尝试将十六进制转换为 ascii 时出现 "wrong addressing" 错误
Getting "wrong addressing" error while trying to convert hexadecimal to ascii
我是这门语言的新手,正在努力熟悉它。在此示例中,我收到 "wrong addressing" 错误,但它有什么问题?
hextoasc proc near ; AX input, si point result storage address
push ax bx cx dx si di bp es
mov cx,00h
mov bx,0ah
hexloop1:
mov dx,0
div bx
add dl,'0'
push dx
inc cx
cmp ax, 0ah
jge hexloop1
add al, '0'
mov [si], al
hexloop2:
pop ax
inc si
mov [si], al
loop hexloop2
inc si
mov al, '$'
mov [si], al
pop es bp di si dx cx bx ax
ret
endp
这是我的错误:
尽管它似乎在抱怨寻址模式,但看起来它实际上并不喜欢这条线:
push ax bx cx dx si di bp es
这实际上不是有效的 8086 操作(push
和 pop
操作码需要 one 寄存器)所以,除非你有一个足够聪明的汇编器要将其分解为单独的说明,您必须自己完成:
push ax
push bx
push cx
push dx
push si
push di
push bp
push es
; all your other code goes here.
pop es
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
我是这门语言的新手,正在努力熟悉它。在此示例中,我收到 "wrong addressing" 错误,但它有什么问题?
hextoasc proc near ; AX input, si point result storage address
push ax bx cx dx si di bp es
mov cx,00h
mov bx,0ah
hexloop1:
mov dx,0
div bx
add dl,'0'
push dx
inc cx
cmp ax, 0ah
jge hexloop1
add al, '0'
mov [si], al
hexloop2:
pop ax
inc si
mov [si], al
loop hexloop2
inc si
mov al, '$'
mov [si], al
pop es bp di si dx cx bx ax
ret
endp
这是我的错误:
尽管它似乎在抱怨寻址模式,但看起来它实际上并不喜欢这条线:
push ax bx cx dx si di bp es
这实际上不是有效的 8086 操作(push
和 pop
操作码需要 one 寄存器)所以,除非你有一个足够聪明的汇编器要将其分解为单独的说明,您必须自己完成:
push ax
push bx
push cx
push dx
push si
push di
push bp
push es
; all your other code goes here.
pop es
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax