As I read MIPS Architecture manual, there is only lbu
/ lhu
instruction. But we dont have sbu
/ shu
instruction.
As I found there was a signed extension for load, but it still can explain the actually store behavior.
How the CPU to distinguish the unsigned and signed data during store operation ? Is there any other flag or mechanism to indicate what data the address exactly store?
1
votes
1 Answers
4
votes
There is nothing special about storing unsigned versus signed data - they are just bits that the CPU writes to memory. The reason that you have separate signed and unsigned loads is that for loads which are less than the width of a register it is convenient to have automatic sign extension for signed values, where the high order part of the register is filled with 0
s for positive values and 1
s for negative values. The unsigned load however will just fill the high order part of the register with 0
s regardless, since there is of course no implicit sign.
sbu
andsb
? – phuclv