News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

syntax error with a macro

Started by zak100, August 07, 2009, 06:29:28 AM

Previous topic - Next topic

zak100

Hi,
I want to print a string using a macro at boot time, passing the name of string as argument, but I am getting a syntax error. Can somebody plz help me with this?

D:\masm prog>ml bpb_str.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: bpb_str.asm
bpb_str.asm(53) : error A2008: syntax error : print_mesg

D:\masm prog>

Zulfi.


;----------------------------------------------------------------------------------

        .MODEL  TINY


        .CODE

;----------------------------------------------------------------------------------

        ORG     0

;code branch

boot0:  jmp short boot1

;----------------------------------------------------------------------------------

        ORG     3

;OEM identifier

boot03  db      'BootDisk'     ;always 8 characters


.STACK 2048; removes the stack warning

;----------------------------------------------------------------------------------

        ORG     0Bh


boot0B  dw      200h           ;bytes per sector
boot0D  db      1              ;sectors per cluster
boot0E  dw      1              ;reserved sectors (the boot sector is reserved)
boot10  db      2              ;number of copies of the FAT
boot11  dw      0E0h           ;root directory entries (224 for 1.4 mb)
boot13  dw      0B40h          ;total disk sectors
boot15  db      0F0h           ;media descriptor byte (F0 for 1.4 mb)
boot16  dw      9              ;sectors per FAT
boot18  dw      12h            ;sectors per cylinder
boot1A  dw      2              ;number of heads
boot1C  dw      0              ;hidden sectors


;----------------------------------------------------------------------------------

boot1: cli                     ;disable maskable interrupts
       xor     di,di
       mov     ss,di
       mov     sp,7C00h        ;SS:SP = 0000:7C00
sti

      print_mesg msg

boot2: jmp     boot2

;----------------------------------------------------------------------------------

;data area - notice the absence of a ".DATA" directive

msg     db      "We be bootin2'!"

print_mesg macro offset1
mov     ax,7C0h
       mov     ds,ax
       push    ax
       mov     ax,xlat0
       push    ax
       retf

;at this point, the registers are as follows:

;DI = 0000
;CS = DS = 07C0
;IP = xlat0 offset
;SS:SP = 0000:7C00

;display the message at B800:0000

xlat0: mov     ax,0B800h       ;notice that di is already 0
       mov     es,ax
       mov     si,offset offset1
       cld
       mov     ah,1Fh
       mov     cx,sizeof offset1

disp0: lodsb
       stosw
       loop    disp0
endm
;----------------------------------------------------------------------------------

        ORG     1FEh

;validation marker

        dw      0AA55h

;----------------------------------------------------------------------------------

        END     boot0









dedndave

\masm32\help\asmintro.chm
that file has a section "Working with Macros"
it should help you get started
also, look in the \masm32\macros folder for a few examples of macros

zak100

Thanks for your guidance. I just defined the macro at the top and its working now.

Zulfi.

zak100

Hi,
I have modified the above code. Now I am trying to print a string at different locations using a single macro at boot time. Can somebody plz help me with this.

Zulfi.

;----------------------------------------------------------------------------------
.MODEL  TINY


address equ 0B800h
address1 equ 0B839h
label1   equ "xlat0"
label2   equ "xlat1"

print_mesg macro offset1,test1, labelN
mov     ax,7C0h
       mov     ds,ax
       push    ax
       mov     ax,labelN
       push    ax
       retf

;at this point, the registers are as follows:

;DI = 0000
;CS = DS = 07C0
;IP = xlat0 offset
;SS:SP = 0000:7C00

;display the message at B800:0000

labelN: mov     ax,test1      ;notice that di is already 0
       mov     es,ax
       mov     si, offset1
       cld
       mov     ah,1Fh
       mov     cx,sizeof msg
endm


.CODE
ORG     0

;code branch

boot0:  jmp short boot1
   

;----------------------------------------------------------------------------------

       

;----------------------------------------------------------------------------------

        ORG     3

;OEM identifier

boot03  db      'BootDisk'     ;always 8 characters
.STACK 2048; removes the stack warning

;----------------------------------------------------------------------------------

        ORG     0Bh


boot0B  dw      200h           ;bytes per sector
boot0D  db      1              ;sectors per cluster
boot0E  dw      1              ;reserved sectors (the boot sector is reserved)
boot10  db      2              ;number of copies of the FAT
boot11  dw      0E0h           ;root directory entries (224 for 1.4 mb)
boot13  dw      0B40h          ;total disk sectors
boot15  db      0F0h           ;media descriptor byte (F0 for 1.4 mb)
boot16  dw      9              ;sectors per FAT
boot18  dw      12h            ;sectors per cylinder
boot1A  dw      2              ;number of heads
boot1C  dw      0              ;hidden sectors

;xCursor db 0
;yCursor db 0
;----------------------------------------------------------------------------------

boot1: cli                     ;disable maskable interrupts
       xor     di,di
       mov     ss,di
       mov     sp,7C00h        ;SS:SP = 0000:7C00


       
       sti

       
;----------------------------------call procedures
       ;mov bx,0B800h
       ;mov val, bx
       
       print_mesg   offset msg, address, label1
       disp0: lodsb
       stosw
       loop    disp0

       print_mesg   offset msg, address1, label2
       disp1: lodsb
       stosw
       loop    disp1

       ;mov bx,0B800h
       ;mov bx,val
       ;print_mesg msg, val
boot2: jmp     boot2
;-------------------------------------procedure definitions


msg db "We be bootin2'!"
         ORG 1FEH


        dw      0AA55h

;----------------------------------------------------------------------------------

        END     boot0






and the sytax errors are:
D:\masm prog>ml /c bpb_str2.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: bpb_str2.asm
bpb_str2.asm(92) : error A2008: syntax error : xlat0
print_mesg(17): Macro Called From
  bpb_str2.asm(92): Main Line Code
bpb_str2.asm(97) : error A2008: syntax error : xlat1
print_mesg(17): Macro Called From
  bpb_str2.asm(97): Main Line Code
bpb_str2.asm(92) : error A2084: constant value too large
print_mesg(4): Macro Called From
  bpb_str2.asm(92): Main Line Code
bpb_str2.asm(97) : error A2084: constant value too large
print_mesg(4): Macro Called From
  bpb_str2.asm(97): Main Line Code

D:\masm prog>pause
Press any key to continue . . .
Terminate batch job (Y/N)? y

zak100

This prob has been solved now.

Zulfi.