How to load memory address without using pseudo-instructions?

后端 未结 3 1357
北海茫月
北海茫月 2020-12-19 13:11

I\'m trying to learn MIPS assembly language by myself using MARS simulator.

For didactic reasons I\'m limiting myself to not using pseudo-instructio

3条回答
  •  余生分开走
    2020-12-19 13:39

    You need to refer to a label in the data section in the lui and ori instructions. This works for gnu assembler (as):

        .data
    lab1: .byte 0xa1
    ...
    .text
        lui $s0, %hi(lab1)
        ori $s0, %lo(lab1)
        lw  $s2, 0($s1)
    ...
    

    The %hi and %lo directives tell the linker what is going on, so that it can put the address of the label "lab1" in the machine code.

提交回复
热议问题