Implemented bit shifts
This commit is contained in:
parent
a7d8d6ae20
commit
f0a1b97f2d
7 changed files with 101 additions and 2 deletions
17
src/build/arch/x64/Shift.go
Normal file
17
src/build/arch/x64/Shift.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package x64
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
)
|
||||
|
||||
// ShiftLeftNumber shifts the register value by `bitCount` bits to the left.
|
||||
func ShiftLeftNumber(code []byte, register cpu.Register, bitCount byte) []byte {
|
||||
code = encode(code, AddressDirect, 0b100, register, 8, 0xC1)
|
||||
return append(code, bitCount)
|
||||
}
|
||||
|
||||
// ShiftRightSignedNumber shifts the signed register value by `bitCount` bits to the right.
|
||||
func ShiftRightSignedNumber(code []byte, register cpu.Register, bitCount byte) []byte {
|
||||
code = encode(code, AddressDirect, 0b111, register, 8, 0xC1)
|
||||
return append(code, bitCount)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue