汇编上机题集锦

u.################11.13
输入三个十进制数,输入输出有提示,单独占一行
1.十进制输出三个数的平均值
2.十进制输出最大数
3.将三个数由大到小排列,十进制输出,中间用空格分开


data segment
mess1 db 'please input 3 dec number:',0ah,0dh,'$'
mess2 db 'the max number is:','$'
mess3 db 'the avg number is:','$'
mess4 db 'from big to small is:','$'
num db 3 dup(?)
temp db ?
flag db 0
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax

lea dx,mess1
call prompt

mov cl,3
lea si,num
kk: call putindec
call crlf
mov [si],bl
inc si
loop kk

lea dx,mess2
call prompt
mov cl,3
lea si,num
mov al,[si]
ppp1: cmp al,[si+1]
ja ppp
mov al,[si+1]
ppp: inc si
loop ppp1
mov bl,al
call putoutdec
call crlf

lea dx,mess3
call prompt
mov cl,3
lea si,num
mov al,[si]
uuu1: add al,[si+1]
inc si
loop uuu1
mov ah,0
mov bh,3
div bh
mov bl,al
call putoutdec
call crlf

lea dx,mess4
call prompt

mov cl,2
aaa3: mov bl,cl
lea si,num
aaa2: mov al,[si]
cmp al,[si+1]
ja aa
xchg al,[si+1]
mov [si],al
aa: inc si
loop aaa2
mov cl,bl
loop aaa3

lea si,num
mov cl,3
ll: mov bl,[si]
inc si
call putoutdec
call whitespace
loop ll
jmp exit

prompt proc
mov ah,9
int 21h
ret
prompt endp
crlf proc
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
ret
crlf endp
whitespace proc
mov dl,20h
mov ah,2
int 21h
ret
whitespace endp
putindec proc
mov bl,0
rr: mov ah,1
int 21h
cmp al,0dh
je putinexit
sub al,30h
mov ah,0
xchg al,bl
mov bh,10
mul bh
xchg al,bl
add bl,al
jmp rr
putinexit:ret
putindec endp

putoutdec proc
cmp bl,100
jb pp
mov flag,1
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,al
mov temp,ah
pp: cmp bl,10
jb pp1
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,ah
mov dl,al
add dl,30h
mov ah,2
int 21h
pp1: mov dl,bl
add dl,30h
mov ah,2
int 21h
mov dl,temp
cmp flag,0
jne pp3
cmp dl,0
je pp2
pp3: add dl,30h
mov ah,2
int 21h
pp2: ret
putoutdec endp
exit: mov ah,4ch
int 21h
code ends
end start



t.################10.31
输入7个十进制数(0-255)
1.输出提示信息
2.求这7个数中的最大,最小和平均数值,以十进制格式输出
3.求这7个数中从大到小的第四个数,以十进制格式输出
4.比较平均和第四个数的大小,以十进制格式输出较大的数


data segment
mess1 db 'please input 7 dec number(0~30):',0ah,0dh,'$'
mess2 db 'the max,min,avg is:','$'
mess3 db 'from big to small of the fourth number:','$'
mess4 db 'the biger between the fourth and avg:','$'
num db 7 dup(?)
temp db ?
flag db 0
avg db ?
fourth db ?
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax

lea dx,mess1
call prompt

mov cl,7
lea si,num
kk: call putindec
call crlf
mov [si],bl
inc si
loop kk

lea dx,mess2
call prompt
mov cl,6
lea si,num
mov al,[si]
ppp1: cmp al,[si+1]
ja ppp
mov al,[si+1]
ppp: inc si
loop ppp1
mov bl,al
call putoutdec
call whitespace

mov cl,6
lea si,num
mov al,[si]
qqq1: cmp al,[si+1]
jb qqq
mov al,[si+1]
qqq: inc si
loop qqq1
mov bl,al
call putoutdec
call whitespace

mov cl,6
lea si,num
mov al,[si]
uuu1: add al,[si+1]
inc si
loop uuu1
mov ah,0
mov bh,7
div bh
mov avg,al
mov bl,al

call putoutdec
call crlf

lea dx,mess3
call prompt

mov cl,6
aaa3: mov bl,cl
lea si,num
aaa2: mov al,[si]
cmp al,[si+1]
ja aa
xchg al,[si+1]
mov [si],al
aa: inc si
loop aaa2
mov cl,bl
loop aaa3

lea si,num
mov bl,[si+3]
mov fourth,bl
call putoutdec
call crlf

lea dx,mess4
call prompt
mov al,avg

mov bl,fourth
cmp al,bl
ja ww
mov bl,fourth
call putoutdec
jmp exit
ww: mov bl,avg
call putoutdec

jmp exit

prompt proc
mov ah,9
int 21h
ret
prompt endp
crlf proc
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
ret
crlf endp
whitespace proc
mov dl,20h
mov ah,2
int 21h
ret
whitespace endp
putindec proc
mov bl,0
rr: mov ah,1
int 21h
cmp al,0dh
je putinexit
sub al,30h
mov ah,0
xchg al,bl
mov bh,10
mul bh
xchg al,bl
add bl,al
jmp rr
putinexit:ret
putindec endp

putoutdec proc
cmp bl,100
jb pp
mov flag,1
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,al
mov temp,ah
pp: cmp bl,10
jb pp1
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,ah
mov dl,al
add dl,30h
mov ah,2
int 21h
pp1: mov dl,bl
add dl,30h
mov ah,2
int 21h
mov dl,temp
cmp flag,0
jne pp3
cmp dl,0
je pp2
pp3: add dl,30h
mov ah,2
int 21h
pp2: ret
putoutdec endp
exit: mov ah,4ch
int 21h
code ends
end start


s.################北大系统班“汇编语言”上机考试题
1.提示从键盘输入<80个字符的串提示语独占一行{必做}
2.以16进制输出字符串中非字母字符的个数(不是a to z and A to Z){必做}
3.把字串中的大写字母变为小写并输出{选做}
4.找到输入的串中的字符中Asscii 码值最大的 Asscii 码以16进制输出{选做}



data segment
aa db 'please input some (<80)',0ah,0dh,'$'
bb db 'the tatal of no char num:','$'
cc db 'the convert:','$'
ee db 'the max ASCII number is: ','$'
num db 80
db ?
db 80 dup(?)
cou db 0
maxa db 0
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax

lea dx,aa
mov ah,09h
int 21h

lea dx,num
mov ah,0ah
int 21h
call crlf

lea dx,bb
mov ah,09h
int 21h

lea si,num+2
mov bl,0
mov cl,num+1

q: mov al,[si]
inc si
cmp al,'A'
jb pp
cmp al,'Z'
jb pp1
cmp al,'a'
jb pp
cmp al,'z'
jb pp1
pp: inc cou
pp1: loop q


exit: mov al,cou
mov bh,cou
mov cl,4
shr al,cl
cmp al,10
jb kk1
add al,7
kk1: add al,30h
mov dl,al
mov ah,2
int 21h
and cou,0fh
cmp cou,10
jb kk2
add cou,7
kk2: add cou,30h
mov dl,cou
mov ah,02h
int 21h
call crlf

lea dx,cc
mov ah,09h
int 21h
mov si,0
lea si,num+2
mov cl,num+1
call convert

lea dx,ee
mov ah,09h
int 21h



mov si,0
mov al,0
lea si,num+2
mov cl,num+1
mov bl,[si]

ll: inc si
cmp bl,[si]
ja gg
mov bl,[si]
gg: mov maxa,bl
mm: loop ll
mov al,bl
mov cl,4
shr al,cl
call vv
jmp xx
vv proc
cmp al,10
jb uu
add al,07h
uu: mov dl,al
add dl,30h
mov ah,02h
int 21h
ret
vv endp
xx: and bl,0fh
mov al,bl

call vv
jmp oo


convert proc
qq: mov al,[si]
cmp al,'A'
jb qq2
cmp al,'Z'
ja qq2
add al,20h
qq2:
mov dl,al
mov ah,02h
int 21h
inc si
loop qq
call crlf
ret
convert endp
crlf proc
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
ret
crlf endp
oo: mov ah,4ch
int 21h


code ends
end start


r.################10月30日模拟练习题
输入一个数(0~255)
1.输入输出提示
2.若能除以15,则yes,否no
3.以十进制输出商
4.以二进制输出余数


data segment
mess1 db 'please input a dec number:',0dh,0ah,'$'
mess2 db 'wheather div 15:','$'
mess3 db 'yes',0ah,0dh,'$'
mess4 db 'no',0ah,0dh,'$'
mess5 db 'shang:','$'
mess6 db 'yun:','$'
shang db ?
yun db ?
nozero db 0
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax

lea dx,mess1
call prompt

mov bl,0
pp: mov ah,1
int 21h
cmp al,0dh
je putinexit
sub al,30h
mov ah,0
xchg al,bl
mov bh,10
mul bh
xchg al,bl
add bl,al
jmp pp

putinexit:call crlf
lea dx,mess2
call prompt
mov al,bl
mov ah,0
mov bh,15
div bh
mov shang,al
mov yun,ah
cmp ah,0
je pp1
lea dx,mess4
call prompt

lea dx,mess5
call prompt
mov bl,shang
call putoutdec
call crlf
lea dx,mess6
call prompt
mov bl,yun
call putoutbin
jmp exit

pp1: lea dx,mess3
call prompt
lea dx,mess5
call prompt
mov bl,shang
call putoutdec
call crlf
lea dx,mess6
call prompt
mov dl,0
add dl,30h
mov ah,2
int 21h

jmp exit

prompt proc
mov ah,9
int 21h
ret
prompt endp
crlf proc
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
crlf endp


putoutdec proc
cmp bl,10
jb ww
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,ah
mov dl,al
add dl,30h
mov ah,2
int 21h

ww: mov dl,bl
add dl,30h
mov ah,2
int 21h
ret
putoutdec endp

putoutbin proc
mov cl,8
hh: mov dl,0
test bl,80h
je hh1
mov dl,1
mov nozero,1
jmp hh2
hh1:
cmp nozero,0
je hh3

hh2: add dl,30h
mov ah,2
int 21h

hh3: shl bl,1
loop hh
ret
putoutbin endp

exit:mov ah,4ch
int 21h
code ends
end start



q.################11月2日模拟练习题
输入两个数(0~255)
1.以十进制输出和
2.若和为偶数,则yes,否no
3.以二进制输出两个数中大者


data segment
mess1 db 'please input 2 dec number:',0ah,0dh,'$'
mess2 db 'the sum is:','$'
mess3 db 'wheather the sum is even:','$'
mess4 db 'yes',0ah,0dh,'$'
mess5 db 'no',0ah,0dh,'$'
mess6 db 'the bigger in two number:','$'
num1 db ?
num2 db ?
sum db ?
temp db ?
flag db 0
nozero db 0
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax

lea dx,mess1
call prompt

call putindec
mov num1,bl
call crlf
call putindec
mov num2,bl
call crlf

lea dx,mess2
call prompt
mov bl,num1
add bl,num2
mov sum,bl
call putoutdec
call crlf

lea dx,mess3
call prompt
mov al,sum
mov ah,0
mov bh,2
div bh
cmp ah,0
je kk
lea dx,mess5
call prompt
jmp kk1
kk: lea dx,mess4
call prompt

kk1: lea dx,mess6
call prompt
mov bl,num1
cmp bl,num2
ja kk2
mov bl,num2
kk2: call putoutbin

jmp exit
prompt proc
mov ah,9
int 21h
ret
prompt endp
crlf proc
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
ret
crlf endp
putindec proc
mov bl,0
qqq: mov ah,1
int 21h
cmp al,0dh
je putinexit
sub al,30h
mov ah,0
xchg al,bl
mov bh,10
mul bh
xchg al,bl
add bl,al
jmp qqq
putinexit:ret
putindec endp
putoutdec proc
cmp bl,100
jb pp1
mov flag,1
mov al,bl
mov ah,0
mov bh,10
div bh
mov temp,ah
mov bl,al
pp1: cmp bl,10
jb pp2
mov al,bl
mov ah,0
mov bh,10
div bh
mov bl,ah
mov dl,al
add dl,30h
mov ah,2
int 21h
pp2: mov dl,bl
add dl,30h
mov ah,2
int 21h

mov dl,temp
cmp flag,0
jne pp3
cmp dl,0
je pp4
pp3: add dl,30h
mov ah,2
int 21h
pp4: ret
putoutdec endp
putoutbin proc
mov cl,8
aa1: mov dl,0
test bl,80h
je aa
mov nozero,1
mov dl,1

aa: cmp nozero,0
je aa2
add dl,30h
mov ah,2
int 21h
aa2: shl bl,1
loop aa1
ret
putoutbin endp
exit:mov ah,4ch
int 21h
code ends
end start



上面的五个程序就是从u-q的答案,程序我都是自己编过后调试成功的,如果你在使用时发现了什么问题请与我联系,祝你成功。 
 

你可能感兴趣的:(病毒研究)