flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > DO 1,0,1,1 ; Define One bit

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
hello macro addicts.

just to try, define a macro as:

DA, define atomic bit
)
or
DO, define one bit

Code:
macro da [args]
{
local .bit
local .byte
.bit=1
.byte=0
.loop:
.byte=[arg.a]

arghhhh!!
    


and then, when i write it:
Code:
da 0,0,1,1,1,1,0,1,0,0,1,1,1,0
    

it will be equivalent to:
Code:
db 10111100b,00011100b
;or 
dw 000111001011100b
    


first bit is the bit#0of the first byte.
8th bit is the last bit of the first byte.
may be usefull in bitmanipulation code

of course, a label cannot be defined for a bit. at least for byte.

if less than one byte (8_bits) are defined, one byte is defined. filled with 0.

i don't see how to do that with macro. but i'm sure it is possible.

thanks for help. Smile
Post 20 Jan 2010, 01:32
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Code:
macro defineBitMap [bit] {
common
local .bit,.byte
 .bit=1
 .byte=0
forward
 if bit <> 0
  .byte=.byte+.bit
 end if
 .bit=.bit+.bit
 if .bit>255
  db .byte
  .byte=0
  .bit=1
 end if
common
 if .bit>1
  db .byte
 end if
}    
Untested
Post 20 Jan 2010, 02:21
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
it's ok, cool, tanks a lot revolution.

da ,Define A(1) bit

or maybe,... bit?

bit 0,1,0,0,1,1,0,0

it works with this:
Code:
da 0,0,1,1,0,0,1,1,0,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1
dd 111000101010101111000011001100b                 
    


it generates two identical dwords.
Post 20 Jan 2010, 03:06
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
cool, Very Happy but imho should be considered endianess,it is to say, the WYSIWYG factor, that simplify readability, it is to say the packing method db/dw/dd
I have written different of these bit packers. one is here
http://board.flatassembler.net/topic.php?t=9905
but not really improved as my new ones, that i cannot find at the moment

using reverse instead of forward is more WYSIWYG but not dd/dw
packed
Code:
 
macro defineBitMap [bit] {
common
local .bit,.byte
 .bit=1
 .byte=0
reverse
 if bit <> 0
  .byte=.byte+.bit
 end if
 .bit=.bit+.bit
 if .bit>255
  db .byte
  .byte=0
  .bit=1
 end if
common
 if .bit>1
  db .byte
 end if
}
    
Post 21 Jan 2010, 06:17
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Pretty clever mask-handling revolution, but the name '.bit' is confusing seeing as the parameter is already called 'bit'... maybe '.mask' or '.pos' or '.index' or something would have been more clear at first sight (took me a while to figure it out). Smile

_________________
Previously known as The_Grey_Beast
Post 21 Jan 2010, 21:03
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
it works, and i am happy!

edfed!
Post 12 Mar 2010, 17:10
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-2020, Tomasz Grysztar.

Powered by rwasa.