Data Types Part 2 - Signed and Unsigned Values
Again I am learning Assembly language on a Khadas Vim3 dev board (Arm64) with Ubuntu 24.04. The size of the bus varies on different architectures so this matters. I will be copy pasting some from the great tutorial from Vega at Mariokartwii.com and trying to create a summary of what I have learned for completeness.
I want to focus on the General Purpose Registers (GPRs) for right now. There is different types of registers I will explore later. Having just finished the Memory and Data Types summary, I think it is best to address this now. The GPRs have two different "modes". Extended and Non-Extended. Extended is when an Instruction will utilize all 64-bits of the GPR. When a GPR is in extended use, it is written:
xD
D = Register's number. For example, GPR 5 in extended form is x5. GPR 22 in extended form is x22.
Non-Extended is when an Instruction will utilize only the lower (righthand-side) 32-bits of the GPR. When a GPR is in non-extended use, it is written as
wD
How do we know if a number is negative? You specify the values to be treated as Signed, AND the first bit of the value contained in the register is a 1.
Signed Range in Non-Extended GPRs: 0x80000000 thru 0xFFFFFFFF (Decimal -2,147,483,648 thru -1) 0x00000000 = zero 0x00000001 thru 0x7FFFFFFF (Decimal 1 thru 2,147,483,647)
Ok you need to specify the value to be treated as Signed number (which can make negative numbers) and then the following is true. Take the first hex digit and convert it to binary (8 = 1000). Let's assume we have declared a signed number. Now because the MSB (Most significant Bit) in binary is a 1, Hex to Binary shows it starts with a one, and Hex to Decimal shows its value (as signed) as -2147483648. Lets do -1 next.
0xFFFFFFFF. The first Hex digit is F (1111 binary). Totally Negative 1. Hey but wait. Why does it say 4294967295 as the decimal value on the line above. That is for unsigned numbers.
Unsigned Range in Non-Extended GPRs: 0x00000000 = zero 0x00000001 thru 0xFFFFFFFF (Decimal 1 thru 4,294,967,295)
For an extended register, since it is 64-bits in size instead of 32-bits, the Signed and Unsigned range is a bit different but follows the same principle.
Signed Range in Extended GPRs: 0x8000000000000000 thru 0xFFFFFFFFFFFFFFFF (Decimal -9,223,372,036,854,775,808 thru -1) 0x0000000000000000 = zero 0x0000000000000001 thru 0x7FFFFFFFFFFFFFFF (Decimal 1 thru 9,223,372,036,854,775,807) Unsigned Range in Extended GPRs: 0x0000000000000000 = zero 0x0000000000000001 thru 0xFFFFFFFFFFFFFFFF (Decimal 1 thru 18,446,744,073,709,551,615)
This page is unfinished. I am tired. Cheers :)
Check out some other Bands on Bandcamp.com. Crazy Fingers (Vancouver 1991), Altogether Steve and the Mercenaries, and Hammy Ham Hands.
Proudly powered by an IDE, a Text Editor, and some Internet Searches.
2024 dispelled.ca end of file.