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

90 lines
1 KiB
Plaintext
Raw Normal View History

2020-12-18 23:15:04 +00:00
==========DIVU - Divide unsigned==========
divu - 2 // is it seperating quotients & remainders correctly
ori $4, $0, 4
ori $5, $0, 3
divu $4, $5
mfhi $4
mflo $5
addu $2,$4,$5
jr $0
ref file = 2
34040004
34050003
0085001B
00002010
00002812
00851021
00000008
divu - 3 // check if unsigned despite MSB=1
2020-12-18 23:15:04 +00:00
lui $4, $0, 0xFFFF
ori $4, $4, 0xFFFC
lui $5, $0, 0xFFFF
ori $5, $5, 0xFFFE
2020-12-18 23:15:04 +00:00
divu $4, $5
mfhi $2 // look at remainder
2020-12-18 23:15:04 +00:00
jr $0
reg file = 4294967292 (0xFFFFFFFC)
2020-12-18 23:15:04 +00:00
3c04FFFF
3484FFFC
2020-12-18 23:15:04 +00:00
3c05ffff
34A5FFFE
2020-12-18 23:15:04 +00:00
0085001B
00001010
2020-12-18 23:15:04 +00:00
00000008
divu - 4 // +ve/(-ve value if signed but unsigned div here)
2020-12-18 23:15:04 +00:00
ori $4, $0, 0x4
lui $5, $0, 0xFFFF
ori $5, $5, 0xFFFC
2020-12-18 23:15:04 +00:00
divu $4, $5
mfhi $2
2020-12-18 23:15:04 +00:00
jr $0
reg file = 4 (0x4)
2020-12-18 23:15:04 +00:00
34040004
3c05FFFF
34A5FFFC
0085001B
00001010
2020-12-18 23:15:04 +00:00
00000008
divu - 5 // is it seperating quotients & remainders correctly
2020-12-18 23:15:04 +00:00
lui $4, $0, 0xFF00
ori $4, $4, 0xFF04
lui $5, $0, 0x00FF
ori $5, $5, 0x00FF
2020-12-18 23:15:04 +00:00
divu $4, $5
mfhi $4
mflo $5
addu $2,$4,$5
jr $0
ref file = 256 (remainder) + 4 (quotient)
2020-12-18 23:15:04 +00:00
3404FF00
3484FF04
340500FF
34A500FF
2020-12-18 23:15:04 +00:00
0085001A
00002010
00002812
00851021
00000008