8086 tasm assembly“操作或指令的参数有非法大小”和“符号已定义类”

时间:2018-03-01 19:58:23

标签: assembly x86-16 tasm

我试图创建一个宏,它在内存中取一个地址和一个数字,然后移动到dl位于给定地址的给定数字位的位。但是每次计算机看到跳转到宏中的标签和标签声明时,我都会得到错误:“操作或指令的参数具有非法大小”和“符号已定义类型”。

    IDEAL
MODEL small
STACK 100h
DATASEG
; --------------------------
; Your variables here
; --------------------------
    var1 db 10101010b
    var2 db 01010101b

CODESEG

macro get0 var0
    mov dl, [var0]
    and dl, 1
endm get0

macro get1 var1
    mov dl, [var1]
    and dl, 2
    shr dl, 1
endm get1

macro get2 var2
    mov dl, [var2]
    and dl, 4
    shr dl, 2
endm get2

macro get3 var3
    mov dl, [var3]
    and dl, 8
    shr dl, 3
endm get3

macro get4 var4
    mov dl, [var4]
    and dl, 16
    shr dl, 4
endm get4

macro get5 var5
    mov dl, [var5]
    and dl, 32
    shr dl, 5
endm get5

macro get6 var6
    mov dl, [var6]
    and dl, 64
    shr dl, 6
endm get6

macro get7 var7
    mov dl, [var7]
    and dl, 128
    shr dl, 7
endm get7

macro get index, get_var ;index - byte
                        ;stores in dl the bit in the index position from get_var
    LOCAL case0
    LOCAL case1
    LOCAL case2
    LOCAL case3
    LOCAL case4
    LOCAL case5
    LOCAL case6
    LOCAL case7
    LOCAL get_exit

    push ax

    mov al, index
    mov ah, 8
    div ah

    cmp ah, 0
    je case0
    cmp ah, 1
    je case1
    cmp ah, 2
    je case2
    cmp ah, 3
    je case3
    cmp ah, 4
    je case4
    cmp ah, 5
    je case5
    cmp ah, 6
    je case6
    cmp ah, 7
    je case7

    case0:
        cbw
        mov si, ax
        get0 byte ptr get_var + si
        jmp exit
    case1:
        cbw
        mov si, ax
        get1 byte ptr get_var + si
        jmp exit
    case2:
        cbw
        mov si, ax
        get2 byte ptr get_var + si
        jmp exit
    case3:
        cbw
        mov si, ax
        get3 byte ptr get_var + si
        jmp exit
    case4:
        cbw
        mov si, ax
        get4 byte ptr get_var + si
        jmp exit
    case5:
        cbw
        mov si, ax
        get5 byte ptr get_var + si
        jmp exit
    case6:
        cbw
        mov si, ax
        get6 byte ptr get_var + si
        jmp exit
    case7:
        cbw
        mov si, ax
        get7 byte ptr get_var + si
        jmp exit

    get_exit:
        pop ax
endm
start:
    mov ax, @data
    mov ds, ax
; --------------------------
; Your code here
; --------------------------
    get 0, var1

exit:
    mov ax, 4c00h
    int 21h
END start
提前谢谢。

0 个答案:

没有答案