Beruflich Dokumente
Kultur Dokumente
1
Ans:
AREA my_code, CODE , READONLY
EXPORT __main
ENTRY
__main
MOV R1 , #0x37AF
STOP
B STOP
Q.2
Ans:
AREA my_code, CODE , READONLY
EXPORT __main
ENTRY
__main
MOV R3 , #0x395A62
STOP
B STOP
Q.03
Ans:
First create the 2's complement bit pattern for -321 by flipping the bit pattern of 321 and
adding 1:
0011 0010 0001 becomes 1100 1101 1110 + 1 becomes 1100 1101 1111=CDF
EXPORT __main
ENTRY
__main
MOV R1 , #0xCDF
STOP
B STOP
EXPORT __main
ENTRY
__main
MOV R1 , #0xA642
MOV R3 , #0x8
STOP
MUL R2 , R1 , R3
B STOP
Q.05
Ans:
First create the 2's complement bit pattern for -458 by flipping the bit pattern of 458 and
adding 1:
0100 0101 1000 becomes 1011 1010 0111 + 1 becomes 0 1011 1010 1000 =BA8
EXPORT __main
ENTRY
__main
MOV R1 , #0xBA8
MOV R2 , #0x1CA
; Move 0x1CA to lowe r byte of R1
STOP
B STOP
Q.06
Ans:
AREA my_code, CODE , READONLY
EXPORT __main
ENTRY
__main
MOV R1 , #0xBA8
MOV R2 , #0x1CA
STOP
B STOP
You might have hastily said that the net result is no change. But if there are one-bits at the left
(high order) end of the pattern they will be lost.
MIPS also has a shift right logical instruction. It moves bits to the right by a number of
positions less than 32. The high-order bit gets zeros and the low-order bits are discarded.
If the bit pattern is regarded as an unsigned integer, or a positive two's comp. integer, then a
right shift of one bit position performs an integer divide by two. A right shift by N positions
performs an integer divide by 2N.
The "trick" of dividing an integer by shifting should not be used in place of the MIPS
arithmetic divide instruction (which will be covered in a few chapters). If you mean "divide"
that is what you should write. But the trick is often used in hardware, and sometimes pops
up in odd software uses, so you should know about it.
Q.08
Ans:
Q.09:
Ans:
First create the 2's complement bit pattern for 0xC5AF2 by flipping the bit pattern of
0xC5AF2 and adding 1:
1100 0101 1010 1111 0010 becomes 0011 1010 0101 0000 1101 + 1 becomes 0 1011 1010
1000 = 3A50E
EXPORT __main
ENTRY
__main
MOV R1 , #0x3A50E
MOV R2 , #0x8
STOP
B STOP
Q.10
Ans:
AREA my_code, CODE , READONLY
EXPORT __main
ENTRY
__main
MOV R1 , #0xA964
STOP
LSR R3 , R2 , #1
RRX R6, R9
B STOP
EXPORT __main
ENTRY
__main
MOV R1 , #0xD29D1C8B
STOP
LSRS R3 , R2 , #1
RRXS R6, R9
B STOP
Q.12
Ans: