ELEC50010-IAC-CW/reference/edgecases/sravref.txt

43 lines
525 B
Plaintext
Raw Normal View History

2020-12-20 10:32:11 +00:00
==SRA Shift right arithmetic ==
2020-12-18 23:15:04 +00:00
2020-12-20 10:32:11 +00:00
sra -3 // Will it be able to handle shifts greater than the highest 1 value
2020-12-18 23:15:04 +00:00
2020-12-20 10:32:11 +00:00
ori $4,$0,16
sra $2,$4, 6
2020-12-18 23:15:04 +00:00
jr $0
ref = 0
2020-12-20 10:32:11 +00:00
34040010
2020-12-18 23:15:04 +00:00
00000008
2020-12-20 10:32:11 +00:00
00041183
2020-12-18 23:15:04 +00:00
2020-12-20 10:32:11 +00:00
sra- 4 // negative number - does it sign extened (negative)
2020-12-18 23:15:04 +00:00
lui $4, 0xFFFF
ori $4, $4, 0x00FF
2020-12-20 10:32:11 +00:00
sra $2, $4, 4
2020-12-18 23:15:04 +00:00
jr $0
ref = FFFFF00F (4294963215 / -4081)
3c04ffff
348400ff
00000008
2020-12-20 10:32:11 +00:00
00041103
2020-12-18 23:15:04 +00:00
2020-12-20 10:32:11 +00:00
sra - 5 // Does it sign extend 0s
2020-12-18 23:15:04 +00:00
lui $4, 0x0FFF
ori $4, $4, 0x00FF
2020-12-20 10:32:11 +00:00
sra $2, $4, 4
2020-12-18 23:15:04 +00:00
jr $0
ref = 00FFF00F (16773135)
3c040fff
348400ff
00000008
2020-12-20 10:32:11 +00:00
00041103