Working with ieee format numbers in ARM
- by Jake Sellers
I'm trying to write an ARM program that will convert an ieee number to a TNS format number. TNS is a format used by some super computers, and is similar to ieee but different. I'm trying to use several masks to place the three different "part" of the ieee number in separate registers so I can move them around accordingly. Here is my unpack subroutine:
UnpackIEEE
LDR r1, SMASK ;load the sign bit mask into r1
LDR r2, EMASK ;load the exponent mask into r2
LDR r3, GMASK ;load the significand mask into r3
AND r4, r0, r1 ;apply sign mask to IEEE and save into r4
AND r5, r0, r2 ;apply exponent mask to IEEE and save into r5
AND r6, r0, r3 ;apply significand mask to IEEE and save into r6
MOV pc, r14 ;return
And here are the masks and number declarations so you can understand:
IEEE DCD 0x40300000 ;2.75 decimal or 01000000001100000000000000000000 binary
SMASK DCD 0x80000000 ;Sign bit mask
EMASK DCD 0x7F800000 ;Exponent mask
GMASK DCD 0x007FFFFF ;Significand mask
When I step through with the debugger, the results I get are not what I expect after working through it on paper. EDIT: What I mean, is that after the subroutine runs, registers 4, 5, and 6 all remain 0. I can't figure out why the masks are not working. I think I do not fully understand how the number is being stored in the register or using the masks wrong. Any help appreciated. If you need more info just ask.
EDIT: entry point: Very simple, just trying to get these subroutines working.
ENTRY
LDR r1, IEEE ;load IEEE num into r1
BL UnpackIEEE ;call unpack sub
SWI SWI_Exit ;finish