EmbDev.net

Forum: µC & Digital Electronics Converting an ieee number


von Jake (Guest)


Rate this post
useful
not useful
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:
1
UnpackIEEE
2
    LDR r1, SMASK   ;load the sign bit mask into r1 
3
    LDR r2, EMASK   ;load the exponent mask into r2
4
    LDR r3, GMASK   ;load the significand mask into r3
5
    AND r4, r0, r1  ;apply sign mask to IEEE and save into r4
6
    AND r5, r0, r2  ;apply exponent mask to IEEE and save into r5
7
    AND r6, r0, r3  ;apply significand mask to IEEE and save into r6
8
    MOV     pc, r14     ;return

And here are the masks and number declarations so you can understand:
1
IEEE        DCD 0x40300000  ;2.75 decimal or 01000000001100000000000000000000 binary
2
SMASK       DCD 0x80000000  ;Sign bit mask
3
EMASK       DCD 0x7F800000  ;Exponent mask
4
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.

: Moved by Admin
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.