macros in TASM 
Author Message
 macros in TASM

Hello,

    In Randal Hydes book, Art of Asssembly, he presents the program  (that I
have changed some.)  It will assemble OK with MASM, but I'm having trouble
with TASM.
    There are basically two problems.  First, to use the UCR standard
library I need to somehow globally specify that I want 32 bit segment.  I am
unsure how to do this.  Second,  TASM seems to work best on one pass.  I use
the /m switch, but the problem is not solved.  The Forlp and Next macros
refer to each other.  The Forlp macro generates a label that is not defined
until the Next macro is used.  TASM chokes on this.  Here is the code (when
I assemble for TASM, I remove the option:use32):

; Project #1 for Chapter Five
; This program will fill the screen with a specified set of values
; when you run it.  Currently, this program is incomplete.  Please
; read the comments carefully to determine where to insert your code
; into this program.

  .386
        option      segment:use16

  .xlist
        include     stdlib.a
  includelib stdlib.lib
  .list

ForLp macro   LCV, start, stop    ;LCV="Loop Ctrl Var"

    local ForLoop

        ifndef  $$For&LCV
    $$For&LCV  =   0
  else
    $$For&LCV  =   $$For&LCV + 1
  endif

;; Emit the instructions to initialize the loop control variable.

  mov ax, Start
  mov LCV, ax

;; Output Loop Label:

    ForLoop     catstr  <$$For&LCV>, %$$For&LCV
&ForLoop:

;; Output test to see if the loop is done:

  mov ax, LCV
  cmp ax, Stop
    $$temp1 catstr <$$Next&LCV>, %$$For&LCV
        jg  $$temp1
endm

; Here is the NEXT macro:

Next macro   LCV

    local ForDone

     inc LCV
    $$temp2 catstr <$$For&LCV>, %$$For&LCV
        jmp $$temp2
    ForDone     catstr  <$$Next&LCV>, %$$For&LCV
&ForDone:

endm

dseg segment para public 'data' use16

I   dw ?
J   dw ?

dseg ends

cseg segment para public 'code' use16
  assume cs:cseg, ds:dseg

PutScreen proc
      push es
      mov bx, 0b800h ;address of video display
      mov es, bx

        mov cx, ax ;save the data
        sub eax,eax  ;make sure eax is all clear
        mov al, 25 ;25 is length of row
        mul J
        add ax, I
        mov es:[eax*2],cx

      pop es
      ret
PutScreen endp

Main proc
  mov ax, dseg
  mov ds, ax
  mov es, ax
  meminit

  forlp j,0,79
  forlp i,0,24

        mov ax, 500h+"."    ;Colored periods
  call putscreen

  next i
  next j

  getc   ;Pause by reading the keyboard.

  forlp j,0,79
  forlp i,0,24

        mov ax, 1000h+" "   ;Blue spaces.
  call Putscreen

  next i
  next j

Quit:
  ExitPgm   ;DOS macro to quit program.
Main endp

cseg ends

sseg segment para stack 'stack' use16
stk  byte 1024 dup ("stack   ")
sseg ends

zzzzzzseg segment para public 'zzzzzz' use16
LastBytes byte 16 dup (?)
zzzzzzseg ends
end Main



Fri, 06 Jul 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Pentium Pro CMOVcc macros for TASM

2. MACROS in TASM

3. Pentium Pro CMOVcc macros for TASM

4. MMX macros for TASM?

5. MACROS in TASM

6. TASM and MMX macros

7. TASM Trojan Macro Library

8. Macro's in TASM

9. TASM/MASM macros

10. Need MMX-Macro-File for TASM

11. Bug in TASM macro expansion

12. A macro involving two sub-macros - where the 2nd macro needs results from the first

 

 
Powered by phpBB® Forum Software