flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > .:: Conditional macros v.1.01 ::.

Author
Thread Post new topic Reply to topic
vadana



Joined: 13 Jul 2003
Posts: 8
Location: Belarus
vadana 23 Dec 2003, 10:58
Hello all.
New version of Conditional macros
Use these macros for relief of the programming.
Send Your advices.
Smile


Description:
Download
Filename: conditional v1.01.zip
Filesize: 4.98 KB
Downloaded: 709 Time(s)

Post 23 Dec 2003, 10:58
View user's profile Send private message Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 10 Jan 2004, 07:12
Dear vadana:
Thanks your excellent macro file. But I can't understand the nested macro define. Can you give some description about it ?
Thank you.

Code:
macro string_data {}

macro STRING name,str
{
  macro string_data
   m_
          string_data
         name db str,0
       _m
}

m_ fix {
_m fix }    
Post 10 Jan 2004, 07:12
View user's profile Send private message MSN Messenger Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 10 Jan 2004, 15:10
In STRING macro it will define new version of string_data macro and insert old version of string_data at the beginning of it.
Code:
macro string_data {}

macro STRING name,str
{
   macro string_data ; defines string_data macro
   m_
      string_data    ; inserts old version here
      name db str,0
   _m
}

m_ fix {
_m fix }

STRING foo, 'foo'
;after that string_data is:
;foo db 'foo',0

STRING bar, 'bar'
;after that string_data is:
;foo db 'foo',0
;bar db 'bar',0
    
Post 10 Jan 2004, 15:10
View user's profile Send private message Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 10 Jan 2004, 16:41
Dear aaro:
Thanks your reply. But I found that the complier maybe present a serious bug about the nested macro define. Please see the belowing demo code:
Code:
macro string_data {}

macro STRING name,str
{
   macro string_data ; defines string_data macro
   m_
      string_data    ; inserts old version here
      name db str,0
   _m
}

m_ fix {
_m fix }

     org     100h                    ; code starts at offset 100h
        use16                           ; use 16-bit code
   STRING  foo,'foo'
 STRING  bar,'bar'
         
display_text = 9
        mov     ah,display_text
     mov     dx,hello
    int     21h

     int     20h

hello db 'Hello world!',24h

    

The complier result is wonderful. It shows on the belowing: (The file size is 22 bytes)
Code:
0B56:0100  B4 09 BA 09 01 CD 21 CD-20 48 65 6C 6C 6F 20 77   ......!. Hello w
0B56:0110  6F 72 6C 64 21 24 99 C3-2E C7 06 55 91 00 00 2E   orld!$.....U....
    


The complier result file don't define the foo and boo variable .
Why?


Description:
Download
Filename: COMDEMO.zip
Filesize: 616 Bytes
Downloaded: 660 Time(s)

Post 10 Jan 2004, 16:41
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 10 Jan 2004, 17:12
You have to use that "string_data" macro somewhere. Currently you only define the macros.
Post 10 Jan 2004, 17:12
View user's profile Send private message Visit poster's website Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 10 Jan 2004, 17:51
Hi,Privalov:
Thanks you helpping. I have added the "string_data" macro on the code.
But I have found two results:

1. The "string_data" macro on the front of "STRING", the complier result file doesn't present the foo and bar variable.
Code:
string_data
STRING    foo,'foo'
 STRING  bar,'bar'
     



2. The "string_data" macro after of "STRING", the result file is OK.
Code:
STRING       foo,'foo'
 STRING  bar,'bar'
 string_data    


I have maze the behaviour the nested macro define. Can you explain more information about it?
Thank you.
Post 10 Jan 2004, 17:51
View user's profile Send private message MSN Messenger Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 16 Jan 2004, 12:19
Hi,Vadana:
The .for macro present a bug and I have fixed it . Please see the belowing code:
Code:
macro .for var,cond,val1,oper,val2,_step,stepval
{
local ..continue,..break,..endfor,..beginfor
  __BEGINFOR equ ..beginfor
   __CONTINUE equ ..continue
   __BREAK equ ..break
 __ENDFOR equ ..endfor
       __VARIABLE equ var
  __OPERATOR equ oper
 __STEPVAL equ stepval
       mov     var,val1
    __CONTINUE:
     __BEGINFOR:
     cmp     var,val2
    if oper eq to
               jge     __ENDFOR
    else
                jle     __ENDFOR
    end if
}    

It should be the belowing code:
Code:
macro     .for    var,val1,oper,val2,_step,stepval
{
local     ..continue,..break,..endfor,..beginfor
      __BEGINFOR      equ     ..beginfor
  __CONTINUE      equ     ..continue
  __BREAK         equ     ..break
     __ENDFOR        equ     ..endfor
    __VARIABLE      equ     var
 __OPERATOR      equ     oper
        __STEPVAL       equ     stepval
     mov     var,val1
    __CONTINUE:
     __BEGINFOR:
     cmp     var,val2
    if oper eq add
              jge     __ENDFOR
    else
                jle     __ENDFOR
    end if
}    

Thank your macro file.


Description:
Download
Filename: COMDEMO.ASM
Filesize: 282 Bytes
Downloaded: 676 Time(s)

Description:
Download
Filename: if.inc
Filesize: 3.97 KB
Downloaded: 687 Time(s)

Post 16 Jan 2004, 12:19
View user's profile Send private message MSN Messenger Reply with quote
vadana



Joined: 13 Jul 2003
Posts: 8
Location: Belarus
vadana 24 Jan 2004, 10:26
Hello all.
You dont need call macros init_string or init_data.
You must init .data section, and strings or other init automaticly, becouse I create new macros .data:
macro .data
{
section '.data' data readable writeable
string_data
dword_data
word_data
char_data
struct_data
array_data
}

The .data section must be placed after .code section
For macros work:

.for eax equal 15 to 30 step 2
...
.endfor


Good luck!!!
.:: VDN ::.
Very Happy
Post 24 Jan 2004, 10:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.