本人刚学汇编不久 。我刚编了一个程序
输入一个字类型的源码数,在显示器的下一行输出对应的补码数
我的想法是:
EG: 输入8001 即38 30 30 31
先看是不是复数
再一位位地换 38>80>7F>FF>0F>46>输到OUTW 中
30>00>FF>0F>46
.......
程序如下:
stack segment stack 'stack'
dw 100 dup(0)
stack ends
data segment
words db 5,0,5 dup(0)
OUTW DB 5 DUP(0)
SAY DB 'PLEASE IN PUTE A WORD:$'
data ends
code segment
start proc far
assume ss:stack,cs:code,ds:data
push ds
SUB ax,ax
push ax
mov ax,data
mov ds,ax
mov outw+4,'$'
MOV AH,9
MOV DX,OFFSET SAY
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
MOV AH,10
MOV DX,OFFSET WORDS
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
XOR AX,AX
XOR BX,BX
MOV SI,OFFSET WORDS
MOV AL,WORDS+2
MOV CH,0
MOV CL,05H
cmp al,41h
jc aa
sub al,07h
aa: SHL AL,CL
RCL BL,1
MOV AL,WORDS+2
CMP BL,01H
JC OFF1
CMP AL,41H
JC A1
SUB AL,07H
A1: MOV Cx,0004H
SHL AL,CL
NOT AL
ADD AL,80H
SHR AL,CL
CMP AL,0AH
JC B1
ADD AL,07H
B1: ADD AL,30H
OFF1: MOV OUTW,AL
MOV AL,[SI+3]
CMP BL,01H
JC OFF2
PUSHF
CMP AL,41H
JC A2
SUB AL,07H
A2: MOV CX,0004H
SHL AL,CL
NOT AL
SHR AL,CL
CMP AL,0AH
JC B2
ADD AL,07H
B2: ADD AL,30H
OFF2: MOV OUTW+1,AL
MOV AL,[SI+4]
CMP BL,01H
JC OFF3
CMP AL,41H
JC A3
SUB AL,07H
A3: MOV CX,0004H
SHL AL,CL
NOT AL
SHR AL,CL
CMP AL,0AH
JC B3
ADD AL,07H
B3: ADD AL,30H
OFF3: MOV OUTW+2,AL
MOV AL,[SI+5]
CMP BL,01H
JC OFF4
CMP AL,41H
JC A4
SUB AL,07H
A4: MOV CX,0004H
SHL AL,CL
NOT AL
SHR AL,CL
CMP AL,0AH
JC B4
ADD AL,07H
B4: ADD AL,31H
OFF4: MOV OUTW[3],AL
MOV DX,OFFSET OUTW
MOV AH,9
INT 21H
ret
start endp
code ends
end start
运行后说CPU出错
我用的是 未来汇编
我看CPU 一步一步地显示
结果 在 RET 也就是最后的RET之前都是对的
换到 USERS WINDOW 界面也可以看到结果
但一运行 RET 就出错
请问一下是为什么啊!!!!!
急!!!!!
[此贴子已经被作者于2007-11-9 21:55:31编辑过]