1
votes

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
There is no sign/unsigned extension when storing since the output (byte) is smaller than the input (register). There is no extension going on, hence no need to distinguish how to do the extending.Raymond Chen
how do you imagine the difference between sbu and sb?phuclv
@ Lưu Vĩnh Phúc As before, i suspect that CPU should have a flag to indicate the different behavior due to i forget the complement. But now i assume that the signed and unsigned should be depend on upper layer by developer.chuck
this is or pretends to be a register based, load/store cpu. so it is only on the way into a register that you need to care about sign extension. register to ram (store) doesnt matter bits is bits, the bits in the register to go the bits in the ram. once properly sign extended in the register then you can do register/register operations like addition without needing further "to the register" sign extensions. when doing an 8 bit math operation for example the extension is required into the register, do the math as 32 bit then save the resulting 8 bits from the register clipping the rest.old_timer

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 0s for positive values and 1s for negative values. The unsigned load however will just fill the high order part of the register with 0s regardless, since there is of course no implicit sign.