杨季文的80x86汇编语言程序设计
masm汇编时说类型不匹配
检查了下发现也没错误,用debug太麻烦了,哪位电脑上有od的,就拜托了.
mlength=128;buffer size
;
dseg segment
buff db mlength
db ?
db mlength dup (?)
mess0 db 'please input:$"'
mess1 db 'length=$'
mess2 db 'x=$';number in bh
mess3 db 'y=$';letter in bl
dseg ends
;
cseg segment
assume cs:cseg,ds:dseg
start:mov ax,dseg
mov ds,ax
mov dx,offset mess0
call dispmess
mov dx,offset buff
mov ah,10;10=oah
int 21h
call newline
;清数字符计数 bh
;清字母符计数器 bl
;mov bh,0
;mov bl,0
xor bx,bx
;
mov cl,buff+1;get character string's actual length
mov ch,0
jcxz cok
mov si,buff+2
again:mov al,[si]
inc si
cmp al,'0'
jb next
cmp al,'9'
ja nodec
inc bh
jmp short next
nodec:or al,20h
cmp al,'a'
jb next
cmp al,'z'
ja next
inc bl
next:loop again
;
cok:mov dx,offset mess1
call dispmess
mov al,buff+1
xor ah,ah
call dispal
call newline
;
mov dx,offset mess2
call dispmess
mov al,bh
xor ah,ah
call dispal
call newline
;
mov dx,offset mess3
mov al,bl
xor ah,ah
call dispal
call newline
;
mov ax,4c00h
int 21h
;
;dispal
;in:al=8 bit binary digit
;out:null
dispal proc
mov cx,3
mov dl,10
disp1:div dl
xchg ah,al
add al,'0'
push ax
xchg ah,al
mov ah,0
loop disp1
mov cx,3
disp2:pop dx
call echoch
loop disp2
ret
dispal endp
;
;explanation:show dx
dispmess proc
mov ah,9
int 21h
ret
dispmess endp
;
;explanation:show dl
echoch proc
mov ah,2
int 21h
ret
echoch endp
;
newline proc
push ax
push dx
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
pop dx
pop ax
ret
newline endp
;
cseg ends
end start