操作码和操作数的无效组合 [英] Invalid combination of opcode and operands

查看:272
本文介绍了操作码和操作数的无效组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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   

    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.

请帮助.

推荐答案

这是哪个体系结构,以及哪个汇编程序?在我看来,Intel/NASM-ish语法中的i386看上去很可爱(但这只是一个小片段).错误在哪一行代码上?无论如何,您不能这样做:

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.

这篇关于操作码和操作数的无效组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆