Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 575 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load 32-bit constant to register in MIPS

#1
I was confused about this part while I study MIPS.

The textbook written by Professor [John L. Hennessy](

[To see links please register here]

) say if we get some *big* constant to load, we should

lui $s0, upper(big)
ori $s0, $s0, lower(big)


But why don't we just do

addi $s0, $zero, big

Since the registers are 32-bit, this is more strightforward, isn't it?
Reply

#2
Yes registers are 32-bits but how can you specify a 32-bit number in an instruction that is 32 bits? An instruction consists of opcode and data. So, you can't squeeze an opcode + 32-bit data in a single addi.
Reply

#3
You can use literal pool if you need to load a lot of constants. Then each constant load costs only 1 load instruction. More information [here](

[To see links please register here]

) and [here](

[To see links please register here]

)
Reply

#4
Alternatively, using *.data* and *.text*

.data
word32bits: .word 0xFFFFFFFF

.text
lw $t0, word32bits # $t0 now contains your 32 bit word.
Reply

#5
The immediate argument passed to `addi` is only 16 bits. To load a 32-bit immediate value that is outside the range of a 16-bit value you need to do it in two goes, as in the example from your text book.

(Anticipating a further question, the reason there is no *load immediate* or *add immediate* instruction which takes a 32-bit immediate value is because the MIPS ISA uses fixed size 32-bit instructions, so there are always < 32 bits available for any instruction arguments - this is very common in RISC architectures.)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through