汇编语言题~这个程序到底哪错了~

2024-11-22 00:50:47
推荐回答(2个)
回答1:

楼上说的不对, 程序有好几处错误。晚几天再帮你改吧,这几天没空。
今天有空,改好了:
data segment
dat dw -1234h,0ffffh,7fffh,1000h,1001h
dw -123,123,-0ffffh,0ffffh,0ffh
msg db 'display end.$'
wrmsg db 'display wrong.$'
deciml db 5 dup('0'),0ah,0dh,'$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov cx,10
lea di,dat
next: mov bx,[di]
call disp
inc di
inc di
loop next
cmp dx,'ok'
jne wrong
lea dx,msg
jmp mdisp
wrong: lea dx,wrmsg
mdisp: mov ah,09h
int 21h
mov ah,4ch
int 21h

disp proc near
push di
push ax
push dx
mov di,cx
test bx,8000h
jz next3
mov dl,'-'
mov ah,2
int 21h
neg bx

next3:mov cx,5
lea si,deciml+4
next2:mov byte ptr [si],'0'
dec si
loop next2

next1: lea si,deciml+4
mov ax,bx
mov cx,10
again: xor dx,dx
idiv cx
add dl,30h
mov [si],dl
dec si
cmp ax,0
jnz again
lea dx,deciml
mov ah,09h
int 21h
cmp di,1
jnz go
mov dx,'ok'
pop bp
jmp go1
go: pop dx
go1:mov cx,di
pop ax
pop di
ret
disp endp
code ends
end start

回答2:

data SEGMENT
dat DW 1234h,0ffffh,7fffh,1000h,1001h
DW -123,123,-0ffffh,0ffffh,0ffh
msg DB 'display end.$'
wrmsg DB 'display wrong.$'
deciml DB 5 dup('0'),0ah,0dh,'$'
res DW ? ;---------------
data ENDS
code SEGMENT
assume CS:code,DS:data
start: MOV AX,data
MOV DS,AX
MOV CX,10
LEA DI,dat
next: MOV BX,[DI]
CALL disp
INC DI
INC DI
LOOP next
MOV DX,res ;------------------------
CMP dx,'ok'
JNE wrong
LEA DX,msg
JMP mdisp
wrong: LEA DX,wrmsg
mdisp: MOV AH,09h
INT 21h
MOV AH,4ch
INT 21h
disp PROC near
PUSH DI
PUSH AX
PUSH CX
PUSH DX
MOV DI,CX
CMP BX,0
JGE next1
MOV DL,'-'
MOV AH,2
INT 21h
NEG BX
next1: LEA SI,deciml+4
MOV AX,BX
MOV CX,10
again: XOR DX,DX
IDIV CX
ADD DL,30h
MOV [SI],DL
DEC SI
CMP AX,0 ;--------------------------
JGE again
LEA DX,deciml
MOV AH,09h
INT 21h
CMP DI,1
JNZ go
MOV res,'ok' ;--------------------------
go: POP DX
POP CX
POP AX
POP DI
RET
disp ENDP
code ENDS
END start