首页 > 解决方案 > TASM 代码在 YASM 中给出错误:标签后预期的指令

问题描述

我有我为 TASM 编写的代码,据我所知 YASM 与该代码兼容,所以 IDK 为什么会出现这些错误:

91.asm:3: error: instruction expected after label
91.asm:4: error: instruction expected after label
91.asm:27: error: instruction expected after label

对于此代码:

IDEAL
MODEL small
STACK 21h
DATASEG
; --------------------------
; Your variables here
; --------------------------
CODESEG
global start
start:
; --------------------------
; Your code here
; --------------------------
    mov cx, 21
    mov ax, 1000h
    cmp cx, 0
    je myExit
addStack:
    push ax
    inc ax
    loop addStack
myExit:
exit:
    mov ax, 4C00h
    int 21h
END start

标签: assemblytasmyasm

解决方案


据我所知, YASM与 TASM兼容。它与使用完全不同指令的N ASM兼容。(和不同的含义mov reg, label- 在 NASM/YASM 中,它是地址的 mov-immediate,与 TASM/MASM 不同,它是负载。)

一行上没有 a 的东西:可以是标签(如果它不被识别为指令助记符,这是 YASM 所假设的)。

但是,如果它后面跟着其他也不被理解为指令的东西(如smallin MODEL small),那就是语法错误。

对 YASM 使用 NASM / YASM 语法。


推荐阅读