【问题标题】:error: expression syntax error错误:表达式语法错误
【发布时间】:2012-09-24 04:24:57
【问题描述】:

您好,我在编译 x86 汇编代码时遇到问题,我使用 nasm 进行编译,但编译器告诉我语法错误。我不明白,因为我使用了一个简单的标签并跳转到它?谁能给我解释一下..

; reads character and prints ascii code in console

[BITS 16]

SEGMENT code
..start:
    mov ax, pile
    mov ss, ax
    mov ax, topofstack
    mov sp, ax

loop:               ; gives syntax error
    mov ah, 00h
    int 16h
    cmp ax, 1c0dh   ; user pressed enter, jump to end
    je end

    mov ah, 09h     ; write character and attribute at cursor position
    mov bh, 0h      ; flags...
    mov bl, 08h
    mov cx, 01h
    int 10h
    jmp loop        ; gives syntax error

end:
    mov ax, 04c00h
    int 21h

SEGMENT pile stack
resb 64
topofstack:

【问题讨论】:

    标签: assembly x86 interrupt


    【解决方案1】:

    loop 是一个指令,我建议将标签更改为 loop1 之类的东西。

    有趣的是,这不会在我的 nasm (2.10.03) 版本中导致错误,至少使用命令 nasm -fobj xx.asm,但事实上你的两个错误在包含 loop 的行上可以肯定这是问题所在。

    您可能有更早(或更高)的版本,或者您可能正在使用不同的选项。无论如何,当然值得研究。

    【讨论】:

    • 在 NASM version 0.98.40 (Apple Computer, Inc. build 11) 这正是问题所在。我将循环标签更改为其他东西,它组装得很好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    相关资源
    最近更新 更多