Converting an ieee number

Guest #2961469
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.

Reply

A question of your own? This thread is over 13 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.