flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Display directive

Author
Thread Post new topic Reply to topic
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 17 Jul 2003, 18:09
What about improving the display directive letting you display a number in a certain base? Syntax could be something like:
Code:
display "Offset: ",<$,16>,13,10    

Outputs (for instance): "Offset: 0000132A" in addition to the two newline-characters (Cr,Lf/13,10)...
Post 17 Jul 2003, 18:09
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 17 Jul 2003, 20:20
Wink
Code:
macro __digit num
 {
   if num < 10
    display '0'+num
   else
    display 'A'+num-10
   end if
 }

macro __display arg1,arg2
 {
   if arg2 eq
    display arg1
   else
    local ..tmp
    ..tmp = arg1
    virtual at 0
     repeat 32
      if ..tmp > 0
       db ..tmp mod arg2
       ..tmp = ..tmp / arg2
      end if
     end repeat
     repeat $
      load ..tmp byte from $-%
      __digit ..tmp
     end repeat
     if $ = 0
      display '0'
     end if
    end virtual
   end if
 }

macro display [arg] { __display arg }


; And now the test:

org 132Ah
display "Offset: ",<$,16>,13,10    
Post 17 Jul 2003, 20:20
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 18 Jul 2003, 09:39
Smile Thanks!
Post 18 Jul 2003, 09:39
View user's profile Send private message Visit poster's website Reply with quote
AdamMarquis



Joined: 20 Jun 2003
Posts: 22
Location: La Sarre, Quebec, Canada
AdamMarquis 06 Aug 2003, 00:18
Great example, I'll try to improve my macro writing style.
There's really power in there =)
Post 06 Aug 2003, 00:18
View user's profile Send private message Reply with quote
VEG



Joined: 06 Feb 2013
Posts: 80
VEG 05 May 2017, 14:12
Tomasz Grysztar, do you have similar macro for the FASMG? Smile
Post 05 May 2017, 14:12
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 05 May 2017, 16:30
VEG wrote:
Tomasz Grysztar, do you have similar macro for the FASMG? Smile
Look here: https://board.flatassembler.net/topic.php?p=184902#184902
Post 05 May 2017, 16:30
View user's profile Send private message Visit poster's website 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.