错误:表达式语法错误

时间:2012-09-24 04:24:57

标签: assembly x86 interrupt

您好我编译我的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:

1 个答案:

答案 0 :(得分:4)

loop指令,我建议将标签更改为loop1

有趣的是,这不会导致我的nasm版本(2.10.03)出错,至少使用命令nasm -fobj xx.asm,但事实上你的两个错误就行了包含loop使得这是一个非常安全的选择,这就是问题所在。

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