assumecs:code
org100h
start:
jmpbbb
lfcrdb13,10,'$'
bbb:
pu" />

嫒美直播免费版app下载-嫒美直播永久免费版下载-嫒美直播最新下载安装

當(dāng)前位置:首頁 > 資格考試 > 正文

匯編編程問題:用匯編語言編寫程序,從屏幕輸入10個(gè)兩位的十制數(shù)(包含正數(shù)和負(fù)數(shù))

用匯編語言編寫程序段,實(shí)現(xiàn)從鍵盤輸入十個(gè)一位10進(jìn)制數(shù)后累加以非壓縮BCD碼形式存放在AH和AL中.

codesegment
assumecs:code
org100h
start:
jmpbbb
lfcrdb13,10,'$'
bbb:
pushcs
popds
callinputnum
movah,9
leadx,lfcr
int21h
leasi,array
movch,0
movcl,byteptr[num]
movax,0
lp:
addax,wordptr[si]
daa;十進(jìn)制加法調(diào)整指令
incsi
incsi
looplp
calldispnum
movah,4ch
int21h
dispnumprocnear
;將要顯示的數(shù)據(jù)放入AL中
movdl,al;將AL暫存在DL中
andal,0Fh;取AL的低4位
movbl,al;非壓縮的bcd碼
addbl,30h;轉(zhuǎn)成ASCii碼

moval,dl;取回AL并經(jīng)以下4次右移取出AL的高4位
shral,1
shral,1
shral,1
shral,1
movbh,al;非壓縮的bcd碼
addbh,30h;轉(zhuǎn)成ASCii碼
movax,bx;非壓縮的兩位數(shù)的ASCii碼存放在AX中

movbyteptr[y+4],al
movbyteptr[y+3],ah
movah,9
leadx,y
int21h
ret
ydb10,13,0,0,0,'$'
dispnumendp
inputnumprocnear
;輸入的數(shù)據(jù)以一個(gè)空格分隔,以回車符結(jié)束輸入
leadi,array;將數(shù)組第一個(gè)元素的有效地址置入DI
movbyteptr[num],0
stin:
movax,0
pushax
again1:
movah,1
int21h
movbyteptr[char],al
cmpal,13
jeline0
cmpal,''
jeline0
subal,30h
movah,0
movsi,ax
popax
movcl,10
movch,0
mulcx
addax,si
pushax
jmpagain1
line0:
popax
movwordptr[di],ax
incbyteptr[num]
cmpbyteptr[char],13
jestinend
incdi
incdi
jmpstin
stinend:
ret
arraydw100dup(0)
numdb0
chardb?
inputnumendp
codeends
endstart

微機(jī)原理,用匯編語言編寫,給定一組數(shù)據(jù),大概十個(gè)數(shù),統(tǒng)計(jì)正數(shù),負(fù)數(shù),0的個(gè)數(shù),并顯示到屏幕上(重要

"1.編制一段程序求出下列公式中z的值并放在result單元,注x,y,result分別定義成字類型變量 \ z=((x+y)*4-y)/2 \ \ 答: \ mov ax,x \ add ax,y \ shl ax,1 \ shl ax,1 \ sub ax,y \ shr ax,1 \ mov result,ax\ \ 2.試編寫一小側(cè)面硬指令序列,在屏幕上顯示出\"hello everybody!\"字符串,該字符串已在數(shù)據(jù)段定義好為變量string \ 答: \ lea dx,string \ mov ah,9 \ int 21h"【摘要】 微機(jī)原理,用匯編語言編寫,給定一組數(shù)據(jù),大概

用匯編語言編寫從鍵盤輸入兩個(gè)兩位的十進(jìn)制數(shù),做加法運(yùn)算,并顯示結(jié)果。

codesegment
assumecs:code
org100h
start:
jmpbbb
lfcrdb13,10,'$'
bbb:
pushcs
popds
callinputnum
movah,9
leadx,lfcr
int21h
leasi,array
movch,0
movcl,byteptr[num]
movax,0
lp:
addax,wordptr[si]
incsi
incsi
looplp
;movcl,byteptr[num]
;divcl
calldispnum
movah,1
int21h
movah,4ch
int21h
dispnumprocnear
;將要顯示的數(shù)據(jù)放入AL中
movah,0
movcl,10
divcl
movbyteptr[y+4],ah;保存?zhèn)€位
movah,0
divcl
movbyteptr[y+3],ah;保存十位
movah,0
movbyteptr[y+2],al;保存百位
moval,byteptr[y+2]
addal,30h;百位轉(zhuǎn)ASC2
movbyteptr[y+2],al
moval,byteptr[y+3]
addal,30h;十位轉(zhuǎn)ASC2
movbyteptr[y+3],al
moval,byteptr[y+4]
addal,30h;個(gè)位轉(zhuǎn)ASC2
movbyteptr[y+4],al
movah,9
leadx,y
int21h
ret
ydb10,13,0,0,0,'$'
dispnumendp
inputnumprocnear
;輸入的數(shù)據(jù)以一個(gè)空格分隔,以回車符結(jié)束輸入
leadi,array;將數(shù)組第一個(gè)元素的有效地址置入DI
movbyteptr[num],0
stin:
movax,0
pushax
again1:
movah,1
int21h
movbyteptr[char],al
cmpal,13
jeline0
cmpal,''
jeline0
subal,30h
movah,0
movsi,ax
popax
movcl,10
movch,0
mulcx
addax,si
pushax
jmpagain1
line0:
popax
movwordptr[di],ax
incbyteptr[num]
cmpbyteptr[char],13
jestinend
incdi
incdi
jmpstin
stinend:
ret
arraydw100dup(0)
numdb0
chardb?
inputnumendp
codeends
endstart

用匯編語言編寫代碼轉(zhuǎn)換程序。編程實(shí)現(xiàn)十制數(shù)和二進(jìn)制數(shù)之間的轉(zhuǎn)換(要求鍵入被轉(zhuǎn)換數(shù),轉(zhuǎn)換的結(jié)果要求從

dsegsegment
msg0db'pleaseInputadecimalnumber<65536:$'
dsegends
assumecs:cseg,ds:dseg
csegsegment
start:
movax,dseg
movds,ax
movah,9
leadx,msg0
int21h

callreadn

movah,0eh
moval,0dh
int10h
moval,0ah
int10h
callprintBin
movah,4ch
int21h
;readinputdecimalnumber
;storeinbx
readnprocnear
movbx,0
movcx,10
movsi,0
r0:
movah,7
int21h
cmpal,0dh
jzr3
cmpal,'0'
jbr0
cmpal,'9'
jar0
movah,0eh
int10h

andal,0fh
movah,0
xchgax,bx
mulcx

addbx,ax
cmpbx,65535
jbr0
r3:
ret
readnendp
;print(bx)->binary
printBinprocnear
movcx,16
movah,0eh
p1:
rolbx,1
moval,bl
andal,1
xoral,30h
int10h
loopp1
ret
printBinendp
csegends
endstart

匯編語言程序(輸入十個(gè)負(fù)數(shù),輸出其中最小的)

ORG 0000H LJMP MAIN0 ORG 0030H MAIN0:MOV A,#10H ACALL MAIN ;長調(diào)用排序程序 MOV P1,A SJMP $ MAIN: ;子程序入口 MOV R6,#00 ;起停標(biāo)志位 LOOP:CLR 00H ;置換標(biāo)志位 MOV R0,#40H ;數(shù)據(jù)存儲(chǔ)單元 MOV R7,#10 ;循環(huán)次數(shù)控制 JIXU:MOV A,@R0 ;取第一個(gè)數(shù) MOV 2AH,A ;存儲(chǔ) INC R0 ;調(diào)整數(shù)據(jù)指針 MOV 2BH,@R0 ;取第二個(gè)數(shù),存儲(chǔ) CLR C ;清零 SUBB A,@R0 ;減法 JNC NEXT ;判斷大小 MOV A,@R0 ;交換
展開全文閱讀