Open TheThirdOne opened 5 years ago
Hi, I think putting the following lines in PseudoOps.txt may solve some GCC incompatibility issues.
lui t1,%hi(label) ;lui RG1,LH4 ;#Load Upper Address : Set t1 to upper 20-bit label's address addi t1,t2,%lo(label) ;addi RG1,RG2,LL5 ;#Load Lower Address : Set t1 to t2 + lower 12-bit label's address lw t1,%lo(label)(t2) ;lw RG1,LL4(RG7) ;#Load from Address flw f1,%lo(label)(t2) ;flw RG1,LL4(RG7) ;#Load from Address
@mvlamar, thats a pretty good suggestion. I got stuck thinking about how to make it work in any part of the assembler, but just supporting the most common cases should get it most of the way there.
In the program I just compiled and looked through and %hi
and %lo
only appear with with lui
and addi
. Do you have an example C program where when compiled to assembly where %lo
is used with lw
?
Hi Benjamin, This is a very simple example. Compile with -O0.
static int i0=0x12345678;
static float f0=1.5;
void main(void){
int i1=i0;
float f1=f0;
}
Thanks for the example. I'll try to add the the psuedo-instructions you suggested.
Aside from some simple pseudo instructions, the only issue I am aware of is the .comm
directive. It is very similar to the .extern
that is already implemented so it should be simple to add.
This isn't directly related, but I think gcc used .equ instead of .eqv
I don't think that GCC outputs assembly using .equ
, but it does seem like that would be a directive you find find in existing handwritten code.
It seems that GCC handles both in a similar way. I'm not sure if they are exactly the same though. I'll look into it and if they are exactly the same, add it into RARS.
I would like for GCC generated assembly to be able to be directly compiled (with libc features replaced). A fair number of small features need to be added to make that possible.
.section .rodata
should not have no effect.data
at least.rodata
section.align n
in.text
n >= 4
n < 4
can just be made inton = 4
.type
add sp,sp, -32
lui a5, %hi(.LC0)
addi a0,a5,%lo(.LC0)
jr ra