DATAS SEGMENT
letter db 0
digit db 0
other db 0
str db 80,?,80 dup(?)
str2 db 'letter:$'
str3 db 'digit:$'
str4 db 'other:$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
lea dx,str
mov ah,0ah
int 21h
mov ch,0
mov cl,80
L1:mov ah,1
int 21h
cmp al,0dh
jz over
cmp al,'0'
jb others
cmp al,'9'
ja L2
jmp digits
L2:cmp al,'A'
jb others
cmp al,'Z'
ja L3
jmp letters
L3:cmp al,'a'
jb others
cmp al,'z'
ja others
jmp letters
letters:
inc letter
jmp over1
digits:
inc digit
jmp over1
others:
inc other
jmp over
over1:
loop L1
over:
call endline
lea dx,str2
mov ah,9
int 21h
sub ax,ax
mov al,letter
call display
call endline
lea dx,str3
mov ah,9
int 21h
sub ax,ax
mov al,digit
call display
call endline
lea dx,str4
mov ah,9
int 21h
sub ax,ax
mov al,other
call display
MOV AH,4CH
INT 21H
endline proc near
mov ah,2
mov dl,0ah
int 21h
mov ah,2
mov dl,0dh
int 21h
ret
endline endp
display proc near
mov dl,al
add dl,30h
mov ah,2
int 21h
ret
display endp
CODES ENDS
END START
error A2085:instruction or register not accepted in current CPU mode.
(此代码需要实现的功能是:键入一串字符,输出字符中字母、数字、其他字符的个数。)
这个代码是我各处摘抄的……一定有很多问题。
子程序有保护现场和恢复现场要在哪里写?按照上面写的代码需要保护的寄存器是ax么?