Improved x64 encoder
This commit is contained in:
parent
b776775f8f
commit
2c2b6e93db
15 changed files with 317 additions and 53 deletions
14
src/build/arch/x64/encodeNum.go
Normal file
14
src/build/arch/x64/encodeNum.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package x64
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
// encodeNum encodes an instruction with up to two registers and a number parameter.
|
||||
func encodeNum(code []byte, w byte, mod byte, reg byte, rm byte, number int, opCode8 byte, opCode32 byte) []byte {
|
||||
if SizeOf(int64(number)) == 1 {
|
||||
code = encode(code, w, mod, reg, rm, opCode8)
|
||||
return append(code, byte(number))
|
||||
}
|
||||
|
||||
code = encode(code, w, mod, reg, rm, opCode32)
|
||||
return binary.LittleEndian.AppendUint32(code, uint32(number))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue