Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
hidetatz committed May 3, 2022
1 parent 6c36139 commit f8956e6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions instruction_parse.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package main

func ParseIImm(inst uint64) uint64 {
imm := bits(inst, 31, 20)
mask := uint64(0b0)
if imm>>11 == 1 {
// sign-extend. inst[31] should be extended.
mask = ^uint64(0b1111_1111_1111)
}
imm |= mask
return imm
// sign-extend
return uint64(int64(int32(inst)) >> 20)
}

func ParseSImm(inst uint64) uint64 {
Expand Down

0 comments on commit f8956e6

Please sign in to comment.