Assembly 操作码和操作数的组合无效

Assembly 操作码和操作数的组合无效,assembly,opcode,operands,Assembly,Opcode,Operands,我之前研究过这个错误,它说加上我做的括号,它没有修复 请帮忙。这是哪种体系结构,哪种汇编程序?在我看来,英特尔/NASM-ish语法中的i386很像(但它只是一个小片段)。错误在哪一行代码上?在任何情况下,您都不能这样做: SEGMENT .data print db "%d %d %d %d This is a test of printf", 10, 0 rowm dw 160 ;row multiplier it

我之前研究过这个错误,它说加上我做的括号,它没有修复


请帮忙。

这是哪种体系结构,哪种汇编程序?在我看来,英特尔/NASM-ish语法中的i386很像(但它只是一个小片段)。错误在哪一行代码上?在任何情况下,您都不能这样做:

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
你不能直接从一个内存到另一个内存进行减法运算。您必须通过中间寄存器,例如:

sub byte[iterations], [ebp+16]

但是您的错误可能也指向另一行。

这是哪种体系结构,哪种汇编程序?在我看来,英特尔/NASM-ish语法中的i386很像(但它只是一个小片段)。错误在哪一行代码上?在任何情况下,您都不能这样做:

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
你不能直接从一个内存到另一个内存进行减法运算。您必须通过中间寄存器,例如:

sub byte[iterations], [ebp+16]

但您的错误可能也涉及到另一行。

关于nasm和intel,您的看法也是正确的。但我希望这对完整的代码有进一步的帮助。错误在第53行。“子字节[iterations],[ebp+16]”并且在您的更改之后,我没有得到错误。如果您不介意检查此代码的其余部分是否存在与前面类似的哑错误。在x86中,对于大多数指令,至少有一个操作数需要是寄存器(有些例外,例如inc/dec)。您的代码似乎有点“过时”-像“losdb”和“stosw”这样的指令几乎不受欢迎,您会发现“mov al,[esi];add esi,1”等更快(但代码大小没有那么紧凑)。看看英特尔或AMD的优化指南(搜索开发者网站)。另外,“迭代”只有一个字节,这有什么原因吗?作为字节而不是dword没有任何速度优势(它实际上更慢),如果输入大于255,则将进行换行。此外,关于nasm和intel,u也是正确的。但我希望这对完整的代码有进一步的帮助。错误在第53行。“子字节[iterations],[ebp+16]”并且在您的更改之后,我没有得到错误。如果您不介意检查此代码的其余部分是否存在与前面类似的哑错误。在x86中,对于大多数指令,至少有一个操作数需要是寄存器(有些例外,例如inc/dec)。您的代码似乎有点“过时”-像“losdb”和“stosw”这样的指令几乎不受欢迎,您会发现“mov al,[esi];add esi,1”等更快(但代码大小没有那么紧凑)。看看英特尔或AMD的优化指南(搜索开发者网站)。另外,“迭代”只有一个字节,这有什么原因吗?作为字节而不是dword没有速度优势(实际上速度较慢),如果输入大于255,则将进行换行。