flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Remove trailing b when representing binary

Author
Thread Post new topic Reply to topic
donn



Joined: 05 Mar 2010
Posts: 105
Just out of curiosity, is it possible to remove db and replace b with a space on a line in fasm1?

For example, instead of:

Code:
mov r8, [rax] db 10111000b,0b,0b,0b,0b ; 0b8h,0b,0,0,0 mov rax, 0b cmp r8, rax


This:

Code:
mov r8, [rax] LINE_START equ db ; Define start of line with db SPACE equ , ; Define space as comma 10111000 0 0 0 0 ; 0b8h,0b,0,0,0 mov rax, 0b restore LINE_START ; Restore definition restore SPACE ; Restore definition cmp r8, rax


Doesn't provide any functional difference, but would just format binary without the trailing b's and would remove the preceding db. Sometimes I forget to include the b and it becomes 10 (ten). Multiple lines beginning with the same db would also look simpler. I need to dabble more in these types of directives and macros. They really can enhance productivity.

Also, apologize if this was asked before, did not see a post yet when searching.
Post 11 Jul 2018, 05:43
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 105
Nevermind, this was addressed here:

https://board.flatassembler.net/topic.php?p=195977

Not sure if this applies yet, but will read through it.
Post 11 Jul 2018, 05:50
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 159
Location: Russian Federation, Sochi
Code:
macro bins vals& { irps val,vals \{ match a,val\#b \\{ ;if a>$FFFFFFFFFFFFFFFFFFFF ; display "fasm supports 129bit",13,10 ; display "for internaly calcs,",13,10 ; display "but not for data definition",13,10 ; ddq a ;.err ; but ddq a same as .err ,no ddq in fasm1 ;else if a>$FFFFFFFFFFFFFFFF ; even more if a >$FFFFFFFFFFFFFFFF compilation will crash in comparison moment display "definition dt present,",13,10 ; so these wil never be shown display "but not operate binary,",13,10 dt a ;.err ; but dt a same as .err, where a is not in float numeric format else if a>$FFFFFFFF dq a else if a>$FFFF dd a else if a>$FF dw a else db a end if \\} \} }
Code:
mov r8, [rax] bins \ 10000000_0000_0000_0000_00000000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1 cmp r8, rax

Is this helps?

for hexes:
Code:
macro $ vals& { irps val,vals \{ match a,$\#val \\{ ;if a>$FFFFFFFFFFFFFFFFFFFF ; display "fasm supports 129bit",13,10 ; display "for internaly calcs,",13,10 ; display "but not for data definition",13,10 ; ddq a ;.err ; but ddq a same as .err ,no ddq in fasm1 ;else if a>$FFFFFFFFFFFFFFFF display "definition dt present,",13,10 display "but not operate binary,",13,10 dt a ;.err ; but dt a same as .err else if a>$FFFFFFFF dq a else if a>$FFFF dd a else if a>$FF dw a else db a end if \\} \} }
Code:
$ 5a 4d


that one $ macro I liked myself (it looks organicaly in code and not crashing my eyes like bins does)
Post 11 Jul 2018, 07:09
View user's profile Send private message Send e-mail Reply with quote
donn



Joined: 05 Mar 2010
Posts: 105
Cool, that's perfect!

fasm 1.71.39 was showing
Code:
Error: reserved word used as symbol

on the _ but space worked fine. fasm 1.73.04 had no error with _. I like the $ and multiline support with \

Code:
mov r8, [rax] $ \ 10111111 01111111 \ 01000000 11100000 cmp r8, rax
Post 11 Jul 2018, 17:30
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 © 2004-2018, Tomasz Grysztar.

Powered by rwasa.