Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB print binary with leading zeros

I am trying to print a 32bits register within GDB using the command:

define gpioa_moder
    print /t *(uint32_t*)0x48000000
end

This is what I get:

101000000000000000010010100000

However, I'd like to keep the two leading zeros missing like this:

00101000000000000000010010100000

Thanks

like image 477
A. Faure Avatar asked Oct 07 '15 10:10

A. Faure


People also ask

What is a leading zero in binary?

A leading zero is any 0 digit that comes before the first nonzero digit in a number's binary form.

How do you find the leading zeros of a number?

Leading zeros in a binary number is equal to zeros preceding the highest order set bit of the number.

Which function is used to count the number of zeros at the beginning of the?

COUNTIF with leading zeros Here the COUNTIF function is set up to count values in B4:B8 that are equal to "01".


1 Answers

You may want to try the x (examine) command.

Then use it like this:

x /w 0x48000000
---> 0x48000000: 00101000000000000000010010100000

You can even use the other format parameters b, h and g to print different sizes.

like image 166
d6bels Avatar answered Oct 19 '22 18:10

d6bels