flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > db ((val1 shl 4) and val2)

Author
Thread Post new topic Reply to topic
rambo



Joined: 28 Feb 2005
Posts: 22
Location: posen, poland
i`d like to have a macro, which performs operation:
Code:
(byteval1 << 4) & byteval2    

and then writes result as a byte.
so i wrote:
Code:
macro wval val1, val2 { db ((val1 shl 4) and val2) }    

but it doesn`t work (writes zeeero).
where is my fault?
Post 16 Aug 2005, 13:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7166
Location: Kraków, Poland
Seems to be converted correctly. With what values do you use it, and what result do you expect?
Post 16 Aug 2005, 13:30
View user's profile Send private message Visit poster's website Reply with quote
rambo



Joined: 28 Feb 2005
Posts: 22
Location: posen, poland
values are of course bytes from 0 to 15, and i expect first byte in byte`s hi nibble and second byte in lo nibble.

little example of using it by me:

Code:
something equ 0x09
..
wval something, 1    


and i`m using it inside others macros..
Post 16 Aug 2005, 13:35
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7166
Location: Kraków, Poland
Oh, so you mean |, not &. In fasm it should be:
Code:
db val1 shl 4 or val2    

(SHL has higher priority than OR/AND, but you can use parenthesis if you feel more comfortable this way).
Post 16 Aug 2005, 13:36
View user's profile Send private message Visit poster's website Reply with quote
rambo



Joined: 28 Feb 2005
Posts: 22
Location: posen, poland
oh, yeah : )
i`m ashamed : ))
thanks.
Post 16 Aug 2005, 13:40
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-2019, Tomasz Grysztar.

Powered by rwasa.