Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

assembly - How to load memory address without using pseudo-instructions?

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

For didactic reasons I'm limiting myself to not using pseudo-instructions.

While trying to get the address of some data into a register, I ran into a problem because I cannot use la.

I tried using lui in combination with ori, the same as if I was to load a number directly, to no avail:

  .data
arr:
  .byte 0xa1
  .byte 0xb2
  .byte 0xc3
  .byte 0xd4
  .byte 0xe5
  .byte 0xf6
  .byte 0x7a
  .byte 0x8b
  .byte 0x9c
  .byte 0xad

.text

  lui $s0, mem # <--- mars just gives me errors here :(
  ori $s0, mem # ?? ... 

Is this doable using specifically MARS, without pseudo-instructions? How?

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To answer the modified question "is this doable using specifically MARS, without pseudo-instructions?": From a quick scan of the MARS documentation, it appears not. MARS appears to be intentionally restricted for pedagogical purposes.

If you want to try this on a full MIPS simulator that will simulate the Linux OS running on MIPS and run code built with the gnu toolchain, take a look at the OVP Simulator. This is free and runs on Linux and Windows, but it's probably a lot more than you need.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...