我刚学汇编不久,遇到个汇编题,想了好久都不会,请会的教一下,谢谢!

2024-12-12 10:46:25
推荐回答(1个)
回答1:

LOCALS @@
.model small
.stack 100h
.data

Jan db 'Jan$'
Feb db 'Feb$'
Mar db 'Mar$'
Apr db 'Apr$'
May db 'May$'
June db 'June$'
July db 'July$'
Aug db 'Aug$'
Sept db 'Sept$'
Oct db 'Oct$'
Nov db 'Nov$'
Dece db 'Dec$'
;
Errmsg db 'Month must in (1 - 12)', 0dh, 0ah, 24h
;
Names dw Errmsg, Jan,Feb,Mar,Apr,May,June,July,Aug,Sept,Oct,Nov,Dece
;
;
.code
;entry: none
;exit : al
input proc near
push bx

xor bx, bx
@@0:
mov ah, 7
int 21h
cmp al, 0dh
je @@1

cmp al, '0'
jb @@0
cmp al, '9'
ja @@0

mov dl, al
mov ah, 2
int 21h

sub al, '0'
shl bl, 1
mov bh, bl
shl bl, 1
shl bl, 1
add bl, bh
add bl, al
jmp short @@0
@@1:
mov al, bl
pop bx
ret
input endp
;
;entry: al
;exit : none
disp proc near
push ax
push bx
push dx

lea dx, errmsg
cmp al, 12
ja @@1

xor ah, ah
mov bx, ax
shl bx, 1
mov dx, word ptr Names[bx]

@@1:
mov ah, 9
int 21h
pop dx
pop bx
pop ax
ret
disp endp
;
main proc far

mov ax, @data
mov ds, ax

call Input
call Disp

mov ax, 4c00h
int 21h
main endp
end main