x86 参数具有非法大小 [tasm]

x86 Argument has Illegal Size [tasm]

我的任务是根据以下规则更改一串数字 (<=100):nr becomes 1 if it's less tham 60 and 2 if not。我想出了这段代码。我认为最大的挑战是打印数字......但它给了我 2 个错误,如代码上标记的那样:

Prints macro number
    mov bx, 10      ; need to divide by 10 to get the last digit
    mov al, number
    mov ah,0
    mov cx,0
    decompose:      
        inc cx
        div bx          ; reminder stored in ah
        mov dl,ah
        add dl,48       ; to convert to char ; <<<<< HERE
        push dl
        cmp al,0        ;the nr=0 means that the loop ends
        jnz decompose

    printloop:  ;loops for as many times as counted in cx ; <<<< HERE
        pop dl  
        mov ah,2h       ; prints whatever is in dl
        int 21h
    loop printloop

        mov dl,' '      ; the space after a number
        mov ah,2h
        int 21h

endm

data segment para public 'data'
    sir DB 15, 78, 12, 39, 42, 88
    lungime_sir EQU $-sir
data ends

;stack segment para public 'stack'
;   dw stack_size dup(?)
;   stack_start label word
;stack ends

code segment para public 'code'
start proc far
    assume cs:code, ds:data
    push ds
    xor ax,ax
    push ax
    mov ax, data
    mov ds, ax

    mov si,0
    mov cx,lungime_sir

next: 
    cmp sir[si],60
    jb mic
    mov sir[si],2
    inc si
loop next

mic: 
    mov sir[si],1
    inc si
    cmp si,lungime_sir
    jle next


    mov cx,lungime_sir
    mov si,0

    ;put values on a stack and pop them out 
print:
    Prints sir[si]
    inc si

loop print


        ret
start endp
code ends
end start

怎么了? :(

push dlpop dl改为push dxpop dx。你不能 push/pop 一个字节。

div bx          ; reminder stored in ah

把这个除法改成div bl得到AH的余数。

mov ah,0放在标签decompose之后,以获得成功的第二次和第三次迭代

mov cx,0
decompose: 
mov ah,0

您已将 Prints 定义为不保留任何寄存器的宏。所以下面的代码不会按预期工作。至少 push/pop 客户体验。

print:
 Prints sir[si]
 inc si
loop print