Search code examples
assemblyx86-16tasm

How to fix "Expecting pointer type" and "symbol already different kind" in macros


I'm not sure what I'm doing wrong.

I've tried adding the prefix @@ in the macros as well declaring local @@label in the macros, it didn't work.

I've also checked this site link as well that was mentioned in the previous problems... It didn't work.

.286
.model small
.stack 100h

writeString macro string, length, x, y, color
    mov ah, 13h
    mov al, 0
    mov bh, 0
    mov bl, color
    lea bp, string
    mov cx, length
    mov dl, x
    mov dh, y
    int 10h
endm

draw_box_outline macro x_fin,y_fin,x_ini,y_ini

    local col_draw,row_draw,row_rev,col_rev

    mov cx,x_ini
    mov dx,y_ini
    mov ah,0ch
    mov al,1111b
    int 10h

    col_draw:
    inc cx
    int 10h
    cmp cx,x_fin
    jb col_draw    

    row_draw:
    inc dx
    int 10h
    cmp dx,y_fin
    jb row_draw

    row_rev:
    dec cx
    int 10h
    cmp cx,x_ini
    ja row_rev

    col_rev:
    dec dx
    int 10h
    cmp dx,y_ini
    ja col_rev
endm

.data
msg db "Select Number of Player/s$"
msg1 db "1$"

;box parameters
b1_col_ini equ 50
b1_row_ini equ 110
b1_col_fin equ 90
b1_row_fin equ 150

b2_col_ini equ 130
b2_row_ini equ 110
b2_col_fin equ 170
b2_row_fin equ 150

b3_col_ini equ 210
b3_row_ini equ 110
b3_col_fin equ 250
b3_row_fin equ 150

.code
org 100h
main proc far
    mov ax,@data
    mov ds,ax
    mov es,ax

    mov ah,0h
    mov al,13h
    mov bh,0
    int 10h

    writeString msg,25,7,10,1111b

    draw_box_outline b1_col_fin,b1_row_fin,b1_col_ini,b1_row_ini
    draw_box_outline b2_col_fin,b2_row_fin,b2_col_ini,b2_row_ini
    draw_box_outline b3_col_fin,b3_row_fin,b3_col_ini,b3_row_ini

    writeString msg,25,7,10,1111b
    ;implement cursor press and detection
    ;implement cursor hide

    mov ax,4c00h
    int 21h
main endp
end main   

In DOSBox I keep getting the error "expected pointer type" and "symbol already of different kind" but in emu8086, there wasn't any problem.


Solution

  • The LOCAL directive must be at the very beginning of the macro. The blank line between the macro declaration and the LOCAL line is already too much. It should look like this:

    draw_box_outline macro x_fin,y_fin,x_ini,y_ini
    local col_draw,row_draw,row_rev,col_rev
    

    Also, take a look here: TASM; LOCAL and LOCALS directives.