'What do %lo and %hi in compiler-generated asm mean, and why doesn't it work on MARS?

Can someone explain to me what this does

    %lo(foo)($1)
    %hi(foo)                 

specifically in this context:

    lui $1, %hi(foo)         
    sw $0, %lo(foo)($1)        

What does the ($1) do in %lo(foo)($1)?

Why does doing this not work on MARS?



Solution 1:[1]

That’s indirect addressing using the high and low 16 bits of foo as offsets in gas. $0 and $1 are registers. See here: http://sourceware.org/ml/binutils/2004-08/msg00262.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davislor