代码:
- Assembly code
datarea segment errstr db 'length is too long!',13,10,'$'datarea endsprognam segment main proc far assume cs: prognam,ds:datarea,es:datareastart: push ds sub ax,ax push ax mov ax,datarea mov ds,ax mov ax,datarea mov es,ax ;+++++++++++++++++++++++++++++++++++++ mov ax,0 mov bx,0 mov cx,0 mov di,0AGAIN: mov ax,bx add ax,cx add ax,dx add ax,di cmp ax,1eh ja ERR mov al,01h int 21h cmp al,'$' je EXIT cmp al,'0' jb L1 cmp al,'9' jbe L2 cmp al,'A' jb L1 cmp al,'Z' jbe L3 cmp al,'a' jb L1 cmp al,'z' jbe L4 add bx,1 jmp AGAIN ERR: mov dx,offset errstr mov ah,9h int 21hL1: add bx,1 jmp GOBL2: add cx,1 jmp GOB L3: add dx,1 jmp GOBL4: add di,1 jmp GOBGOB: cmp al,'$' je EXIT jmp AGAINEXIT: ;++++++++++++++++++++++++++++++ retmain endpprognam ends end start
无语法错误,运行直接给我输出:length is too long!了,请问错在哪里
------解决方案--------------------------------------------------------
读入字符的功能调用那里,应该是 mov ah, 1 吧,你笔误成了 mov al, 1
------解决方案--------------------------------------------------------
;这个程序让你参考吧:
data segment
mess db 0dh,0ah,'Input String: $'
sz db 0
dAx db 0
xXx db 0
SZ_C DB 100 DUP ('$')
DX_C DB 100 DUP ('$')
XX_C DB 100 DUP ('$')
CRLF DB 0DH,0AH,'$'
data ends
code segment
assume cs:code, ds:data
main proc far
start:
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
call crlf_p
mov ah,09
mov dx,offset mess
int 21h
next:
mov ah,01
int 21h
CMP AL,0DH
JNZ GOON
JMP DISP_1
GOON:
cmp al,'0'
jl NEXT
cmp al,'9'
jg NO_0_9
inc SZ
MOV BX,OFFSET SZ_C
MOV CX,0
MOV CL,SZ
ADD BX,CX
DEC BX
MOV [BX],AL
JMP NEXT
NO_0_9:
cmp al,'A'
jl NEXT
cmp al,'Z'
jg NO_D_AZ
inc DAX
MOV BX,OFFSET DX_C
MOV CX,0
MOV CL,DAX
ADD BX,CX
DEC BX
MOV [BX],AL
JMP NEXT
NO_D_AZ:
cmp al,'a'
jl NEXT
cmp al,'z'
jg NO_X_AZ
inc XXX
MOV BX,OFFSET XX_C
MOV CX,0
MOV CL,XXX
ADD BX,CX
DEC BX
MOV [BX],AL
JMP NEXT
NO_X_AZ:
JMP NEXT
DISP_1:
CALL CRLF_P
CALL CRLF_P
mov al,SZ
CALL DISP_CZR
mov ah,09
lea dx,SZ_C
int 21h
CALL CRLF_P
mov al,DAX
CALL DISP_CZR
mov ah,09
lea dx,DX_C
int 21h
CALL CRLF_P
mov al,XXX
CALL DISP_CZR
mov ah,09
lea dx,XX_C
int 21h
ret
main endp
DISP_CZR PROC NEAR
xor ah,ah
;mov al,num
mov bl,100d
div bl
push ax
add al,30h
mov dl,al
mov ah,2
int 21h
pop ax
mov al,ah
xor ah,ah
mov bl,10d
div bl
add ax,3030h
push ax
pop dx
mov ah,2
int 21h
mov dl,dh
int 21h
MOV DL,':'
INT 21H
mov dl,' '
int 21h
RET
DISP_CZR ENDP
CRLF_P PROC NEAR
mov ah,09
LEA DX,CRLF
INT 21H
RET
CRLF_P ENDP
code ends
end start
------解决方案--------------------------------------------------------
1
用masm5.0以上编译
2
把下面两行去掉
main proc far
main endp
3
再把最后的ret换成
mov ax,4c00h
int 21h
4
再次编译,如果出错,则根据masm提示的行号,再仔细检查