汇编输出杨辉三角 - 百度文库 ر

1.2

1ÿҶԳƣ1ʼ𽥱ȻСص1 2nеָΪn

3nֺΪ2^(n1)2ģn-1η

4ÿֵһе֮͡ôд˹Ρ 52n+1е12n+2е32n+3е5??һߣЩĺǵ2n쳲2nе22n+1е42n+2е6??Щ֮ǵ2n-1쳲

6nеĵ1Ϊ1ڶΪ1(n-1)Ϊ1(n-1)n-2/2ĸΪ1(n-1)n-2/2n-3/3?ơ

7.δ֪͵nηĸϵΪǵĵ(n+1)С

ͼ1-2-1 ͼ 1-2-2 ѧʽ

һ Լ

2.1 Ըſ

ݱҪͨԱдҪܹʾϢ£ӼһݣʾϢʾӦǡԻ򵥵Ľܡ

(AssemblyLanguage)ijԡڻУǷ(Memoni)룬õַ(Symbol)(Label)ַ롣÷ŴԵĶ룬ͰѻԱ˻ԡǻΪԡʹûԱдij򣬻ֱʶҪһֳ򽫻Էɻԣõijл򣬻ϵͳԴϵͳѻԷɻԵĹ̳Ϊࡣ

һֹܺǿijԣҲüӲԲֱӿӲԡԣΪһԣӦڸ߼ԵıҪһѻԭļɻִеĴ롣߼ĻMASMTASMȵΪдṩ˺ܶڸ߼ԵṹȡĻбдĻкܴһαָѾͬڸ߼ԡڵĻ໷Ѿ˸߼ʹȫûдwindowsӦóҲǿеģⲻǻԵijԵijڱдЧҪԻӲȷƵij

(Assembly Language)һֲǷʾijԣǷʾָIJͲ÷ŻŴַǷһ㶼Ӣĵʵдʶͼ䡣ʹûԱдijΪԴ򡣻ԴɻֱִУ뷭лɵĿĹ̳ΪࡣѻԴĿΪ

أ֮ԵĶӦϵһָӦһԴ룬ԻԺͻһԡʹûԽгܳûӲܺͽṹص㣬ӶЧؼӿִٶȣٳռõĴ洢ռ䡣ԻԴڱдϵͳʵʱͨųʵʱƳȡ

Ϊı֮һȻӦõķΧܹ㣬ҪȴӹɣΪܹ޷ɵĹܡLinuxںȻ󲿷ִCԱдģȻɱijЩؼطʹ˻룬ҪLinux֡ⲿִӲĹϵdzУʹCҲЩģܹܺﳤ̣ܶ޶ȵطӲܡ

2.2 ŵ㼰ȱ

ֱͬĵײӲнһЩŵ㣺 1ֱܹӷӲصĴ洢I/O˿ڣ

2ܹܱƣɵĶƴȫĿƣ

3ܹԹؼи׼ȷĿƣ̹߳ͬʻӲ豸

4ܹضӦöԴѵŻٶȣ 5ܹ޶ȵطӲĹܡ

ͬʱӦʶһֲηdz͵ԣֱֹдƵĻָ룬˲ɱشһЩȱ㣺 1дĴdzѶά 2ײbugڵԣ

3ֻضϵṹʹŻ 4Чʺܵͣʱ䳤ҵ

ȳʼʱڵʾʾϢIJֻ110֮Χ̫СʾʾϢ󡣵õǵĽ֮󼴵һ㷨ӳӦÿһֵÿһֵѹջбԺʱֱӵá֮ͨѭdiÿһУͬʱͨڲѭsiһеÿһʱͨshowӳ־ʮֵʱͨshowspace֮Ŀոǰոϰ벿ֵֵ֮ոʽһԤƵĴ洢ԪڣȻֱʵĻдӡһεǡ

ڶ ӳ

4.1 ӳ

int 16 ahΪ0һܣӼ̶ַַalУʱcmpжַֻ0~9ÿַתΪʮƴ沢չΪִaxУٽaxʼΪ0bpٽaxʮbpӣbpУٷ룬λ shur proc push cx push bx xor bp,bp mov bx,10 mov cx,2 input:

mov ah,0 ;ݴal int 16h

cmp al,0dh ;Իس jz ok

cmp al,'0' ;ֻ0~9 jb input cmp al,'9' ja input

mov ah,0eh ;ʾЧ int 10h

sub al,30h ;ASCIIΪʮ cbw ;ֽչΪ xchg ax,bp

mul bx ;10 add bp,ax ;һλ loop input

ok:nop ;ֵBP pop bx ;ָõļĴ pop cx ret shur endp

4.2㷨ӳ

ijmnеC(n, m)ʱõݹķ㷨ǣ