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

发布于 2024-10-27 16:55:06 字数 1774 浏览 1 评论 0原文

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

我之前研究过这个错误,它说添加括号,我这样做了,但它没有修复。

请帮忙。

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.

help please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2024-11-03 16:55:06

这是哪种架构,哪种汇编器?对我来说,看起来像 Intel/NASM-ish 语法中的 i386(但这只是一个小片段)。错误出现在哪一行代码上?无论如何你都不能这样做:

sub byte[iterations], [ebp+16]

你不能直接从内存到内存进行减法。您必须通过中间寄存器,例如:

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文