Print the bits of a read byte in QuickBMS

Doubts, help and support about QuickBMS and other game research tools
GHFear
Posts: 290
Joined: Fri Mar 30, 2018 2:48 am

Print the bits of a read byte in QuickBMS

Post by GHFear »

How would I print the bits in a byte I read?

let's say I read 0x32 and want it to print "00110010".


Code: Select all

get TEST byte
print ?
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: Print the bits of a read byte in QuickBMS

Post by Shokoniraya »

add % before and after but i dont see any code to write as 01 mode

Code: Select all

get TEST byte
print "%TEST%"
Last edited by Shokoniraya on Wed May 01, 2019 4:49 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Print the bits of a read byte in QuickBMS

Post by aluigi »

There is no binary printing output in quickbms.
GHFear
Posts: 290
Joined: Fri Mar 30, 2018 2:48 am

Re: Print the bits of a read byte in QuickBMS

Post by GHFear »

aluigi wrote:There is no binary printing output in quickbms.

God damn bro. No problem. I Guess I can use c# for that instead.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Print the bits of a read byte in QuickBMS

Post by aluigi »

If you need to convert a number in binary you can use a tool like my calcc:
http://aluigi.altervista.org/mytoolz.htm#calcc

Example for number 0x12345678:

Code: Select all

0x12345678
 305419896              0000000012345678   0000000000002215053170
 0000000000000000000000000000000000010010001101000101011001111000
 305419896              .4Vx               3.0541989600000000000e+008
 00000000000000000102031011121320          18.52.86.120
 JDIVTY                 SNFZ4              Wed 05 Sep 1979 22:51:36
 0.00000000             1.508974781700064e-315
 01 Jan 1601 00:00:30

It's not like having the output directly in quickbms but if you need to visualize only few numbers it's good.
GHFear
Posts: 290
Joined: Fri Mar 30, 2018 2:48 am

Re: Print the bits of a read byte in QuickBMS

Post by GHFear »

aluigi wrote:If you need to convert a number in binary you can use a tool like my calcc:
http://aluigi.altervista.org/mytoolz.htm#calcc

Example for number 0x12345678:

Code: Select all

0x12345678
 305419896              0000000012345678   0000000000002215053170
 0000000000000000000000000000000000010010001101000101011001111000
 305419896              .4Vx               3.0541989600000000000e+008
 00000000000000000102031011121320          18.52.86.120
 JDIVTY                 SNFZ4              Wed 05 Sep 1979 22:51:36
 0.00000000             1.508974781700064e-315
 01 Jan 1601 00:00:30

It's not like having the output directly in quickbms but if you need to visualize only few numbers it's good.


I was actually going to make the bitvalues a string and then compare that to another string and then write different text to a temp File based on what bits were active. Maybe I can do that some other way?

So if the bits are XXX00001 it would write "N 4 0" and XXX00010 would be "N 3 0".
XXX00100 = N 2 0
XXX01000 = N 1 0
XXX10000 = N 0 0
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Print the bits of a read byte in QuickBMS

Post by aluigi »

A simple converter to bits is the following:

Code: Select all

math VAR = 0x12345678
callfunction TOBIT 1
print "%STR%"

startfunction TOBIT
    set STR string ""
    for TMP = VAR != 0
        xmath TMP2 "TMP & 1"
        string STR + TMP2
    next TMP u>> 1
    string STR r STR
endfunction

That thing of counting the left zeroes depends, honestly quickbms is not done for these things :)
GHFear
Posts: 290
Joined: Fri Mar 30, 2018 2:48 am

Re: Print the bits of a read byte in QuickBMS

Post by GHFear »

aluigi wrote:A simple converter to bits is the following:

Code: Select all

math VAR = 0x12345678
callfunction TOBIT 1
print "%STR%"

startfunction TOBIT
    set STR string ""
    for TMP = VAR != 0
        xmath TMP2 "TMP & 1"
        string STR + TMP2
    next TMP u>> 1
    string STR r STR
endfunction

That thing of counting the left zeroes depends, honestly quickbms is not done for these things :)


yeah :) this is good. The only problem now is I need all the 0000s in front of the first 1 too. Now it cuts off all the 0000s.
Could I force it to show all 8 bits?

Output looks like this:
110
1001000
110
1001000
110
1010
1010
110
1
11
100
1100
1100
10100
1000100
10100
1100
1
11


EDIT:
Nevermind, I fixed it like this:

Code: Select all

startfunction TOBIT

    set STR string ""
    math TEST = 8
    for TMP = NOTEBITS != 0
        math TEST - 1
        xmath TMP2 "TMP & 1"
        string STR + TMP2
    next TMP u>> 1
   
    for i = 0 < TEST
        string STR + 0
    next i
   
    string STR r STR
endfunction