First of all its given that the computer/processor doesn't care whether the given number in binary is signed or unsigned number, depending on instructions it receives in op-code it performs signed or unsigned arithmetic, and in the given case it will interpret the number as signed or unsigned.

subu rd,rs,rt

rs stores 11100 rt has 01000. Say it is supposed to do an unsigned arithmetic 11100 - 01000 the result would be obviously 10100 which is 20 in decimal notation, since we performed an unsigned arithmetic (subtraction). And this number is temporarily stored somewhere in the memory in a location address say "rd" to be used again.

Does this mean the number being stored at location rd can be used only for unsigned arithmetic in future.

If yes: please clarify the following. How does the computer actually know that it has to apply unsigned arithmetic whenever it used the data in rd the next time.where is the data related to this (that rd can only use unsigned arithmetic) stored.

So would this mean the computer really cares if the number being stored in address rd is signed or unsigned which will be a contradiction to first statement.

If no: why can it be used for a different type of arithmetic? wont doing this create any complications.

1 Answers

2
Paulpro On Best Solutions

Does this mean the number being stored at location rd can be used only for unsigned arithmetic in future.

No.

If no: why can it be used for a different type of arithmetic?

There is no information stored that determines whether the number is signed or unsigned, and it can be used for both signed and unsigned arithmetic in the future. The processor doesn't know anything about the history of the data in the register when it operates on it with a subsequent instruction, so the answer to why? is simply that there is nothing preventing it.

Won't doing this create any complications?

I suppose it could if you are working in assembly language and choose to switch between unsigned and signed arithmetic without a reason. Usually people work in compiled languages like C, in which case each number has a type and is either signed or unsigned, and at compile time the language will generate machine code that uses arithmetic corresponding to the type of the number.