flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > Display directive

Author
Thread Post new topic Reply to topic
Tommy



Joined: 17 Jun 2003
Posts: 492
Location: Norway
Display directive
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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6314
Location: Kraków, Poland
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: 492
Location: Norway
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
Should go in the manual!
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: 51
Location: Minsk, Belarus
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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6314
Location: Kraków, Poland

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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.