1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MIPs Assemble ATAN2F HELP!!! $100 Reward

Discussion in 'Assembly Language Programming (ALP) Forum' started by asic_designer, Feb 15, 2015.

  1. asic_designer

    asic_designer New Member

    Joined:
    Apr 8, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi Everyone

    I have a question about the assemble code generated by this small patch of C code that I wrote. The code patch is shown below, basically what I am doing is reading floating point values in from a hardware updated register and performing the arctan2f function on those values.

    Code:
    #include "stdlib.h"
    #include "stdbool.h"
    #include "string.h"
    #include "math.h"
    #include <stdarg.h>
    #include "C:\Engineering_Projects\SourceCode\Software\SoC_Embedded_Lib\GLOBAL.H"
    
    #define   rs232_uart2_fp	  		 (*((volatile   float		*) 0x2C040002)) // UART WRITE FIFO FLOATING POINT
    
    #define   quik_silva_reg_fp               (*((volatile   float		*) 0x8C040000)) // System Register
    
    int main (void) 
    {  
    
    float temp;
    float ax, ay;
    
    quik_silva_reg = 0;
    
    init_soc();
    
    
    while  ( 1 ) {
    
    	ax = rs232_uart2_fp;
    	ay = rs232_uart2_fp;
    
    	quik_silva_reg = 0;
    	quik_silva_reg_fp = atan2f(ay, ax);
    
    }
    	
    	
      return 0;
      
    }
    OK so the code is not working and I have no idea why. I took a look at the disassemble list and I found something which looks very strange to me. The compiler places the two floating point variables x and y in floating point registers $f12, and $f13 and then calls the atan2f function as shown below.

    Code:
    while  ( 1 ) {
    
    	ax = rs232_uart2_fp;
         e68:	c62d0002 	lwc1	$f13,2(s1)
    Trig_Tests/atan2_test.cpp:28
    	ay = rs232_uart2_fp;
         e6c:	c62c0002 	lwc1	$f12,2(s1)
    \Trig_Tests/atan2_test.cpp:29
    	quik_silva_reg = 0;
         e70:	ae000000 	sw	zero,0(s0)
    Trig_Tests/atan2_test.cpp:30
    	quik_silva_reg_fp = atan2f(ay, ax);
         e74:	0c000406 	jal	1018 <atan2f>
         e78:	00000000 	nop
         e7c:	e6000000 	swc1	$f0,0(s0)
         e80:	0800039a 	j	e68 <main+0x24>
         e84:	00000000 	nop
    Now here is the weird part, when I look through the atan2f code I see ABSOLUTELY NO mention of floating point register $f13. Am I missing something here??? I do see a reference for a mfc1 for floating point register $f14 but no mention of register $f13 which is the register which holds the x operand for the atan2f(y,x) function. I attached the entire dissemble list for you to have a look for yourself.

    There is a $100 dollar reward for the person who explains why $f13 is not referenced in the code after the initial load instruction, shown above.

    Here are my command line and options.

    mips-sde-elf-gcc -Os -msingle-float -fsingle-precision-constant -g -mno-memcpy -mno-branch-likely -mno-check-zero-division -m
    abi=32 -mfp32 -mno-paired-single -mips32r2 -mno-fp-exceptions -mtune=r3k -T elf32btsmip.xc startup.o atan2_test.cpp -o uPC0_Spr6.elf -lc -lm

    Thanks in advance for your help! I really need it!!!!!:cryin:
     

    Attached Files:

Share This Page