Simplified file structure

This commit is contained in:
Eduard Urbach 2024-08-07 19:39:10 +02:00
parent cacee7260a
commit a466281307
Signed by: eduard
GPG key ID: 49226B848C78F6C8
219 changed files with 453 additions and 457 deletions

View file

@ -1,40 +0,0 @@
package x64_test
import (
"testing"
"git.akyoto.dev/cli/q/src/build/arch/x64"
"git.akyoto.dev/go/assert"
)
func TestJump(t *testing.T) {
usagePatterns := []struct {
Offset int8
Code []byte
}{
{0, []byte{0xEB, 0x00}},
{1, []byte{0xEB, 0x01}},
{2, []byte{0xEB, 0x02}},
{3, []byte{0xEB, 0x03}},
{127, []byte{0xEB, 0x7F}},
{-1, []byte{0xEB, 0xFF}},
{-2, []byte{0xEB, 0xFE}},
{-3, []byte{0xEB, 0xFD}},
{-128, []byte{0xEB, 0x80}},
}
for _, pattern := range usagePatterns {
t.Logf("jmp %x", pattern.Offset)
code := x64.Jump8(nil, pattern.Offset)
assert.DeepEqual(t, code, pattern.Code)
}
}
func TestConditionalJump(t *testing.T) {
assert.DeepEqual(t, x64.Jump8IfEqual(nil, 1), []byte{0x74, 0x01})
assert.DeepEqual(t, x64.Jump8IfNotEqual(nil, 1), []byte{0x75, 0x01})
assert.DeepEqual(t, x64.Jump8IfLess(nil, 1), []byte{0x7C, 0x01})
assert.DeepEqual(t, x64.Jump8IfGreaterOrEqual(nil, 1), []byte{0x7D, 0x01})
assert.DeepEqual(t, x64.Jump8IfLessOrEqual(nil, 1), []byte{0x7E, 0x01})
assert.DeepEqual(t, x64.Jump8IfGreater(nil, 1), []byte{0x7F, 0x01})
}