Let the compiler show you:
#define SOME_ADDRESS (*((volatile unsigned int *) 0x2000A000 ))
void fun ( void )
{
SOME_ADDRESS = 0xFFFF0000;
}
compile and disassemble
Disassembly of section .text:
00000000 <fun>:
0: 3c022000 lui $2,0x2000
4: 3442a000 ori $2,$2,0xa000
8: 3c03ffff lui $3,0xffff
c: ac430000 sw $3,0($2)
10: 03e00008 jr $31
14: 00000000 nop
As pointed out in the comments there is a missed optimization, but that is not the point of this answer. 1) Learn asm 2) learn to optimize the asm...down the road. Using the compiler you will get to see some of those optimizations. But not in this case.
#define SOME_ADDRESS (*((volatile unsigned int *) 0x20004000 ))
void fun ( void )
{
SOME_ADDRESS = 0xFFFF0000;
}
00000000 <fun>:
0: 3c022000 lui $2,0x2000
4: 3c03ffff lui $3,0xffff
8: ac434000 sw $3,16384($2)
c: 03e00008 jr $31
10: 00000000 nop
Yes it was built for mips32 to get this -march=mips1 and -march=mips32r6 produce the same code. as commented.