Forum: µC & Digital Electronics Converting an ieee number

Author: Jake (Guest)
Posted on:

Rate this post
0 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:
    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.

: Moved by Admin


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.