开发者

Invalid combination of opcode and operands [duplicate]

This question already has an answer here: Invalid combination of opcode and operands error (1 answer) Closed 6 years ago.
SEGMENT .data
    print       db      "%d %d %d %d This is a test of printf", 10, 0
    rowm        dw      160     ;row multiplier
    iterations  db      80      ;number of columns to set

SEGMENT .bss
    offs        resd    1       ;offset 

SEGMENT .text
    attribute   equ     47h ;color attribute

    global _VText
    global _VPage
    extern _vm_buffer
    extern _printf


_VText:

    push ebp
    mov ebp, esp
    push edi
    push esi
    push eax
    push es
    push ecx
    push edx

    mov esi, [ebp+8]        ;message 
    mov es, [_vm_buffer]
    mov dword [offs], 0

    mov ax, [ebp+12]            ;row
    mul dword[rowm]         ;multiply row by 160, result stored in dx:ax
    add [offs], dx          ;add dx:ax to offset
    shl dword [offs], 16
    add [offs], ax

    mov ax, [ebp+16]            ;column
    shl ax, 1               ;multiply column by 2
    add [offs], ax          ;add ax to offset

    mov ax, [ebp+24]            ;page
    shl ax, 12              ;multiply page by 2^12 (4096)
    add [offs], ax          ;add ax to offset 开发者_StackOverflow中文版  

    mov edi, offs           ;set offset
    mov ah, [ebp+20]        ;attribute

    sub byte[iterations], [ebp+16]   ;so that we don't write too many columns
    mov ecx, iterations

next_char:
    lodsb                   ;get the input string type
    cmp al, 00h             ;check for null character
    je null_ch              ;if null, then quit (null character indicates end of the string)
    stosw                   ;store ax to video memory
    loop next_char          ;will loop 80 times

null_ch:
    pop edx
    pop ecx
    pop es
    pop eax
    pop esi
    pop edi
    pop ebp
    ret


_VPage:



    ret

i researched this error earlier and it said add the bracket i did that and it's not fixing.

help please.


Which architecture is this, and which assembler? Looks like i386 in Intel/NASM-ish syntax to me (but it's just a small snippet). Which line of code is the error on? In any case you can't do this:

sub byte[iterations], [ebp+16]

You can't do a subtract directly from memory to memory. You have to go through an intermediate register, e.g:

mov eax, [ebp+16]
sub byte[iterations], al

But your error might be referring to another line too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜