assembly - MIPS getting around using pseudo-instructions, What is going wrong? -


my question how i'm supposed around use of pseudo-instructions such la , li. many internet sources use pseudo-instructions anyway, confuses me extent. part of problem going wrong snippet. simulator spits out syntax error liu instruction , don't understand going wrong.

from understanding, liu command grabs significant bits, shifts left 16 bits, , puts in register ($a0). ori instruction takes label, , performs or on lower 16 bits adding register.

       .data m1:    .asciiz "some string"         .text main:           lui     $a0, m1        # loads m1 $a0 printed        ori     $a0, $a0, m1 

am not supposed use label m1 liu or ori? , if i'm not meant to, do instead?

i've read this , understand supposed happening, i'm still not sure why instructions has different effect, , why there andi $a0,$a0,0x0000ffff before liu , ori commands.

the mips simulator i'm using qtspim if relevant. i've gone looking answers question here , elsewhere, , i've failed understand them. help/corrections wonderful.

the code in referenced answer unfortunately incorrect. should be:

lui $a0, m1 >> 16 ori $a0, $a0, m1 & 0xffff 

the problem spim doesn't seem support these operators on labels.

anyway, logic have split 32 bit address 2 halves, , load them separately. right shifting 16 gives top 16 bits (the shift reversed lui @ runtime) while masking 0xffff gives low 16 bits.

gnu assembler has special support functions %hi , %lo high , low halves. them can write equivalent code follows:

lui     $a0, %hi(m1)       # loads m1 $a0 printed ori     $a0, $a0, %lo(m1) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -