Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-10 09:45:43 -06:00
commit 8b72f6a52b
33 files changed
+7510

No files matched your search

+927
View File
@@ -0,0 +1,927 @@
# Tests of encoding instructions: each instruction's bytes, as GNU as writes them
# from the Intel syntax beside it, at every width and with every register a REX
# prefix or VEX reaches, then jumps and calls patched to their targets.
import std::io;
import binary::amd64;
import std::testing;
#! Whether code holds the bytes a reference assembler writes, given as hex,
#! emptying it for the next.
#! @param t The tester.
#! @param made The code.
#! @param expected The bytes, as hex.
def encodes(t: &mut tester, made: &mut assembly, expected: strview): void {
val digits := "0123456789abcdef";
var text := string::new(nothing {});
for &each in made.bytes.span {
text.append(digits.substr((each >> 4) as u64, 1));
text.append(digits.substr((each & 15) as u64, 1));
}
if text.span != expected {
println($"encoded as {text}, expected {expected}");
}
t.expects(text.span == expected);
made.bytes.clear();
}
# Each instruction's expected bytes were written by GNU as from the Intel syntax
# after it, so the encoder matches a reference assembler byte for byte.
@test def instructions_encode_as_a_reference_assembler_writes_them(t: &mut tester): void {
var a := assembly::new();
a.mov(reg::rax, reg::rcx); encodes(t, &mut a, "4889c8"); # mov rax, rcx
a.mov(reg::rax, reg::rbp); encodes(t, &mut a, "4889e8"); # mov rax, rbp
a.mov(reg::rax, reg::r8); encodes(t, &mut a, "4c89c0"); # mov rax, r8
a.mov(reg::rax, reg::r14); encodes(t, &mut a, "4c89f0"); # mov rax, r14
a.mov(reg::rbx, reg::rcx); encodes(t, &mut a, "4889cb"); # mov rbx, rcx
a.mov(reg::rbx, reg::rbp); encodes(t, &mut a, "4889eb"); # mov rbx, rbp
a.mov(reg::rbx, reg::r8); encodes(t, &mut a, "4c89c3"); # mov rbx, r8
a.mov(reg::rbx, reg::r14); encodes(t, &mut a, "4c89f3"); # mov rbx, r14
a.mov(reg::rsp, reg::rcx); encodes(t, &mut a, "4889cc"); # mov rsp, rcx
a.mov(reg::rsp, reg::rbp); encodes(t, &mut a, "4889ec"); # mov rsp, rbp
a.mov(reg::rsp, reg::r8); encodes(t, &mut a, "4c89c4"); # mov rsp, r8
a.mov(reg::rsp, reg::r14); encodes(t, &mut a, "4c89f4"); # mov rsp, r14
a.mov(reg::r12, reg::rcx); encodes(t, &mut a, "4989cc"); # mov r12, rcx
a.mov(reg::r12, reg::rbp); encodes(t, &mut a, "4989ec"); # mov r12, rbp
a.mov(reg::r12, reg::r8); encodes(t, &mut a, "4d89c4"); # mov r12, r8
a.mov(reg::r12, reg::r14); encodes(t, &mut a, "4d89f4"); # mov r12, r14
a.mov(reg::r13, reg::rcx); encodes(t, &mut a, "4989cd"); # mov r13, rcx
a.mov(reg::r13, reg::rbp); encodes(t, &mut a, "4989ed"); # mov r13, rbp
a.mov(reg::r13, reg::r8); encodes(t, &mut a, "4d89c5"); # mov r13, r8
a.mov(reg::r13, reg::r14); encodes(t, &mut a, "4d89f5"); # mov r13, r14
a.mov(reg::r15, reg::rcx); encodes(t, &mut a, "4989cf"); # mov r15, rcx
a.mov(reg::r15, reg::rbp); encodes(t, &mut a, "4989ef"); # mov r15, rbp
a.mov(reg::r15, reg::r8); encodes(t, &mut a, "4d89c7"); # mov r15, r8
a.mov(reg::r15, reg::r14); encodes(t, &mut a, "4d89f7"); # mov r15, r14
a.mov_imm(reg::rax, 0x0); encodes(t, &mut a, "b800000000"); # mov eax, 0
a.mov_imm(reg::r9, 0x0); encodes(t, &mut a, "41b900000000"); # mov r9d, 0
a.mov_imm(reg::rax, 0x1); encodes(t, &mut a, "b801000000"); # mov eax, 1
a.mov_imm(reg::r9, 0x1); encodes(t, &mut a, "41b901000000"); # mov r9d, 1
a.mov_imm(reg::rax, 0x7FFFFFFF); encodes(t, &mut a, "b8ffffff7f"); # mov eax, 2147483647
a.mov_imm(reg::r9, 0x7FFFFFFF); encodes(t, &mut a, "41b9ffffff7f"); # mov r9d, 2147483647
a.mov_imm(reg::rax, 0xFFFFFFFF); encodes(t, &mut a, "b8ffffffff"); # mov eax, 4294967295
a.mov_imm(reg::r9, 0xFFFFFFFF); encodes(t, &mut a, "41b9ffffffff"); # mov r9d, 4294967295
a.mov_imm(reg::rax, 0x100000000); encodes(t, &mut a, "48b80000000001000000"); # movabs rax, 4294967296
a.mov_imm(reg::r9, 0x100000000); encodes(t, &mut a, "49b90000000001000000"); # movabs r9, 4294967296
a.mov_imm(reg::rax, 0xFFFFFFFFFFFFFFFF); encodes(t, &mut a, "48c7c0ffffffff"); # mov rax, -1
a.mov_imm(reg::r9, 0xFFFFFFFFFFFFFFFF); encodes(t, &mut a, "49c7c1ffffffff"); # mov r9, -1
a.mov_imm(reg::rax, 0xFFFFFFFF80000000); encodes(t, &mut a, "48c7c000000080"); # mov rax, -2147483648
a.mov_imm(reg::r9, 0xFFFFFFFF80000000); encodes(t, &mut a, "49c7c100000080"); # mov r9, -2147483648
a.mov_imm(reg::rax, 0x123456789ABCDEF0); encodes(t, &mut a, "48b8f0debc9a78563412"); # movabs rax, 1311768467463790320
a.mov_imm(reg::r9, 0x123456789ABCDEF0); encodes(t, &mut a, "49b9f0debc9a78563412"); # movabs r9, 1311768467463790320
a.load(1, false, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "0fb603"); # movzx eax, byte ptr [rbx]
a.load(1, false, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "440fb61b"); # movzx r11d, byte ptr [rbx]
a.load(1, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "0fb613"); # movzx edx, byte ptr [rbx]
a.load(1, true, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "480fbe03"); # movsx rax, byte ptr [rbx]
a.load(1, true, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbe1b"); # movsx r11, byte ptr [rbx]
a.load(1, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "480fbe13"); # movsx rdx, byte ptr [rbx]
a.store(1, indexed(reg::rbx, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "8803"); # mov byte ptr [rbx], al
a.store(1, indexed(reg::rbx, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "408833"); # mov byte ptr [rbx], sil
a.store(1, indexed(reg::rbx, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "448813"); # mov byte ptr [rbx], r10b
a.load(2, false, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "0fb703"); # movzx eax, word ptr [rbx]
a.load(2, false, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "440fb71b"); # movzx r11d, word ptr [rbx]
a.load(2, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "0fb713"); # movzx edx, word ptr [rbx]
a.load(2, true, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "480fbf03"); # movsx rax, word ptr [rbx]
a.load(2, true, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbf1b"); # movsx r11, word ptr [rbx]
a.load(2, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "480fbf13"); # movsx rdx, word ptr [rbx]
a.store(2, indexed(reg::rbx, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "668903"); # mov word ptr [rbx], ax
a.store(2, indexed(reg::rbx, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "668933"); # mov word ptr [rbx], si
a.store(2, indexed(reg::rbx, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "66448913"); # mov word ptr [rbx], r10w
a.load(4, false, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "8b03"); # mov eax, dword ptr [rbx]
a.load(4, false, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "448b1b"); # mov r11d, dword ptr [rbx]
a.load(4, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "8b13"); # mov edx, dword ptr [rbx]
a.load(4, true, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "486303"); # movsxd rax, dword ptr [rbx]
a.load(4, true, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "4c631b"); # movsxd r11, dword ptr [rbx]
a.load(4, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "486313"); # movsxd rdx, dword ptr [rbx]
a.store(4, indexed(reg::rbx, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "8903"); # mov dword ptr [rbx], eax
a.store(4, indexed(reg::rbx, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "8933"); # mov dword ptr [rbx], esi
a.store(4, indexed(reg::rbx, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "448913"); # mov dword ptr [rbx], r10d
a.load(8, false, reg::rax, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "488b03"); # mov rax, qword ptr [rbx]
a.load(8, false, reg::r11, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "4c8b1b"); # mov r11, qword ptr [rbx]
a.load(8, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "488b13"); # mov rdx, qword ptr [rbx]
a.store(8, indexed(reg::rbx, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "488903"); # mov qword ptr [rbx], rax
a.store(8, indexed(reg::rbx, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "488933"); # mov qword ptr [rbx], rsi
a.store(8, indexed(reg::rbx, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "4c8913"); # mov qword ptr [rbx], r10
a.store_imm(indexed(reg::rbx, reg::none, 1, 0), -5); encodes(t, &mut a, "48c703fbffffff"); # mov qword ptr [rbx], -5
a.lea(reg::rdi, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "488d3b"); # lea rdi, [rbx]
a.alu_load(alu::add, reg::r9, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "4c030b"); # add r9, qword ptr [rbx]
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 0), 0); encodes(t, &mut a, "48833b00"); # cmp qword ptr [rbx], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 0), 1000); encodes(t, &mut a, "48813be8030000"); # cmp qword ptr [rbx], 1000
a.movss_load(1, indexed(reg::rbx, reg::none, 1, 0)); encodes(t, &mut a, "f30f100b"); # movss xmm1, dword ptr [rbx]
a.movss_store(indexed(reg::rbx, reg::none, 1, 0), 9); encodes(t, &mut a, "f3440f110b"); # movss dword ptr [rbx], xmm9
a.load(1, false, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "0fb64310"); # movzx eax, byte ptr [rbx+16]
a.load(1, false, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "440fb65b10"); # movzx r11d, byte ptr [rbx+16]
a.load(1, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "0fb65310"); # movzx edx, byte ptr [rbx+16]
a.load(1, true, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "480fbe4310"); # movsx rax, byte ptr [rbx+16]
a.load(1, true, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "4c0fbe5b10"); # movsx r11, byte ptr [rbx+16]
a.load(1, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "480fbe5310"); # movsx rdx, byte ptr [rbx+16]
a.store(1, indexed(reg::rbx, reg::none, 1, 16), reg::rax); encodes(t, &mut a, "884310"); # mov byte ptr [rbx+16], al
a.store(1, indexed(reg::rbx, reg::none, 1, 16), reg::rsi); encodes(t, &mut a, "40887310"); # mov byte ptr [rbx+16], sil
a.store(1, indexed(reg::rbx, reg::none, 1, 16), reg::r10); encodes(t, &mut a, "44885310"); # mov byte ptr [rbx+16], r10b
a.load(2, false, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "0fb74310"); # movzx eax, word ptr [rbx+16]
a.load(2, false, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "440fb75b10"); # movzx r11d, word ptr [rbx+16]
a.load(2, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "0fb75310"); # movzx edx, word ptr [rbx+16]
a.load(2, true, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "480fbf4310"); # movsx rax, word ptr [rbx+16]
a.load(2, true, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "4c0fbf5b10"); # movsx r11, word ptr [rbx+16]
a.load(2, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "480fbf5310"); # movsx rdx, word ptr [rbx+16]
a.store(2, indexed(reg::rbx, reg::none, 1, 16), reg::rax); encodes(t, &mut a, "66894310"); # mov word ptr [rbx+16], ax
a.store(2, indexed(reg::rbx, reg::none, 1, 16), reg::rsi); encodes(t, &mut a, "66897310"); # mov word ptr [rbx+16], si
a.store(2, indexed(reg::rbx, reg::none, 1, 16), reg::r10); encodes(t, &mut a, "6644895310"); # mov word ptr [rbx+16], r10w
a.load(4, false, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "8b4310"); # mov eax, dword ptr [rbx+16]
a.load(4, false, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "448b5b10"); # mov r11d, dword ptr [rbx+16]
a.load(4, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "8b5310"); # mov edx, dword ptr [rbx+16]
a.load(4, true, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "48634310"); # movsxd rax, dword ptr [rbx+16]
a.load(4, true, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "4c635b10"); # movsxd r11, dword ptr [rbx+16]
a.load(4, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "48635310"); # movsxd rdx, dword ptr [rbx+16]
a.store(4, indexed(reg::rbx, reg::none, 1, 16), reg::rax); encodes(t, &mut a, "894310"); # mov dword ptr [rbx+16], eax
a.store(4, indexed(reg::rbx, reg::none, 1, 16), reg::rsi); encodes(t, &mut a, "897310"); # mov dword ptr [rbx+16], esi
a.store(4, indexed(reg::rbx, reg::none, 1, 16), reg::r10); encodes(t, &mut a, "44895310"); # mov dword ptr [rbx+16], r10d
a.load(8, false, reg::rax, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "488b4310"); # mov rax, qword ptr [rbx+16]
a.load(8, false, reg::r11, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "4c8b5b10"); # mov r11, qword ptr [rbx+16]
a.load(8, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "488b5310"); # mov rdx, qword ptr [rbx+16]
a.store(8, indexed(reg::rbx, reg::none, 1, 16), reg::rax); encodes(t, &mut a, "48894310"); # mov qword ptr [rbx+16], rax
a.store(8, indexed(reg::rbx, reg::none, 1, 16), reg::rsi); encodes(t, &mut a, "48897310"); # mov qword ptr [rbx+16], rsi
a.store(8, indexed(reg::rbx, reg::none, 1, 16), reg::r10); encodes(t, &mut a, "4c895310"); # mov qword ptr [rbx+16], r10
a.store_imm(indexed(reg::rbx, reg::none, 1, 16), -5); encodes(t, &mut a, "48c74310fbffffff"); # mov qword ptr [rbx+16], -5
a.lea(reg::rdi, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "488d7b10"); # lea rdi, [rbx+16]
a.alu_load(alu::add, reg::r9, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "4c034b10"); # add r9, qword ptr [rbx+16]
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 16), 0); encodes(t, &mut a, "48837b1000"); # cmp qword ptr [rbx+16], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 16), 1000); encodes(t, &mut a, "48817b10e8030000"); # cmp qword ptr [rbx+16], 1000
a.movss_load(1, indexed(reg::rbx, reg::none, 1, 16)); encodes(t, &mut a, "f30f104b10"); # movss xmm1, dword ptr [rbx+16]
a.movss_store(indexed(reg::rbx, reg::none, 1, 16), 9); encodes(t, &mut a, "f3440f114b10"); # movss dword ptr [rbx+16], xmm9
a.load(1, false, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "0fb643f8"); # movzx eax, byte ptr [rbx-8]
a.load(1, false, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "440fb65bf8"); # movzx r11d, byte ptr [rbx-8]
a.load(1, false, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "0fb653f8"); # movzx edx, byte ptr [rbx-8]
a.load(1, true, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "480fbe43f8"); # movsx rax, byte ptr [rbx-8]
a.load(1, true, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "4c0fbe5bf8"); # movsx r11, byte ptr [rbx-8]
a.load(1, true, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "480fbe53f8"); # movsx rdx, byte ptr [rbx-8]
a.store(1, indexed(reg::rbx, reg::none, 1, -8), reg::rax); encodes(t, &mut a, "8843f8"); # mov byte ptr [rbx-8], al
a.store(1, indexed(reg::rbx, reg::none, 1, -8), reg::rsi); encodes(t, &mut a, "408873f8"); # mov byte ptr [rbx-8], sil
a.store(1, indexed(reg::rbx, reg::none, 1, -8), reg::r10); encodes(t, &mut a, "448853f8"); # mov byte ptr [rbx-8], r10b
a.load(2, false, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "0fb743f8"); # movzx eax, word ptr [rbx-8]
a.load(2, false, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "440fb75bf8"); # movzx r11d, word ptr [rbx-8]
a.load(2, false, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "0fb753f8"); # movzx edx, word ptr [rbx-8]
a.load(2, true, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "480fbf43f8"); # movsx rax, word ptr [rbx-8]
a.load(2, true, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "4c0fbf5bf8"); # movsx r11, word ptr [rbx-8]
a.load(2, true, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "480fbf53f8"); # movsx rdx, word ptr [rbx-8]
a.store(2, indexed(reg::rbx, reg::none, 1, -8), reg::rax); encodes(t, &mut a, "668943f8"); # mov word ptr [rbx-8], ax
a.store(2, indexed(reg::rbx, reg::none, 1, -8), reg::rsi); encodes(t, &mut a, "668973f8"); # mov word ptr [rbx-8], si
a.store(2, indexed(reg::rbx, reg::none, 1, -8), reg::r10); encodes(t, &mut a, "66448953f8"); # mov word ptr [rbx-8], r10w
a.load(4, false, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "8b43f8"); # mov eax, dword ptr [rbx-8]
a.load(4, false, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "448b5bf8"); # mov r11d, dword ptr [rbx-8]
a.load(4, false, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "8b53f8"); # mov edx, dword ptr [rbx-8]
a.load(4, true, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "486343f8"); # movsxd rax, dword ptr [rbx-8]
a.load(4, true, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "4c635bf8"); # movsxd r11, dword ptr [rbx-8]
a.load(4, true, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "486353f8"); # movsxd rdx, dword ptr [rbx-8]
a.store(4, indexed(reg::rbx, reg::none, 1, -8), reg::rax); encodes(t, &mut a, "8943f8"); # mov dword ptr [rbx-8], eax
a.store(4, indexed(reg::rbx, reg::none, 1, -8), reg::rsi); encodes(t, &mut a, "8973f8"); # mov dword ptr [rbx-8], esi
a.store(4, indexed(reg::rbx, reg::none, 1, -8), reg::r10); encodes(t, &mut a, "448953f8"); # mov dword ptr [rbx-8], r10d
a.load(8, false, reg::rax, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "488b43f8"); # mov rax, qword ptr [rbx-8]
a.load(8, false, reg::r11, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "4c8b5bf8"); # mov r11, qword ptr [rbx-8]
a.load(8, false, reg::rdx, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "488b53f8"); # mov rdx, qword ptr [rbx-8]
a.store(8, indexed(reg::rbx, reg::none, 1, -8), reg::rax); encodes(t, &mut a, "488943f8"); # mov qword ptr [rbx-8], rax
a.store(8, indexed(reg::rbx, reg::none, 1, -8), reg::rsi); encodes(t, &mut a, "488973f8"); # mov qword ptr [rbx-8], rsi
a.store(8, indexed(reg::rbx, reg::none, 1, -8), reg::r10); encodes(t, &mut a, "4c8953f8"); # mov qword ptr [rbx-8], r10
a.store_imm(indexed(reg::rbx, reg::none, 1, -8), -5); encodes(t, &mut a, "48c743f8fbffffff"); # mov qword ptr [rbx-8], -5
a.lea(reg::rdi, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "488d7bf8"); # lea rdi, [rbx-8]
a.alu_load(alu::add, reg::r9, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "4c034bf8"); # add r9, qword ptr [rbx-8]
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, -8), 0); encodes(t, &mut a, "48837bf800"); # cmp qword ptr [rbx-8], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, -8), 1000); encodes(t, &mut a, "48817bf8e8030000"); # cmp qword ptr [rbx-8], 1000
a.movss_load(1, indexed(reg::rbx, reg::none, 1, -8)); encodes(t, &mut a, "f30f104bf8"); # movss xmm1, dword ptr [rbx-8]
a.movss_store(indexed(reg::rbx, reg::none, 1, -8), 9); encodes(t, &mut a, "f3440f114bf8"); # movss dword ptr [rbx-8], xmm9
a.load(1, false, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "0fb68300100000"); # movzx eax, byte ptr [rbx+4096]
a.load(1, false, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "440fb69b00100000"); # movzx r11d, byte ptr [rbx+4096]
a.load(1, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "0fb69300100000"); # movzx edx, byte ptr [rbx+4096]
a.load(1, true, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "480fbe8300100000"); # movsx rax, byte ptr [rbx+4096]
a.load(1, true, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "4c0fbe9b00100000"); # movsx r11, byte ptr [rbx+4096]
a.load(1, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "480fbe9300100000"); # movsx rdx, byte ptr [rbx+4096]
a.store(1, indexed(reg::rbx, reg::none, 1, 4096), reg::rax); encodes(t, &mut a, "888300100000"); # mov byte ptr [rbx+4096], al
a.store(1, indexed(reg::rbx, reg::none, 1, 4096), reg::rsi); encodes(t, &mut a, "4088b300100000"); # mov byte ptr [rbx+4096], sil
a.store(1, indexed(reg::rbx, reg::none, 1, 4096), reg::r10); encodes(t, &mut a, "44889300100000"); # mov byte ptr [rbx+4096], r10b
a.load(2, false, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "0fb78300100000"); # movzx eax, word ptr [rbx+4096]
a.load(2, false, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "440fb79b00100000"); # movzx r11d, word ptr [rbx+4096]
a.load(2, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "0fb79300100000"); # movzx edx, word ptr [rbx+4096]
a.load(2, true, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "480fbf8300100000"); # movsx rax, word ptr [rbx+4096]
a.load(2, true, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "4c0fbf9b00100000"); # movsx r11, word ptr [rbx+4096]
a.load(2, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "480fbf9300100000"); # movsx rdx, word ptr [rbx+4096]
a.store(2, indexed(reg::rbx, reg::none, 1, 4096), reg::rax); encodes(t, &mut a, "66898300100000"); # mov word ptr [rbx+4096], ax
a.store(2, indexed(reg::rbx, reg::none, 1, 4096), reg::rsi); encodes(t, &mut a, "6689b300100000"); # mov word ptr [rbx+4096], si
a.store(2, indexed(reg::rbx, reg::none, 1, 4096), reg::r10); encodes(t, &mut a, "6644899300100000"); # mov word ptr [rbx+4096], r10w
a.load(4, false, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "8b8300100000"); # mov eax, dword ptr [rbx+4096]
a.load(4, false, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "448b9b00100000"); # mov r11d, dword ptr [rbx+4096]
a.load(4, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "8b9300100000"); # mov edx, dword ptr [rbx+4096]
a.load(4, true, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "48638300100000"); # movsxd rax, dword ptr [rbx+4096]
a.load(4, true, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "4c639b00100000"); # movsxd r11, dword ptr [rbx+4096]
a.load(4, true, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "48639300100000"); # movsxd rdx, dword ptr [rbx+4096]
a.store(4, indexed(reg::rbx, reg::none, 1, 4096), reg::rax); encodes(t, &mut a, "898300100000"); # mov dword ptr [rbx+4096], eax
a.store(4, indexed(reg::rbx, reg::none, 1, 4096), reg::rsi); encodes(t, &mut a, "89b300100000"); # mov dword ptr [rbx+4096], esi
a.store(4, indexed(reg::rbx, reg::none, 1, 4096), reg::r10); encodes(t, &mut a, "44899300100000"); # mov dword ptr [rbx+4096], r10d
a.load(8, false, reg::rax, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "488b8300100000"); # mov rax, qword ptr [rbx+4096]
a.load(8, false, reg::r11, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "4c8b9b00100000"); # mov r11, qword ptr [rbx+4096]
a.load(8, false, reg::rdx, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "488b9300100000"); # mov rdx, qword ptr [rbx+4096]
a.store(8, indexed(reg::rbx, reg::none, 1, 4096), reg::rax); encodes(t, &mut a, "48898300100000"); # mov qword ptr [rbx+4096], rax
a.store(8, indexed(reg::rbx, reg::none, 1, 4096), reg::rsi); encodes(t, &mut a, "4889b300100000"); # mov qword ptr [rbx+4096], rsi
a.store(8, indexed(reg::rbx, reg::none, 1, 4096), reg::r10); encodes(t, &mut a, "4c899300100000"); # mov qword ptr [rbx+4096], r10
a.store_imm(indexed(reg::rbx, reg::none, 1, 4096), -5); encodes(t, &mut a, "48c78300100000fbffffff"); # mov qword ptr [rbx+4096], -5
a.lea(reg::rdi, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "488dbb00100000"); # lea rdi, [rbx+4096]
a.alu_load(alu::add, reg::r9, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "4c038b00100000"); # add r9, qword ptr [rbx+4096]
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 4096), 0); encodes(t, &mut a, "4883bb0010000000"); # cmp qword ptr [rbx+4096], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbx, reg::none, 1, 4096), 1000); encodes(t, &mut a, "4881bb00100000e8030000"); # cmp qword ptr [rbx+4096], 1000
a.movss_load(1, indexed(reg::rbx, reg::none, 1, 4096)); encodes(t, &mut a, "f30f108b00100000"); # movss xmm1, dword ptr [rbx+4096]
a.movss_store(indexed(reg::rbx, reg::none, 1, 4096), 9); encodes(t, &mut a, "f3440f118b00100000"); # movss dword ptr [rbx+4096], xmm9
a.load(1, false, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "0fb60424"); # movzx eax, byte ptr [rsp]
a.load(1, false, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "440fb61c24"); # movzx r11d, byte ptr [rsp]
a.load(1, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "0fb61424"); # movzx edx, byte ptr [rsp]
a.load(1, true, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "480fbe0424"); # movsx rax, byte ptr [rsp]
a.load(1, true, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbe1c24"); # movsx r11, byte ptr [rsp]
a.load(1, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "480fbe1424"); # movsx rdx, byte ptr [rsp]
a.store(1, indexed(reg::rsp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "880424"); # mov byte ptr [rsp], al
a.store(1, indexed(reg::rsp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "40883424"); # mov byte ptr [rsp], sil
a.store(1, indexed(reg::rsp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "44881424"); # mov byte ptr [rsp], r10b
a.load(2, false, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "0fb70424"); # movzx eax, word ptr [rsp]
a.load(2, false, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "440fb71c24"); # movzx r11d, word ptr [rsp]
a.load(2, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "0fb71424"); # movzx edx, word ptr [rsp]
a.load(2, true, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "480fbf0424"); # movsx rax, word ptr [rsp]
a.load(2, true, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbf1c24"); # movsx r11, word ptr [rsp]
a.load(2, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "480fbf1424"); # movsx rdx, word ptr [rsp]
a.store(2, indexed(reg::rsp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "66890424"); # mov word ptr [rsp], ax
a.store(2, indexed(reg::rsp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "66893424"); # mov word ptr [rsp], si
a.store(2, indexed(reg::rsp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "6644891424"); # mov word ptr [rsp], r10w
a.load(4, false, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "8b0424"); # mov eax, dword ptr [rsp]
a.load(4, false, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "448b1c24"); # mov r11d, dword ptr [rsp]
a.load(4, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "8b1424"); # mov edx, dword ptr [rsp]
a.load(4, true, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "48630424"); # movsxd rax, dword ptr [rsp]
a.load(4, true, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "4c631c24"); # movsxd r11, dword ptr [rsp]
a.load(4, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "48631424"); # movsxd rdx, dword ptr [rsp]
a.store(4, indexed(reg::rsp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "890424"); # mov dword ptr [rsp], eax
a.store(4, indexed(reg::rsp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "893424"); # mov dword ptr [rsp], esi
a.store(4, indexed(reg::rsp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "44891424"); # mov dword ptr [rsp], r10d
a.load(8, false, reg::rax, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "488b0424"); # mov rax, qword ptr [rsp]
a.load(8, false, reg::r11, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "4c8b1c24"); # mov r11, qword ptr [rsp]
a.load(8, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "488b1424"); # mov rdx, qword ptr [rsp]
a.store(8, indexed(reg::rsp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "48890424"); # mov qword ptr [rsp], rax
a.store(8, indexed(reg::rsp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "48893424"); # mov qword ptr [rsp], rsi
a.store(8, indexed(reg::rsp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "4c891424"); # mov qword ptr [rsp], r10
a.store_imm(indexed(reg::rsp, reg::none, 1, 0), -5); encodes(t, &mut a, "48c70424fbffffff"); # mov qword ptr [rsp], -5
a.lea(reg::rdi, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "488d3c24"); # lea rdi, [rsp]
a.alu_load(alu::add, reg::r9, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "4c030c24"); # add r9, qword ptr [rsp]
a.alu_mem_imm(alu::cmp, indexed(reg::rsp, reg::none, 1, 0), 0); encodes(t, &mut a, "48833c2400"); # cmp qword ptr [rsp], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rsp, reg::none, 1, 0), 1000); encodes(t, &mut a, "48813c24e8030000"); # cmp qword ptr [rsp], 1000
a.movss_load(1, indexed(reg::rsp, reg::none, 1, 0)); encodes(t, &mut a, "f30f100c24"); # movss xmm1, dword ptr [rsp]
a.movss_store(indexed(reg::rsp, reg::none, 1, 0), 9); encodes(t, &mut a, "f3440f110c24"); # movss dword ptr [rsp], xmm9
a.load(1, false, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "0fb6442408"); # movzx eax, byte ptr [rsp+8]
a.load(1, false, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "440fb65c2408"); # movzx r11d, byte ptr [rsp+8]
a.load(1, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "0fb6542408"); # movzx edx, byte ptr [rsp+8]
a.load(1, true, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "480fbe442408"); # movsx rax, byte ptr [rsp+8]
a.load(1, true, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4c0fbe5c2408"); # movsx r11, byte ptr [rsp+8]
a.load(1, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "480fbe542408"); # movsx rdx, byte ptr [rsp+8]
a.store(1, indexed(reg::rsp, reg::none, 1, 8), reg::rax); encodes(t, &mut a, "88442408"); # mov byte ptr [rsp+8], al
a.store(1, indexed(reg::rsp, reg::none, 1, 8), reg::rsi); encodes(t, &mut a, "4088742408"); # mov byte ptr [rsp+8], sil
a.store(1, indexed(reg::rsp, reg::none, 1, 8), reg::r10); encodes(t, &mut a, "4488542408"); # mov byte ptr [rsp+8], r10b
a.load(2, false, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "0fb7442408"); # movzx eax, word ptr [rsp+8]
a.load(2, false, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "440fb75c2408"); # movzx r11d, word ptr [rsp+8]
a.load(2, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "0fb7542408"); # movzx edx, word ptr [rsp+8]
a.load(2, true, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "480fbf442408"); # movsx rax, word ptr [rsp+8]
a.load(2, true, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4c0fbf5c2408"); # movsx r11, word ptr [rsp+8]
a.load(2, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "480fbf542408"); # movsx rdx, word ptr [rsp+8]
a.store(2, indexed(reg::rsp, reg::none, 1, 8), reg::rax); encodes(t, &mut a, "6689442408"); # mov word ptr [rsp+8], ax
a.store(2, indexed(reg::rsp, reg::none, 1, 8), reg::rsi); encodes(t, &mut a, "6689742408"); # mov word ptr [rsp+8], si
a.store(2, indexed(reg::rsp, reg::none, 1, 8), reg::r10); encodes(t, &mut a, "664489542408"); # mov word ptr [rsp+8], r10w
a.load(4, false, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "8b442408"); # mov eax, dword ptr [rsp+8]
a.load(4, false, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "448b5c2408"); # mov r11d, dword ptr [rsp+8]
a.load(4, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "8b542408"); # mov edx, dword ptr [rsp+8]
a.load(4, true, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4863442408"); # movsxd rax, dword ptr [rsp+8]
a.load(4, true, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4c635c2408"); # movsxd r11, dword ptr [rsp+8]
a.load(4, true, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4863542408"); # movsxd rdx, dword ptr [rsp+8]
a.store(4, indexed(reg::rsp, reg::none, 1, 8), reg::rax); encodes(t, &mut a, "89442408"); # mov dword ptr [rsp+8], eax
a.store(4, indexed(reg::rsp, reg::none, 1, 8), reg::rsi); encodes(t, &mut a, "89742408"); # mov dword ptr [rsp+8], esi
a.store(4, indexed(reg::rsp, reg::none, 1, 8), reg::r10); encodes(t, &mut a, "4489542408"); # mov dword ptr [rsp+8], r10d
a.load(8, false, reg::rax, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "488b442408"); # mov rax, qword ptr [rsp+8]
a.load(8, false, reg::r11, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4c8b5c2408"); # mov r11, qword ptr [rsp+8]
a.load(8, false, reg::rdx, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "488b542408"); # mov rdx, qword ptr [rsp+8]
a.store(8, indexed(reg::rsp, reg::none, 1, 8), reg::rax); encodes(t, &mut a, "4889442408"); # mov qword ptr [rsp+8], rax
a.store(8, indexed(reg::rsp, reg::none, 1, 8), reg::rsi); encodes(t, &mut a, "4889742408"); # mov qword ptr [rsp+8], rsi
a.store(8, indexed(reg::rsp, reg::none, 1, 8), reg::r10); encodes(t, &mut a, "4c89542408"); # mov qword ptr [rsp+8], r10
a.store_imm(indexed(reg::rsp, reg::none, 1, 8), -5); encodes(t, &mut a, "48c7442408fbffffff"); # mov qword ptr [rsp+8], -5
a.lea(reg::rdi, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "488d7c2408"); # lea rdi, [rsp+8]
a.alu_load(alu::add, reg::r9, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "4c034c2408"); # add r9, qword ptr [rsp+8]
a.alu_mem_imm(alu::cmp, indexed(reg::rsp, reg::none, 1, 8), 0); encodes(t, &mut a, "48837c240800"); # cmp qword ptr [rsp+8], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rsp, reg::none, 1, 8), 1000); encodes(t, &mut a, "48817c2408e8030000"); # cmp qword ptr [rsp+8], 1000
a.movss_load(1, indexed(reg::rsp, reg::none, 1, 8)); encodes(t, &mut a, "f30f104c2408"); # movss xmm1, dword ptr [rsp+8]
a.movss_store(indexed(reg::rsp, reg::none, 1, 8), 9); encodes(t, &mut a, "f3440f114c2408"); # movss dword ptr [rsp+8], xmm9
a.load(1, false, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "0fb64500"); # movzx eax, byte ptr [rbp]
a.load(1, false, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "440fb65d00"); # movzx r11d, byte ptr [rbp]
a.load(1, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "0fb65500"); # movzx edx, byte ptr [rbp]
a.load(1, true, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "480fbe4500"); # movsx rax, byte ptr [rbp]
a.load(1, true, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbe5d00"); # movsx r11, byte ptr [rbp]
a.load(1, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "480fbe5500"); # movsx rdx, byte ptr [rbp]
a.store(1, indexed(reg::rbp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "884500"); # mov byte ptr [rbp], al
a.store(1, indexed(reg::rbp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "40887500"); # mov byte ptr [rbp], sil
a.store(1, indexed(reg::rbp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "44885500"); # mov byte ptr [rbp], r10b
a.load(2, false, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "0fb74500"); # movzx eax, word ptr [rbp]
a.load(2, false, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "440fb75d00"); # movzx r11d, word ptr [rbp]
a.load(2, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "0fb75500"); # movzx edx, word ptr [rbp]
a.load(2, true, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "480fbf4500"); # movsx rax, word ptr [rbp]
a.load(2, true, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "4c0fbf5d00"); # movsx r11, word ptr [rbp]
a.load(2, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "480fbf5500"); # movsx rdx, word ptr [rbp]
a.store(2, indexed(reg::rbp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "66894500"); # mov word ptr [rbp], ax
a.store(2, indexed(reg::rbp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "66897500"); # mov word ptr [rbp], si
a.store(2, indexed(reg::rbp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "6644895500"); # mov word ptr [rbp], r10w
a.load(4, false, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "8b4500"); # mov eax, dword ptr [rbp]
a.load(4, false, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "448b5d00"); # mov r11d, dword ptr [rbp]
a.load(4, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "8b5500"); # mov edx, dword ptr [rbp]
a.load(4, true, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "48634500"); # movsxd rax, dword ptr [rbp]
a.load(4, true, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "4c635d00"); # movsxd r11, dword ptr [rbp]
a.load(4, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "48635500"); # movsxd rdx, dword ptr [rbp]
a.store(4, indexed(reg::rbp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "894500"); # mov dword ptr [rbp], eax
a.store(4, indexed(reg::rbp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "897500"); # mov dword ptr [rbp], esi
a.store(4, indexed(reg::rbp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "44895500"); # mov dword ptr [rbp], r10d
a.load(8, false, reg::rax, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "488b4500"); # mov rax, qword ptr [rbp]
a.load(8, false, reg::r11, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "4c8b5d00"); # mov r11, qword ptr [rbp]
a.load(8, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "488b5500"); # mov rdx, qword ptr [rbp]
a.store(8, indexed(reg::rbp, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "48894500"); # mov qword ptr [rbp], rax
a.store(8, indexed(reg::rbp, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "48897500"); # mov qword ptr [rbp], rsi
a.store(8, indexed(reg::rbp, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "4c895500"); # mov qword ptr [rbp], r10
a.store_imm(indexed(reg::rbp, reg::none, 1, 0), -5); encodes(t, &mut a, "48c74500fbffffff"); # mov qword ptr [rbp], -5
a.lea(reg::rdi, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "488d7d00"); # lea rdi, [rbp]
a.alu_load(alu::add, reg::r9, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "4c034d00"); # add r9, qword ptr [rbp]
a.alu_mem_imm(alu::cmp, indexed(reg::rbp, reg::none, 1, 0), 0); encodes(t, &mut a, "48837d0000"); # cmp qword ptr [rbp], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbp, reg::none, 1, 0), 1000); encodes(t, &mut a, "48817d00e8030000"); # cmp qword ptr [rbp], 1000
a.movss_load(1, indexed(reg::rbp, reg::none, 1, 0)); encodes(t, &mut a, "f30f104d00"); # movss xmm1, dword ptr [rbp]
a.movss_store(indexed(reg::rbp, reg::none, 1, 0), 9); encodes(t, &mut a, "f3440f114d00"); # movss dword ptr [rbp], xmm9
a.load(1, false, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "0fb64518"); # movzx eax, byte ptr [rbp+24]
a.load(1, false, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "440fb65d18"); # movzx r11d, byte ptr [rbp+24]
a.load(1, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "0fb65518"); # movzx edx, byte ptr [rbp+24]
a.load(1, true, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "480fbe4518"); # movsx rax, byte ptr [rbp+24]
a.load(1, true, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "4c0fbe5d18"); # movsx r11, byte ptr [rbp+24]
a.load(1, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "480fbe5518"); # movsx rdx, byte ptr [rbp+24]
a.store(1, indexed(reg::rbp, reg::none, 1, 24), reg::rax); encodes(t, &mut a, "884518"); # mov byte ptr [rbp+24], al
a.store(1, indexed(reg::rbp, reg::none, 1, 24), reg::rsi); encodes(t, &mut a, "40887518"); # mov byte ptr [rbp+24], sil
a.store(1, indexed(reg::rbp, reg::none, 1, 24), reg::r10); encodes(t, &mut a, "44885518"); # mov byte ptr [rbp+24], r10b
a.load(2, false, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "0fb74518"); # movzx eax, word ptr [rbp+24]
a.load(2, false, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "440fb75d18"); # movzx r11d, word ptr [rbp+24]
a.load(2, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "0fb75518"); # movzx edx, word ptr [rbp+24]
a.load(2, true, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "480fbf4518"); # movsx rax, word ptr [rbp+24]
a.load(2, true, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "4c0fbf5d18"); # movsx r11, word ptr [rbp+24]
a.load(2, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "480fbf5518"); # movsx rdx, word ptr [rbp+24]
a.store(2, indexed(reg::rbp, reg::none, 1, 24), reg::rax); encodes(t, &mut a, "66894518"); # mov word ptr [rbp+24], ax
a.store(2, indexed(reg::rbp, reg::none, 1, 24), reg::rsi); encodes(t, &mut a, "66897518"); # mov word ptr [rbp+24], si
a.store(2, indexed(reg::rbp, reg::none, 1, 24), reg::r10); encodes(t, &mut a, "6644895518"); # mov word ptr [rbp+24], r10w
a.load(4, false, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "8b4518"); # mov eax, dword ptr [rbp+24]
a.load(4, false, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "448b5d18"); # mov r11d, dword ptr [rbp+24]
a.load(4, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "8b5518"); # mov edx, dword ptr [rbp+24]
a.load(4, true, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "48634518"); # movsxd rax, dword ptr [rbp+24]
a.load(4, true, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "4c635d18"); # movsxd r11, dword ptr [rbp+24]
a.load(4, true, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "48635518"); # movsxd rdx, dword ptr [rbp+24]
a.store(4, indexed(reg::rbp, reg::none, 1, 24), reg::rax); encodes(t, &mut a, "894518"); # mov dword ptr [rbp+24], eax
a.store(4, indexed(reg::rbp, reg::none, 1, 24), reg::rsi); encodes(t, &mut a, "897518"); # mov dword ptr [rbp+24], esi
a.store(4, indexed(reg::rbp, reg::none, 1, 24), reg::r10); encodes(t, &mut a, "44895518"); # mov dword ptr [rbp+24], r10d
a.load(8, false, reg::rax, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "488b4518"); # mov rax, qword ptr [rbp+24]
a.load(8, false, reg::r11, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "4c8b5d18"); # mov r11, qword ptr [rbp+24]
a.load(8, false, reg::rdx, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "488b5518"); # mov rdx, qword ptr [rbp+24]
a.store(8, indexed(reg::rbp, reg::none, 1, 24), reg::rax); encodes(t, &mut a, "48894518"); # mov qword ptr [rbp+24], rax
a.store(8, indexed(reg::rbp, reg::none, 1, 24), reg::rsi); encodes(t, &mut a, "48897518"); # mov qword ptr [rbp+24], rsi
a.store(8, indexed(reg::rbp, reg::none, 1, 24), reg::r10); encodes(t, &mut a, "4c895518"); # mov qword ptr [rbp+24], r10
a.store_imm(indexed(reg::rbp, reg::none, 1, 24), -5); encodes(t, &mut a, "48c74518fbffffff"); # mov qword ptr [rbp+24], -5
a.lea(reg::rdi, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "488d7d18"); # lea rdi, [rbp+24]
a.alu_load(alu::add, reg::r9, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "4c034d18"); # add r9, qword ptr [rbp+24]
a.alu_mem_imm(alu::cmp, indexed(reg::rbp, reg::none, 1, 24), 0); encodes(t, &mut a, "48837d1800"); # cmp qword ptr [rbp+24], 0
a.alu_mem_imm(alu::cmp, indexed(reg::rbp, reg::none, 1, 24), 1000); encodes(t, &mut a, "48817d18e8030000"); # cmp qword ptr [rbp+24], 1000
a.movss_load(1, indexed(reg::rbp, reg::none, 1, 24)); encodes(t, &mut a, "f30f104d18"); # movss xmm1, dword ptr [rbp+24]
a.movss_store(indexed(reg::rbp, reg::none, 1, 24), 9); encodes(t, &mut a, "f3440f114d18"); # movss dword ptr [rbp+24], xmm9
a.load(1, false, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "410fb60424"); # movzx eax, byte ptr [r12]
a.load(1, false, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "450fb61c24"); # movzx r11d, byte ptr [r12]
a.load(1, false, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "410fb61424"); # movzx edx, byte ptr [r12]
a.load(1, true, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "490fbe0424"); # movsx rax, byte ptr [r12]
a.load(1, true, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "4d0fbe1c24"); # movsx r11, byte ptr [r12]
a.load(1, true, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "490fbe1424"); # movsx rdx, byte ptr [r12]
a.store(1, indexed(reg::r12, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "41880424"); # mov byte ptr [r12], al
a.store(1, indexed(reg::r12, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "41883424"); # mov byte ptr [r12], sil
a.store(1, indexed(reg::r12, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "45881424"); # mov byte ptr [r12], r10b
a.load(2, false, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "410fb70424"); # movzx eax, word ptr [r12]
a.load(2, false, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "450fb71c24"); # movzx r11d, word ptr [r12]
a.load(2, false, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "410fb71424"); # movzx edx, word ptr [r12]
a.load(2, true, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "490fbf0424"); # movsx rax, word ptr [r12]
a.load(2, true, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "4d0fbf1c24"); # movsx r11, word ptr [r12]
a.load(2, true, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "490fbf1424"); # movsx rdx, word ptr [r12]
a.store(2, indexed(reg::r12, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "6641890424"); # mov word ptr [r12], ax
a.store(2, indexed(reg::r12, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "6641893424"); # mov word ptr [r12], si
a.store(2, indexed(reg::r12, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "6645891424"); # mov word ptr [r12], r10w
a.load(4, false, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "418b0424"); # mov eax, dword ptr [r12]
a.load(4, false, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "458b1c24"); # mov r11d, dword ptr [r12]
a.load(4, false, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "418b1424"); # mov edx, dword ptr [r12]
a.load(4, true, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "49630424"); # movsxd rax, dword ptr [r12]
a.load(4, true, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "4d631c24"); # movsxd r11, dword ptr [r12]
a.load(4, true, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "49631424"); # movsxd rdx, dword ptr [r12]
a.store(4, indexed(reg::r12, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "41890424"); # mov dword ptr [r12], eax
a.store(4, indexed(reg::r12, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "41893424"); # mov dword ptr [r12], esi
a.store(4, indexed(reg::r12, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "45891424"); # mov dword ptr [r12], r10d
a.load(8, false, reg::rax, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "498b0424"); # mov rax, qword ptr [r12]
a.load(8, false, reg::r11, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "4d8b1c24"); # mov r11, qword ptr [r12]
a.load(8, false, reg::rdx, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "498b1424"); # mov rdx, qword ptr [r12]
a.store(8, indexed(reg::r12, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "49890424"); # mov qword ptr [r12], rax
a.store(8, indexed(reg::r12, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "49893424"); # mov qword ptr [r12], rsi
a.store(8, indexed(reg::r12, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "4d891424"); # mov qword ptr [r12], r10
a.store_imm(indexed(reg::r12, reg::none, 1, 0), -5); encodes(t, &mut a, "49c70424fbffffff"); # mov qword ptr [r12], -5
a.lea(reg::rdi, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "498d3c24"); # lea rdi, [r12]
a.alu_load(alu::add, reg::r9, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "4d030c24"); # add r9, qword ptr [r12]
a.alu_mem_imm(alu::cmp, indexed(reg::r12, reg::none, 1, 0), 0); encodes(t, &mut a, "49833c2400"); # cmp qword ptr [r12], 0
a.alu_mem_imm(alu::cmp, indexed(reg::r12, reg::none, 1, 0), 1000); encodes(t, &mut a, "49813c24e8030000"); # cmp qword ptr [r12], 1000
a.movss_load(1, indexed(reg::r12, reg::none, 1, 0)); encodes(t, &mut a, "f3410f100c24"); # movss xmm1, dword ptr [r12]
a.movss_store(indexed(reg::r12, reg::none, 1, 0), 9); encodes(t, &mut a, "f3450f110c24"); # movss dword ptr [r12], xmm9
a.load(1, false, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "410fb6442428"); # movzx eax, byte ptr [r12+40]
a.load(1, false, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "450fb65c2428"); # movzx r11d, byte ptr [r12+40]
a.load(1, false, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "410fb6542428"); # movzx edx, byte ptr [r12+40]
a.load(1, true, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "490fbe442428"); # movsx rax, byte ptr [r12+40]
a.load(1, true, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4d0fbe5c2428"); # movsx r11, byte ptr [r12+40]
a.load(1, true, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "490fbe542428"); # movsx rdx, byte ptr [r12+40]
a.store(1, indexed(reg::r12, reg::none, 1, 40), reg::rax); encodes(t, &mut a, "4188442428"); # mov byte ptr [r12+40], al
a.store(1, indexed(reg::r12, reg::none, 1, 40), reg::rsi); encodes(t, &mut a, "4188742428"); # mov byte ptr [r12+40], sil
a.store(1, indexed(reg::r12, reg::none, 1, 40), reg::r10); encodes(t, &mut a, "4588542428"); # mov byte ptr [r12+40], r10b
a.load(2, false, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "410fb7442428"); # movzx eax, word ptr [r12+40]
a.load(2, false, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "450fb75c2428"); # movzx r11d, word ptr [r12+40]
a.load(2, false, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "410fb7542428"); # movzx edx, word ptr [r12+40]
a.load(2, true, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "490fbf442428"); # movsx rax, word ptr [r12+40]
a.load(2, true, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4d0fbf5c2428"); # movsx r11, word ptr [r12+40]
a.load(2, true, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "490fbf542428"); # movsx rdx, word ptr [r12+40]
a.store(2, indexed(reg::r12, reg::none, 1, 40), reg::rax); encodes(t, &mut a, "664189442428"); # mov word ptr [r12+40], ax
a.store(2, indexed(reg::r12, reg::none, 1, 40), reg::rsi); encodes(t, &mut a, "664189742428"); # mov word ptr [r12+40], si
a.store(2, indexed(reg::r12, reg::none, 1, 40), reg::r10); encodes(t, &mut a, "664589542428"); # mov word ptr [r12+40], r10w
a.load(4, false, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "418b442428"); # mov eax, dword ptr [r12+40]
a.load(4, false, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "458b5c2428"); # mov r11d, dword ptr [r12+40]
a.load(4, false, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "418b542428"); # mov edx, dword ptr [r12+40]
a.load(4, true, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4963442428"); # movsxd rax, dword ptr [r12+40]
a.load(4, true, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4d635c2428"); # movsxd r11, dword ptr [r12+40]
a.load(4, true, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4963542428"); # movsxd rdx, dword ptr [r12+40]
a.store(4, indexed(reg::r12, reg::none, 1, 40), reg::rax); encodes(t, &mut a, "4189442428"); # mov dword ptr [r12+40], eax
a.store(4, indexed(reg::r12, reg::none, 1, 40), reg::rsi); encodes(t, &mut a, "4189742428"); # mov dword ptr [r12+40], esi
a.store(4, indexed(reg::r12, reg::none, 1, 40), reg::r10); encodes(t, &mut a, "4589542428"); # mov dword ptr [r12+40], r10d
a.load(8, false, reg::rax, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "498b442428"); # mov rax, qword ptr [r12+40]
a.load(8, false, reg::r11, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4d8b5c2428"); # mov r11, qword ptr [r12+40]
a.load(8, false, reg::rdx, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "498b542428"); # mov rdx, qword ptr [r12+40]
a.store(8, indexed(reg::r12, reg::none, 1, 40), reg::rax); encodes(t, &mut a, "4989442428"); # mov qword ptr [r12+40], rax
a.store(8, indexed(reg::r12, reg::none, 1, 40), reg::rsi); encodes(t, &mut a, "4989742428"); # mov qword ptr [r12+40], rsi
a.store(8, indexed(reg::r12, reg::none, 1, 40), reg::r10); encodes(t, &mut a, "4d89542428"); # mov qword ptr [r12+40], r10
a.store_imm(indexed(reg::r12, reg::none, 1, 40), -5); encodes(t, &mut a, "49c7442428fbffffff"); # mov qword ptr [r12+40], -5
a.lea(reg::rdi, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "498d7c2428"); # lea rdi, [r12+40]
a.alu_load(alu::add, reg::r9, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "4d034c2428"); # add r9, qword ptr [r12+40]
a.alu_mem_imm(alu::cmp, indexed(reg::r12, reg::none, 1, 40), 0); encodes(t, &mut a, "49837c242800"); # cmp qword ptr [r12+40], 0
a.alu_mem_imm(alu::cmp, indexed(reg::r12, reg::none, 1, 40), 1000); encodes(t, &mut a, "49817c2428e8030000"); # cmp qword ptr [r12+40], 1000
a.movss_load(1, indexed(reg::r12, reg::none, 1, 40)); encodes(t, &mut a, "f3410f104c2428"); # movss xmm1, dword ptr [r12+40]
a.movss_store(indexed(reg::r12, reg::none, 1, 40), 9); encodes(t, &mut a, "f3450f114c2428"); # movss dword ptr [r12+40], xmm9
a.load(1, false, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "410fb64500"); # movzx eax, byte ptr [r13]
a.load(1, false, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "450fb65d00"); # movzx r11d, byte ptr [r13]
a.load(1, false, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "410fb65500"); # movzx edx, byte ptr [r13]
a.load(1, true, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "490fbe4500"); # movsx rax, byte ptr [r13]
a.load(1, true, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "4d0fbe5d00"); # movsx r11, byte ptr [r13]
a.load(1, true, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "490fbe5500"); # movsx rdx, byte ptr [r13]
a.store(1, indexed(reg::r13, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "41884500"); # mov byte ptr [r13], al
a.store(1, indexed(reg::r13, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "41887500"); # mov byte ptr [r13], sil
a.store(1, indexed(reg::r13, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "45885500"); # mov byte ptr [r13], r10b
a.load(2, false, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "410fb74500"); # movzx eax, word ptr [r13]
a.load(2, false, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "450fb75d00"); # movzx r11d, word ptr [r13]
a.load(2, false, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "410fb75500"); # movzx edx, word ptr [r13]
a.load(2, true, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "490fbf4500"); # movsx rax, word ptr [r13]
a.load(2, true, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "4d0fbf5d00"); # movsx r11, word ptr [r13]
a.load(2, true, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "490fbf5500"); # movsx rdx, word ptr [r13]
a.store(2, indexed(reg::r13, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "6641894500"); # mov word ptr [r13], ax
a.store(2, indexed(reg::r13, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "6641897500"); # mov word ptr [r13], si
a.store(2, indexed(reg::r13, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "6645895500"); # mov word ptr [r13], r10w
a.load(4, false, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "418b4500"); # mov eax, dword ptr [r13]
a.load(4, false, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "458b5d00"); # mov r11d, dword ptr [r13]
a.load(4, false, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "418b5500"); # mov edx, dword ptr [r13]
a.load(4, true, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "49634500"); # movsxd rax, dword ptr [r13]
a.load(4, true, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "4d635d00"); # movsxd r11, dword ptr [r13]
a.load(4, true, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "49635500"); # movsxd rdx, dword ptr [r13]
a.store(4, indexed(reg::r13, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "41894500"); # mov dword ptr [r13], eax
a.store(4, indexed(reg::r13, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "41897500"); # mov dword ptr [r13], esi
a.store(4, indexed(reg::r13, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "45895500"); # mov dword ptr [r13], r10d
a.load(8, false, reg::rax, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "498b4500"); # mov rax, qword ptr [r13]
a.load(8, false, reg::r11, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "4d8b5d00"); # mov r11, qword ptr [r13]
a.load(8, false, reg::rdx, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "498b5500"); # mov rdx, qword ptr [r13]
a.store(8, indexed(reg::r13, reg::none, 1, 0), reg::rax); encodes(t, &mut a, "49894500"); # mov qword ptr [r13], rax
a.store(8, indexed(reg::r13, reg::none, 1, 0), reg::rsi); encodes(t, &mut a, "49897500"); # mov qword ptr [r13], rsi
a.store(8, indexed(reg::r13, reg::none, 1, 0), reg::r10); encodes(t, &mut a, "4d895500"); # mov qword ptr [r13], r10
a.store_imm(indexed(reg::r13, reg::none, 1, 0), -5); encodes(t, &mut a, "49c74500fbffffff"); # mov qword ptr [r13], -5
a.lea(reg::rdi, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "498d7d00"); # lea rdi, [r13]
a.alu_load(alu::add, reg::r9, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "4d034d00"); # add r9, qword ptr [r13]
a.alu_mem_imm(alu::cmp, indexed(reg::r13, reg::none, 1, 0), 0); encodes(t, &mut a, "49837d0000"); # cmp qword ptr [r13], 0
a.alu_mem_imm(alu::cmp, indexed(reg::r13, reg::none, 1, 0), 1000); encodes(t, &mut a, "49817d00e8030000"); # cmp qword ptr [r13], 1000
a.movss_load(1, indexed(reg::r13, reg::none, 1, 0)); encodes(t, &mut a, "f3410f104d00"); # movss xmm1, dword ptr [r13]
a.movss_store(indexed(reg::r13, reg::none, 1, 0), 9); encodes(t, &mut a, "f3450f114d00"); # movss dword ptr [r13], xmm9
a.load(1, false, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "410fb685c8000000"); # movzx eax, byte ptr [r13+200]
a.load(1, false, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "450fb69dc8000000"); # movzx r11d, byte ptr [r13+200]
a.load(1, false, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "410fb695c8000000"); # movzx edx, byte ptr [r13+200]
a.load(1, true, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "490fbe85c8000000"); # movsx rax, byte ptr [r13+200]
a.load(1, true, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "4d0fbe9dc8000000"); # movsx r11, byte ptr [r13+200]
a.load(1, true, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "490fbe95c8000000"); # movsx rdx, byte ptr [r13+200]
a.store(1, indexed(reg::r13, reg::none, 1, 200), reg::rax); encodes(t, &mut a, "418885c8000000"); # mov byte ptr [r13+200], al
a.store(1, indexed(reg::r13, reg::none, 1, 200), reg::rsi); encodes(t, &mut a, "4188b5c8000000"); # mov byte ptr [r13+200], sil
a.store(1, indexed(reg::r13, reg::none, 1, 200), reg::r10); encodes(t, &mut a, "458895c8000000"); # mov byte ptr [r13+200], r10b
a.load(2, false, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "410fb785c8000000"); # movzx eax, word ptr [r13+200]
a.load(2, false, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "450fb79dc8000000"); # movzx r11d, word ptr [r13+200]
a.load(2, false, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "410fb795c8000000"); # movzx edx, word ptr [r13+200]
a.load(2, true, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "490fbf85c8000000"); # movsx rax, word ptr [r13+200]
a.load(2, true, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "4d0fbf9dc8000000"); # movsx r11, word ptr [r13+200]
a.load(2, true, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "490fbf95c8000000"); # movsx rdx, word ptr [r13+200]
a.store(2, indexed(reg::r13, reg::none, 1, 200), reg::rax); encodes(t, &mut a, "66418985c8000000"); # mov word ptr [r13+200], ax
a.store(2, indexed(reg::r13, reg::none, 1, 200), reg::rsi); encodes(t, &mut a, "664189b5c8000000"); # mov word ptr [r13+200], si
a.store(2, indexed(reg::r13, reg::none, 1, 200), reg::r10); encodes(t, &mut a, "66458995c8000000"); # mov word ptr [r13+200], r10w
a.load(4, false, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "418b85c8000000"); # mov eax, dword ptr [r13+200]
a.load(4, false, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "458b9dc8000000"); # mov r11d, dword ptr [r13+200]
a.load(4, false, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "418b95c8000000"); # mov edx, dword ptr [r13+200]
a.load(4, true, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "496385c8000000"); # movsxd rax, dword ptr [r13+200]
a.load(4, true, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "4d639dc8000000"); # movsxd r11, dword ptr [r13+200]
a.load(4, true, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "496395c8000000"); # movsxd rdx, dword ptr [r13+200]
a.store(4, indexed(reg::r13, reg::none, 1, 200), reg::rax); encodes(t, &mut a, "418985c8000000"); # mov dword ptr [r13+200], eax
a.store(4, indexed(reg::r13, reg::none, 1, 200), reg::rsi); encodes(t, &mut a, "4189b5c8000000"); # mov dword ptr [r13+200], esi
a.store(4, indexed(reg::r13, reg::none, 1, 200), reg::r10); encodes(t, &mut a, "458995c8000000"); # mov dword ptr [r13+200], r10d
a.load(8, false, reg::rax, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "498b85c8000000"); # mov rax, qword ptr [r13+200]
a.load(8, false, reg::r11, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "4d8b9dc8000000"); # mov r11, qword ptr [r13+200]
a.load(8, false, reg::rdx, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "498b95c8000000"); # mov rdx, qword ptr [r13+200]
a.store(8, indexed(reg::r13, reg::none, 1, 200), reg::rax); encodes(t, &mut a, "498985c8000000"); # mov qword ptr [r13+200], rax
a.store(8, indexed(reg::r13, reg::none, 1, 200), reg::rsi); encodes(t, &mut a, "4989b5c8000000"); # mov qword ptr [r13+200], rsi
a.store(8, indexed(reg::r13, reg::none, 1, 200), reg::r10); encodes(t, &mut a, "4d8995c8000000"); # mov qword ptr [r13+200], r10
a.store_imm(indexed(reg::r13, reg::none, 1, 200), -5); encodes(t, &mut a, "49c785c8000000fbffffff"); # mov qword ptr [r13+200], -5
a.lea(reg::rdi, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "498dbdc8000000"); # lea rdi, [r13+200]
a.alu_load(alu::add, reg::r9, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "4d038dc8000000"); # add r9, qword ptr [r13+200]
a.alu_mem_imm(alu::cmp, indexed(reg::r13, reg::none, 1, 200), 0); encodes(t, &mut a, "4983bdc800000000"); # cmp qword ptr [r13+200], 0
a.alu_mem_imm(alu::cmp, indexed(reg::r13, reg::none, 1, 200), 1000); encodes(t, &mut a, "4981bdc8000000e8030000"); # cmp qword ptr [r13+200], 1000
a.movss_load(1, indexed(reg::r13, reg::none, 1, 200)); encodes(t, &mut a, "f3410f108dc8000000"); # movss xmm1, dword ptr [r13+200]
a.movss_store(indexed(reg::r13, reg::none, 1, 200), 9); encodes(t, &mut a, "f3450f118dc8000000"); # movss dword ptr [r13+200], xmm9
a.load(1, false, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "410fb687d4feffff"); # movzx eax, byte ptr [r15-300]
a.load(1, false, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "450fb69fd4feffff"); # movzx r11d, byte ptr [r15-300]
a.load(1, false, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "410fb697d4feffff"); # movzx edx, byte ptr [r15-300]
a.load(1, true, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "490fbe87d4feffff"); # movsx rax, byte ptr [r15-300]
a.load(1, true, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "4d0fbe9fd4feffff"); # movsx r11, byte ptr [r15-300]
a.load(1, true, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "490fbe97d4feffff"); # movsx rdx, byte ptr [r15-300]
a.store(1, indexed(reg::r15, reg::none, 1, -300), reg::rax); encodes(t, &mut a, "418887d4feffff"); # mov byte ptr [r15-300], al
a.store(1, indexed(reg::r15, reg::none, 1, -300), reg::rsi); encodes(t, &mut a, "4188b7d4feffff"); # mov byte ptr [r15-300], sil
a.store(1, indexed(reg::r15, reg::none, 1, -300), reg::r10); encodes(t, &mut a, "458897d4feffff"); # mov byte ptr [r15-300], r10b
a.load(2, false, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "410fb787d4feffff"); # movzx eax, word ptr [r15-300]
a.load(2, false, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "450fb79fd4feffff"); # movzx r11d, word ptr [r15-300]
a.load(2, false, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "410fb797d4feffff"); # movzx edx, word ptr [r15-300]
a.load(2, true, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "490fbf87d4feffff"); # movsx rax, word ptr [r15-300]
a.load(2, true, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "4d0fbf9fd4feffff"); # movsx r11, word ptr [r15-300]
a.load(2, true, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "490fbf97d4feffff"); # movsx rdx, word ptr [r15-300]
a.store(2, indexed(reg::r15, reg::none, 1, -300), reg::rax); encodes(t, &mut a, "66418987d4feffff"); # mov word ptr [r15-300], ax
a.store(2, indexed(reg::r15, reg::none, 1, -300), reg::rsi); encodes(t, &mut a, "664189b7d4feffff"); # mov word ptr [r15-300], si
a.store(2, indexed(reg::r15, reg::none, 1, -300), reg::r10); encodes(t, &mut a, "66458997d4feffff"); # mov word ptr [r15-300], r10w
a.load(4, false, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "418b87d4feffff"); # mov eax, dword ptr [r15-300]
a.load(4, false, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "458b9fd4feffff"); # mov r11d, dword ptr [r15-300]
a.load(4, false, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "418b97d4feffff"); # mov edx, dword ptr [r15-300]
a.load(4, true, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "496387d4feffff"); # movsxd rax, dword ptr [r15-300]
a.load(4, true, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "4d639fd4feffff"); # movsxd r11, dword ptr [r15-300]
a.load(4, true, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "496397d4feffff"); # movsxd rdx, dword ptr [r15-300]
a.store(4, indexed(reg::r15, reg::none, 1, -300), reg::rax); encodes(t, &mut a, "418987d4feffff"); # mov dword ptr [r15-300], eax
a.store(4, indexed(reg::r15, reg::none, 1, -300), reg::rsi); encodes(t, &mut a, "4189b7d4feffff"); # mov dword ptr [r15-300], esi
a.store(4, indexed(reg::r15, reg::none, 1, -300), reg::r10); encodes(t, &mut a, "458997d4feffff"); # mov dword ptr [r15-300], r10d
a.load(8, false, reg::rax, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "498b87d4feffff"); # mov rax, qword ptr [r15-300]
a.load(8, false, reg::r11, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "4d8b9fd4feffff"); # mov r11, qword ptr [r15-300]
a.load(8, false, reg::rdx, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "498b97d4feffff"); # mov rdx, qword ptr [r15-300]
a.store(8, indexed(reg::r15, reg::none, 1, -300), reg::rax); encodes(t, &mut a, "498987d4feffff"); # mov qword ptr [r15-300], rax
a.store(8, indexed(reg::r15, reg::none, 1, -300), reg::rsi); encodes(t, &mut a, "4989b7d4feffff"); # mov qword ptr [r15-300], rsi
a.store(8, indexed(reg::r15, reg::none, 1, -300), reg::r10); encodes(t, &mut a, "4d8997d4feffff"); # mov qword ptr [r15-300], r10
a.store_imm(indexed(reg::r15, reg::none, 1, -300), -5); encodes(t, &mut a, "49c787d4fefffffbffffff"); # mov qword ptr [r15-300], -5
a.lea(reg::rdi, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "498dbfd4feffff"); # lea rdi, [r15-300]
a.alu_load(alu::add, reg::r9, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "4d038fd4feffff"); # add r9, qword ptr [r15-300]
a.alu_mem_imm(alu::cmp, indexed(reg::r15, reg::none, 1, -300), 0); encodes(t, &mut a, "4983bfd4feffff00"); # cmp qword ptr [r15-300], 0
a.alu_mem_imm(alu::cmp, indexed(reg::r15, reg::none, 1, -300), 1000); encodes(t, &mut a, "4981bfd4feffffe8030000"); # cmp qword ptr [r15-300], 1000
a.movss_load(1, indexed(reg::r15, reg::none, 1, -300)); encodes(t, &mut a, "f3410f108fd4feffff"); # movss xmm1, dword ptr [r15-300]
a.movss_store(indexed(reg::r15, reg::none, 1, -300), 9); encodes(t, &mut a, "f3450f118fd4feffff"); # movss dword ptr [r15-300], xmm9
a.lea(reg::rax, indexed(reg::rax, reg::rcx, 8, 0)); encodes(t, &mut a, "488d04c8"); # lea rax, [rax+rcx*8]
a.load(8, false, reg::r8, indexed(reg::rax, reg::rcx, 8, 0)); encodes(t, &mut a, "4c8b04c8"); # mov r8, qword ptr [rax+rcx*8]
a.lea(reg::rax, indexed(reg::rbx, reg::r12, 4, 16)); encodes(t, &mut a, "4a8d44a310"); # lea rax, [rbx+r12*4+16]
a.load(8, false, reg::r8, indexed(reg::rbx, reg::r12, 4, 16)); encodes(t, &mut a, "4e8b44a310"); # mov r8, qword ptr [rbx+r12*4+16]
a.lea(reg::rax, indexed(reg::r13, reg::rax, 1, 0)); encodes(t, &mut a, "498d440500"); # lea rax, [r13+rax*1]
a.load(8, false, reg::r8, indexed(reg::r13, reg::rax, 1, 0)); encodes(t, &mut a, "4d8b440500"); # mov r8, qword ptr [r13+rax*1]
a.lea(reg::rax, indexed(reg::rsp, reg::rbp, 2, -4)); encodes(t, &mut a, "488d446cfc"); # lea rax, [rsp+rbp*2-4]
a.load(8, false, reg::r8, indexed(reg::rsp, reg::rbp, 2, -4)); encodes(t, &mut a, "4c8b446cfc"); # mov r8, qword ptr [rsp+rbp*2-4]
a.lea(reg::rax, indexed(reg::none, reg::rcx, 8, 4194304)); encodes(t, &mut a, "488d04cd00004000"); # lea rax, [rcx*8+4194304]
a.load(8, false, reg::r8, indexed(reg::none, reg::rcx, 8, 4194304)); encodes(t, &mut a, "4c8b04cd00004000"); # mov r8, qword ptr [rcx*8+4194304]
a.load(8, false, reg::rax, indexed(reg::none, reg::none, 1, 4198400)); encodes(t, &mut a, "488b042500104000"); # mov rax, qword ptr ds:0x401000
a.alu(alu::add, reg::rax, reg::r11); encodes(t, &mut a, "4c01d8"); # add rax, r11
a.alu(alu::add, reg::r12, reg::rdx); encodes(t, &mut a, "4901d4"); # add r12, rdx
a.alu_imm(alu::add, reg::rcx, 5); encodes(t, &mut a, "4883c105"); # add rcx, 5
a.alu_imm(alu::add, reg::r10, -100000); encodes(t, &mut a, "4981c26079feff"); # add r10, -100000
a.alu(alu::bor, reg::rax, reg::r11); encodes(t, &mut a, "4c09d8"); # or rax, r11
a.alu(alu::bor, reg::r12, reg::rdx); encodes(t, &mut a, "4909d4"); # or r12, rdx
a.alu_imm(alu::bor, reg::rcx, 5); encodes(t, &mut a, "4883c905"); # or rcx, 5
a.alu_imm(alu::bor, reg::r10, -100000); encodes(t, &mut a, "4981ca6079feff"); # or r10, -100000
a.alu(alu::band, reg::rax, reg::r11); encodes(t, &mut a, "4c21d8"); # and rax, r11
a.alu(alu::band, reg::r12, reg::rdx); encodes(t, &mut a, "4921d4"); # and r12, rdx
a.alu_imm(alu::band, reg::rcx, 5); encodes(t, &mut a, "4883e105"); # and rcx, 5
a.alu_imm(alu::band, reg::r10, -100000); encodes(t, &mut a, "4981e26079feff"); # and r10, -100000
a.alu(alu::sub, reg::rax, reg::r11); encodes(t, &mut a, "4c29d8"); # sub rax, r11
a.alu(alu::sub, reg::r12, reg::rdx); encodes(t, &mut a, "4929d4"); # sub r12, rdx
a.alu_imm(alu::sub, reg::rcx, 5); encodes(t, &mut a, "4883e905"); # sub rcx, 5
a.alu_imm(alu::sub, reg::r10, -100000); encodes(t, &mut a, "4981ea6079feff"); # sub r10, -100000
a.alu(alu::bxor, reg::rax, reg::r11); encodes(t, &mut a, "4c31d8"); # xor rax, r11
a.alu(alu::bxor, reg::r12, reg::rdx); encodes(t, &mut a, "4931d4"); # xor r12, rdx
a.alu_imm(alu::bxor, reg::rcx, 5); encodes(t, &mut a, "4883f105"); # xor rcx, 5
a.alu_imm(alu::bxor, reg::r10, -100000); encodes(t, &mut a, "4981f26079feff"); # xor r10, -100000
a.alu(alu::cmp, reg::rax, reg::r11); encodes(t, &mut a, "4c39d8"); # cmp rax, r11
a.alu(alu::cmp, reg::r12, reg::rdx); encodes(t, &mut a, "4939d4"); # cmp r12, rdx
a.alu_imm(alu::cmp, reg::rcx, 5); encodes(t, &mut a, "4883f905"); # cmp rcx, 5
a.alu_imm(alu::cmp, reg::r10, -100000); encodes(t, &mut a, "4981fa6079feff"); # cmp r10, -100000
a.alu(alu::adc, reg::rax, reg::r11); encodes(t, &mut a, "4c11d8"); # adc rax, r11
a.alu(alu::adc, reg::r12, reg::rdx); encodes(t, &mut a, "4911d4"); # adc r12, rdx
a.alu_imm(alu::adc, reg::rcx, 5); encodes(t, &mut a, "4883d105"); # adc rcx, 5
a.alu_imm(alu::adc, reg::r10, -100000); encodes(t, &mut a, "4981d26079feff"); # adc r10, -100000
a.alu(alu::sbb, reg::rax, reg::r11); encodes(t, &mut a, "4c19d8"); # sbb rax, r11
a.alu(alu::sbb, reg::r12, reg::rdx); encodes(t, &mut a, "4919d4"); # sbb r12, rdx
a.alu_imm(alu::sbb, reg::rcx, 5); encodes(t, &mut a, "4883d905"); # sbb rcx, 5
a.alu_imm(alu::sbb, reg::r10, -100000); encodes(t, &mut a, "4981da6079feff"); # sbb r10, -100000
a.test(reg::rax, reg::rax); encodes(t, &mut a, "4885c0"); # test rax, rax
a.test(reg::r9, reg::rcx); encodes(t, &mut a, "4985c9"); # test r9, rcx
a.imul(reg::rax, reg::rcx); encodes(t, &mut a, "480fafc1"); # imul rax, rcx
a.imul(reg::r14, reg::r8); encodes(t, &mut a, "4d0faff0"); # imul r14, r8
a.unary(unary::bnot, reg::rcx); encodes(t, &mut a, "48f7d1"); # not rcx
a.unary(unary::bnot, reg::r13); encodes(t, &mut a, "49f7d5"); # not r13
a.unary(unary::neg, reg::rcx); encodes(t, &mut a, "48f7d9"); # neg rcx
a.unary(unary::neg, reg::r13); encodes(t, &mut a, "49f7dd"); # neg r13
a.unary(unary::mul, reg::rcx); encodes(t, &mut a, "48f7e1"); # mul rcx
a.unary(unary::mul, reg::r13); encodes(t, &mut a, "49f7e5"); # mul r13
a.unary(unary::div, reg::rcx); encodes(t, &mut a, "48f7f1"); # div rcx
a.unary(unary::div, reg::r13); encodes(t, &mut a, "49f7f5"); # div r13
a.unary(unary::idiv, reg::rcx); encodes(t, &mut a, "48f7f9"); # idiv rcx
a.unary(unary::idiv, reg::r13); encodes(t, &mut a, "49f7fd"); # idiv r13
a.bsr(reg::rax, reg::rcx); encodes(t, &mut a, "480fbdc1"); # bsr rax, rcx
a.bsr(reg::r13, reg::r9); encodes(t, &mut a, "4d0fbde9"); # bsr r13, r9
a.bsf(reg::rax, reg::rcx); encodes(t, &mut a, "480fbcc1"); # bsf rax, rcx
a.bsf(reg::r13, reg::r9); encodes(t, &mut a, "4d0fbce9"); # bsf r13, r9
a.bswap(reg::rax); encodes(t, &mut a, "480fc8"); # bswap rax
a.bswap(reg::r13); encodes(t, &mut a, "490fcd"); # bswap r13
a.cqo(); encodes(t, &mut a, "4899"); # cqo
a.shift_cl(shift::shl, reg::rax); encodes(t, &mut a, "48d3e0"); # shl rax, cl
a.shift_imm(shift::shl, reg::r9, 13); encodes(t, &mut a, "49c1e10d"); # shl r9, 13
a.shift_cl(shift::shr, reg::rax); encodes(t, &mut a, "48d3e8"); # shr rax, cl
a.shift_imm(shift::shr, reg::r9, 13); encodes(t, &mut a, "49c1e90d"); # shr r9, 13
a.shift_cl(shift::sar, reg::rax); encodes(t, &mut a, "48d3f8"); # sar rax, cl
a.shift_imm(shift::sar, reg::r9, 13); encodes(t, &mut a, "49c1f90d"); # sar r9, 13
a.setcc(cc::equal, reg::rax); encodes(t, &mut a, "0f94c00fb6c0"); # sete al; movzx eax, al
a.setcc(cc::equal, reg::rsi); encodes(t, &mut a, "400f94c6400fb6f6"); # sete sil; movzx esi, sil
a.setcc(cc::equal, reg::r10); encodes(t, &mut a, "410f94c2450fb6d2"); # sete r10b; movzx r10d, r10b
a.setcc(cc::not_equal, reg::rax); encodes(t, &mut a, "0f95c00fb6c0"); # setne al; movzx eax, al
a.setcc(cc::not_equal, reg::rsi); encodes(t, &mut a, "400f95c6400fb6f6"); # setne sil; movzx esi, sil
a.setcc(cc::not_equal, reg::r10); encodes(t, &mut a, "410f95c2450fb6d2"); # setne r10b; movzx r10d, r10b
a.setcc(cc::below, reg::rax); encodes(t, &mut a, "0f92c00fb6c0"); # setb al; movzx eax, al
a.setcc(cc::below, reg::rsi); encodes(t, &mut a, "400f92c6400fb6f6"); # setb sil; movzx esi, sil
a.setcc(cc::below, reg::r10); encodes(t, &mut a, "410f92c2450fb6d2"); # setb r10b; movzx r10d, r10b
a.setcc(cc::above, reg::rax); encodes(t, &mut a, "0f97c00fb6c0"); # seta al; movzx eax, al
a.setcc(cc::above, reg::rsi); encodes(t, &mut a, "400f97c6400fb6f6"); # seta sil; movzx esi, sil
a.setcc(cc::above, reg::r10); encodes(t, &mut a, "410f97c2450fb6d2"); # seta r10b; movzx r10d, r10b
a.setcc(cc::less, reg::rax); encodes(t, &mut a, "0f9cc00fb6c0"); # setl al; movzx eax, al
a.setcc(cc::less, reg::rsi); encodes(t, &mut a, "400f9cc6400fb6f6"); # setl sil; movzx esi, sil
a.setcc(cc::less, reg::r10); encodes(t, &mut a, "410f9cc2450fb6d2"); # setl r10b; movzx r10d, r10b
a.setcc(cc::greater_equal, reg::rax); encodes(t, &mut a, "0f9dc00fb6c0"); # setge al; movzx eax, al
a.setcc(cc::greater_equal, reg::rsi); encodes(t, &mut a, "400f9dc6400fb6f6"); # setge sil; movzx esi, sil
a.setcc(cc::greater_equal, reg::r10); encodes(t, &mut a, "410f9dc2450fb6d2"); # setge r10b; movzx r10d, r10b
a.setcc(cc::parity, reg::rax); encodes(t, &mut a, "0f9ac00fb6c0"); # setp al; movzx eax, al
a.setcc(cc::parity, reg::rsi); encodes(t, &mut a, "400f9ac6400fb6f6"); # setp sil; movzx esi, sil
a.setcc(cc::parity, reg::r10); encodes(t, &mut a, "410f9ac2450fb6d2"); # setp r10b; movzx r10d, r10b
a.setcc(cc::no_parity, reg::rax); encodes(t, &mut a, "0f9bc00fb6c0"); # setnp al; movzx eax, al
a.setcc(cc::no_parity, reg::rsi); encodes(t, &mut a, "400f9bc6400fb6f6"); # setnp sil; movzx esi, sil
a.setcc(cc::no_parity, reg::r10); encodes(t, &mut a, "410f9bc2450fb6d2"); # setnp r10b; movzx r10d, r10b
a.push(reg::rax); encodes(t, &mut a, "50"); # push rax
a.pop(reg::rax); encodes(t, &mut a, "58"); # pop rax
a.call_reg(reg::rax); encodes(t, &mut a, "ffd0"); # call rax
a.push(reg::rbp); encodes(t, &mut a, "55"); # push rbp
a.pop(reg::rbp); encodes(t, &mut a, "5d"); # pop rbp
a.call_reg(reg::rbp); encodes(t, &mut a, "ffd5"); # call rbp
a.push(reg::r12); encodes(t, &mut a, "4154"); # push r12
a.pop(reg::r12); encodes(t, &mut a, "415c"); # pop r12
a.call_reg(reg::r12); encodes(t, &mut a, "41ffd4"); # call r12
a.push(reg::r15); encodes(t, &mut a, "4157"); # push r15
a.pop(reg::r15); encodes(t, &mut a, "415f"); # pop r15
a.call_reg(reg::r15); encodes(t, &mut a, "41ffd7"); # call r15
a.ret(); encodes(t, &mut a, "c3"); # ret
a.leave(); encodes(t, &mut a, "c9"); # leave
a.syscall(); encodes(t, &mut a, "0f05"); # syscall
a.rep_movsb(); encodes(t, &mut a, "f3a4"); # rep movsb
a.rep_stosb(); encodes(t, &mut a, "f3aa"); # rep stosb
a.imul_imm(reg::rax, reg::rcx, 5); encodes(t, &mut a, "486bc105"); # imul rax, rcx, 5
a.imul_imm(reg::r9, reg::r15, 1000); encodes(t, &mut a, "4d69cfe8030000"); # imul r9, r15, 1000
a.imul_imm(reg::rsi, reg::r13, -3); encodes(t, &mut a, "496bf5fd"); # imul rsi, r13, -3
a.extend(1, false, reg::rax, reg::rsi); encodes(t, &mut a, "400fb6c6"); # movzx eax, sil
a.extend(1, false, reg::r14, reg::r9); encodes(t, &mut a, "450fb6f1"); # movzx r14d, r9b
a.extend(1, true, reg::rcx, reg::rdi); encodes(t, &mut a, "480fbecf"); # movsx rcx, dil
a.extend(1, true, reg::r8, reg::rax); encodes(t, &mut a, "4c0fbec0"); # movsx r8, al
a.extend(2, false, reg::rdx, reg::r10); encodes(t, &mut a, "410fb7d2"); # movzx edx, r10w
a.extend(2, true, reg::r11, reg::rcx); encodes(t, &mut a, "4c0fbfd9"); # movsx r11, cx
a.extend(4, false, reg::rsi, reg::r13); encodes(t, &mut a, "418bf5"); # mov esi, r13d
a.extend(4, false, reg::rax, reg::rax); encodes(t, &mut a, "8bc0"); # mov eax, eax
a.extend(4, true, reg::rdi, reg::r9); encodes(t, &mut a, "4963f9"); # movsxd rdi, r9d
a.rep_movsq(); encodes(t, &mut a, "f348a5"); # rep movsq
a.rep_stosq(); encodes(t, &mut a, "f348ab"); # rep stosq
a.ud2(); encodes(t, &mut a, "0f0b"); # ud2
a.movq_to_xmm(0, reg::rax); encodes(t, &mut a, "66480f6ec0"); # movq xmm0, rax
a.movq_from_xmm(reg::rax, 0); encodes(t, &mut a, "66480f7ec0"); # movq rax, xmm0
a.cvtsi2sd(0, reg::rax); encodes(t, &mut a, "f2480f2ac0"); # cvtsi2sd xmm0, rax
a.cvttsd2si(reg::rax, 0); encodes(t, &mut a, "f2480f2cc0"); # cvttsd2si rax, xmm0
a.movq_to_xmm(9, reg::rcx); encodes(t, &mut a, "664c0f6ec9"); # movq xmm9, rcx
a.movq_from_xmm(reg::rcx, 9); encodes(t, &mut a, "664c0f7ec9"); # movq rcx, xmm9
a.cvtsi2sd(9, reg::rcx); encodes(t, &mut a, "f24c0f2ac9"); # cvtsi2sd xmm9, rcx
a.cvttsd2si(reg::rcx, 9); encodes(t, &mut a, "f2490f2cc9"); # cvttsd2si rcx, xmm9
a.movq_to_xmm(2, reg::r13); encodes(t, &mut a, "66490f6ed5"); # movq xmm2, r13
a.movq_from_xmm(reg::r13, 2); encodes(t, &mut a, "66490f7ed5"); # movq r13, xmm2
a.cvtsi2sd(2, reg::r13); encodes(t, &mut a, "f2490f2ad5"); # cvtsi2sd xmm2, r13
a.cvttsd2si(reg::r13, 2); encodes(t, &mut a, "f24c0f2cea"); # cvttsd2si r13, xmm2
a.sse(sse::sqrtsd, 0, 1); encodes(t, &mut a, "f20f51c1"); # sqrtsd xmm0, xmm1
a.sse(sse::sqrtsd, 12, 3); encodes(t, &mut a, "f2440f51e3"); # sqrtsd xmm12, xmm3
a.sse(sse::addsd, 0, 1); encodes(t, &mut a, "f20f58c1"); # addsd xmm0, xmm1
a.sse(sse::addsd, 12, 3); encodes(t, &mut a, "f2440f58e3"); # addsd xmm12, xmm3
a.sse(sse::subsd, 0, 1); encodes(t, &mut a, "f20f5cc1"); # subsd xmm0, xmm1
a.sse(sse::subsd, 12, 3); encodes(t, &mut a, "f2440f5ce3"); # subsd xmm12, xmm3
a.sse(sse::mulsd, 0, 1); encodes(t, &mut a, "f20f59c1"); # mulsd xmm0, xmm1
a.sse(sse::mulsd, 12, 3); encodes(t, &mut a, "f2440f59e3"); # mulsd xmm12, xmm3
a.sse(sse::divsd, 0, 1); encodes(t, &mut a, "f20f5ec1"); # divsd xmm0, xmm1
a.sse(sse::divsd, 12, 3); encodes(t, &mut a, "f2440f5ee3"); # divsd xmm12, xmm3
a.ucomisd(0, 1); encodes(t, &mut a, "660f2ec1"); # ucomisd xmm0, xmm1
a.ucomisd(10, 15); encodes(t, &mut a, "66450f2ed7"); # ucomisd xmm10, xmm15
a.cvtsd2ss(0, 0); encodes(t, &mut a, "f20f5ac0"); # cvtsd2ss xmm0, xmm0
a.cvtss2sd(1, 8); encodes(t, &mut a, "f3410f5ac8"); # cvtss2sd xmm1, xmm8
a.alu_store(alu::bor, at(reg::rbx, 0), reg::rax); encodes(t, &mut a, "480903"); # or qword ptr [rbx], rax
a.alu_store(alu::bor, at(reg::rbx, 16), reg::r9); encodes(t, &mut a, "4c094b10"); # or qword ptr [rbx+16], r9
a.alu_store(alu::bor, at(reg::r12, -8), reg::rcx); encodes(t, &mut a, "49094c24f8"); # or qword ptr [r12-8], rcx
a.alu_store(alu::band, at(reg::r13, 0), reg::rdx); encodes(t, &mut a, "49215500"); # and qword ptr [r13], rdx
a.alu_store(alu::bor, amd64::absolute(0x400058), reg::rax); encodes(t, &mut a, "4809042558004000"); # or qword ptr [0x400058], rax
a.lock(); a.alu_store(alu::bor, amd64::absolute(0x400058), reg::rax); encodes(t, &mut a, "f04809042558004000"); # lock or qword ptr [0x400058], rax
a.lock(); a.alu_store(alu::bor, at(reg::r12, 4096), reg::r9); encodes(t, &mut a, "f04d098c2400100000"); # lock or qword ptr [r12+4096], r9
a.xchg(8, at(reg::rbx, 0), reg::rax); encodes(t, &mut a, "488703"); # xchg qword ptr [rbx], rax
a.xchg(8, amd64::absolute(0x400058), reg::rax); encodes(t, &mut a, "4887042558004000"); # xchg qword ptr [0x400058], rax
a.xchg(8, at(reg::r12, 16), reg::r9); encodes(t, &mut a, "4d874c2410"); # xchg qword ptr [r12+16], r9
a.xchg(8, at(reg::rsp, 8), reg::r15); encodes(t, &mut a, "4c877c2408"); # xchg qword ptr [rsp+8], r15
a.fmod_stack(); encodes(t, &mut a, "dd442408dd0424d9f8dfe0f6c40475f7dd1c24ddd8"); # fld, fld, fprem until done, fstp, fstp
}
# Atomics' instructions, at each width, with registers needing a REX prefix and
# the bytes of `sil` and `dil`, which only one names, as GNU as writes them.
@test def atomic_instructions_encode_at_every_width(t: &mut tester): void {
var a := assembly::new();
a.xchg(1, at(reg::rbx, 0), reg::rax); encodes(t, &mut a, "8603"); # xchg byte ptr [rbx], al
a.xchg(1, at(reg::rdi, 8), reg::rsi); encodes(t, &mut a, "40867708"); # xchg byte ptr [rdi+8], sil
a.xchg(2, at(reg::r12, 0), reg::rcx); encodes(t, &mut a, "6641870c24"); # xchg word ptr [r12], cx
a.xchg(4, at(reg::rbp, -16), reg::r9); encodes(t, &mut a, "44874df0"); # xchg dword ptr [rbp-16], r9d
a.lock_xadd(1, at(reg::rdx, 0), reg::rcx); encodes(t, &mut a, "f00fc00a"); # lock xadd byte ptr [rdx], cl
a.lock_xadd(1, at(reg::r13, 4), reg::rdi); encodes(t, &mut a, "f0410fc07d04"); # lock xadd byte ptr [r13+4], dil
a.lock_xadd(2, at(reg::rax, 0), reg::r10); encodes(t, &mut a, "66f0440fc110"); # lock xadd word ptr [rax], r10w
a.lock_xadd(4, at(reg::rsp, 8), reg::rdx); encodes(t, &mut a, "f00fc1542408"); # lock xadd dword ptr [rsp+8], edx
a.lock_xadd(8, at(reg::r15, 0), reg::rax); encodes(t, &mut a, "f0490fc107"); # lock xadd qword ptr [r15], rax
a.lock_cmpxchg(1, at(reg::rdx, 0), reg::rcx); encodes(t, &mut a, "f00fb00a"); # lock cmpxchg byte ptr [rdx], cl
a.lock_cmpxchg(1, at(reg::rcx, 0), reg::r8); encodes(t, &mut a, "f0440fb001"); # lock cmpxchg byte ptr [rcx], r8b
a.lock_cmpxchg(2, at(reg::rbx, 2), reg::rsi); encodes(t, &mut a, "66f00fb17302"); # lock cmpxchg word ptr [rbx+2], si
a.lock_cmpxchg(4, at(reg::rdi, 0), reg::rcx); encodes(t, &mut a, "f00fb10f"); # lock cmpxchg dword ptr [rdi], ecx
a.lock_cmpxchg(8, at(reg::r11, -8), reg::r14); encodes(t, &mut a, "f04d0fb173f8"); # lock cmpxchg qword ptr [r11-8], r14
a.lock_cmpxchg(8, amd64::absolute(0x400058), reg::rcx); encodes(t, &mut a, "f0480fb10c2558004000"); # lock cmpxchg qword ptr [0x400058], rcx
a.mfence(); encodes(t, &mut a, "0faef0"); # mfence
a.cmov(cc::less, reg::rcx, reg::rax); encodes(t, &mut a, "480f4cc8"); # cmovl rcx, rax
a.cmov(cc::above, reg::r9, reg::rdx); encodes(t, &mut a, "4c0f47ca"); # cmova r9, rdx
}
# A thread's own record, through `gs`, as GNU as writes it.
@test def a_threads_own_record_is_reached_through_gs(t: &mut tester): void {
var a := assembly::new();
a.alu_load(alu::cmp, reg::rax, own(8)); encodes(t, &mut a, "65483b042508000000"); # cmp rax, qword ptr gs:[8]
a.store(8, own(0x78), reg::rsp); encodes(t, &mut a, "654889242578000000"); # mov qword ptr gs:[0x78], rsp
a.load(8, false, reg::rax, own(0x18)); encodes(t, &mut a, "65488b042518000000"); # mov rax, qword ptr gs:[0x18]
a.store(8, own(0x40), reg::rbp); encodes(t, &mut a, "6548892c2540000000"); # mov qword ptr gs:[0x40], rbp
a.store_imm(own(0x78), 0); encodes(t, &mut a, "6548c704257800000000000000"); # mov qword ptr gs:[0x78], 0
a.alu_mem_imm(alu::cmp, own(0x58), 0); encodes(t, &mut a, "6548833c255800000000"); # cmp qword ptr gs:[0x58], 0
a.load(8, false, reg::r9, own(0x10)); encodes(t, &mut a, "654c8b0c2510000000"); # mov r9, qword ptr gs:[0x10]
}
@test def instructions_the_c_compiler_never_wrote_encode_as_well(t: &mut tester): void {
var a := assembly::new();
a.movsd_load(0, at(reg::rbp, -8)); encodes(t, &mut a, "f20f1045f8"); # movsd xmm0, qword ptr [rbp-8]
a.movsd_load(12, at(reg::rsp, 16)); encodes(t, &mut a, "f2440f10642410"); # movsd xmm12, qword ptr [rsp+16]
a.movsd_store(at(reg::rbp, -8), 3); encodes(t, &mut a, "f20f115df8"); # movsd qword ptr [rbp-8], xmm3
a.movsd_store(at(reg::r13, 0), 9); encodes(t, &mut a, "f2450f114d00"); # movsd qword ptr [r13+0], xmm9
a.movaps(2, 3); encodes(t, &mut a, "0f28d3"); # movaps xmm2, xmm3
a.movaps(10, 1); encodes(t, &mut a, "440f28d1"); # movaps xmm10, xmm1
a.movaps(4, 15); encodes(t, &mut a, "410f28e7"); # movaps xmm4, xmm15
a.xorpd(2, 0); encodes(t, &mut a, "660f57d0"); # xorpd xmm2, xmm0
a.xorpd(9, 0); encodes(t, &mut a, "66440f57c8"); # xorpd xmm9, xmm0
a.call_mem(at(reg::rbp, -24)); encodes(t, &mut a, "ff55e8"); # call qword ptr [rbp-24]
a.call_mem(amd64::absolute(0x400100)); encodes(t, &mut a, "ff142500014000"); # call qword ptr [0x400100]
a.call_mem(indexed(reg::rax, reg::r9, 8, 16)); encodes(t, &mut a, "42ff54c810"); # call qword ptr [rax+r9*8+16]
a.jmp_reg(reg::rax); encodes(t, &mut a, "ffe0"); # jmp rax
a.jmp_reg(reg::r11); encodes(t, &mut a, "41ffe3"); # jmp r11
a.jmp_mem(indexed(reg::none, reg::rdx, 8, 0x401000)); encodes(t, &mut a, "ff24d500104000"); # jmp qword [rdx*8+0x401000]
a.jmp_mem(indexed(reg::none, reg::r9, 8, 0x7f)); encodes(t, &mut a, "42ff24cd7f000000"); # jmp qword [r9*8+0x7f]
a.jmp_mem(at(reg::rax, 0)); encodes(t, &mut a, "ff20"); # jmp qword [rax]
a.store_imm_width(1, at(reg::rbp, -1), 7); encodes(t, &mut a, "c645ff07"); # mov byte ptr [rbp-1], 7
a.store_imm_width(2, at(reg::rbx, 2), 0x1234); encodes(t, &mut a, "66c743023412"); # mov word ptr [rbx+2], 0x1234
a.store_imm_width(4, at(reg::r12, 4), 0x12345678); encodes(t, &mut a, "41c744240478563412"); # mov dword ptr [r12+4], 0x12345678
a.store_imm_width(8, at(reg::rbp, -16), 0xFFFFFFFFFFFFFFFF); encodes(t, &mut a, "48c745f0ffffffff"); # mov qword ptr [rbp-16], -1
a.cmov(cc::equal, reg::rax, reg::rcx); encodes(t, &mut a, "480f44c1"); # cmove rax, rcx
a.cmov(cc::less, reg::r11, reg::r9); encodes(t, &mut a, "4d0f4cd9"); # cmovl r11, r9
a.cmov(cc::above_equal, reg::rsi, reg::r14); encodes(t, &mut a, "490f43f6"); # cmovae rsi, r14
a.imul_load(reg::rax, at(reg::rbp, -8)); encodes(t, &mut a, "480faf45f8"); # imul rax, qword ptr [rbp-8]
a.imul_load(reg::r10, at(reg::r13, 8)); encodes(t, &mut a, "4d0faf5508"); # imul r10, qword ptr [r13+8]
a.test_mem(at(reg::rbp, -8), reg::rax); encodes(t, &mut a, "488545f8"); # test qword ptr [rbp-8], rax
a.test_mem(at(reg::r12, 0), reg::r9); encodes(t, &mut a, "4d850c24"); # test qword ptr [r12], r9
a.sse_load(sse::addsd, 2, at(reg::rbp, -8)); encodes(t, &mut a, "f20f5855f8"); # addsd xmm2, qword ptr [rbp-8]
a.sse_load(sse::mulsd, 11, at(reg::rsp, 8)); encodes(t, &mut a, "f2440f595c2408"); # mulsd xmm11, qword ptr [rsp+8]
a.alu_load(alu::cmp, reg::rax, at(reg::rbp, -8)); encodes(t, &mut a, "483b45f8"); # cmp rax, qword ptr [rbp-8]
a.alu_store(alu::cmp, at(reg::rbp, -16), reg::r10); encodes(t, &mut a, "4c3955f0"); # cmp qword ptr [rbp-16], r10
a.load(8, false, reg::rax, indexed(reg::rax, reg::rcx, 8, 0x400000)); encodes(t, &mut a, "488b84c800004000"); # mov rax, qword ptr [rax+rcx*8+0x400000]
a.lea(reg::rdx, indexed(reg::rcx, reg::rdx, 1, 0)); encodes(t, &mut a, "488d1411"); # lea rdx, [rcx+rdx*1]
a.lea(reg::r11, indexed(reg::r12, reg::r13, 2, 8)); encodes(t, &mut a, "4f8d5c6c08"); # lea r11, [r12+r13*2+8]
}
# Vector instructions: SSE's, with their mandatory prefixes and opcode maps, AVX's,
# with VEX prefixes of both lengths, and asking the processor what it has.
@test def vector_instructions_encode_as_a_reference_assembler_writes_them(t: &mut tester): void {
var a := assembly::new();
a.packed(vec_paddd, 9, 2); encodes(t, &mut a, "66440ffeca"); # paddd xmm9, xmm2
a.packed(vec_pminsb, 0, 12); encodes(t, &mut a, "66410f3838c4"); # pminsb xmm0, xmm12
a.packed_imm(vec_roundps, 1, 2, 9); encodes(t, &mut a, "660f3a08ca09"); # roundps xmm1, xmm2, 9
a.packed_imm(vec_cmpps, 3, 4, 2); encodes(t, &mut a, "0fc2dc02"); # cmpleps xmm3, xmm4
a.packed(vec_movmskps, reg::rax as u32, 1); encodes(t, &mut a, "0f50c1"); # movmskps eax, xmm1
a.packed(vec_pmovmskb, reg::r9 as u32, 10); encodes(t, &mut a, "66450fd7ca"); # pmovmskb r9d, xmm10
a.packed_mem(vec_movdqu_load, 8, at(reg::rax, 16)); encodes(t, &mut a, "f3440f6f4010"); # movdqu xmm8, [rax+16]
a.packed_mem(vec_movdqu_store, 3, at(reg::r12, 0)); encodes(t, &mut a, "f3410f7f1c24"); # movdqu [r12], xmm3
a.packed_mem(vec_movd_load, 1, at(reg::rcx, 0)); encodes(t, &mut a, "660f6e09"); # movd xmm1, [rcx]
a.packed(vec_punpcklqdq, 2, 2); encodes(t, &mut a, "660f6cd2"); # punpcklqdq xmm2, xmm2
a.packed(vec_xorps | vec_doubles, 0, 1); encodes(t, &mut a, "660f57c1"); # xorpd xmm0, xmm1
a.packed(vec_pcmpgtq, 1, 9); encodes(t, &mut a, "66410f3837c9"); # pcmpgtq xmm1, xmm9
a.packed(vec_movdqa, 4, 11); encodes(t, &mut a, "66410f6fe3"); # movdqa xmm4, xmm11
a.vex(vec_paddd, true, 0, 1, 2); encodes(t, &mut a, "c5f5fec2"); # vpaddd ymm0, ymm1, ymm2
a.vex(vec_paddd, true, 8, 9, 10); encodes(t, &mut a, "c44135fec2"); # vpaddd ymm8, ymm9, ymm10
a.vex(vec_vfmadd231ps, true, 0, 1, 2); encodes(t, &mut a, "c4e275b8c2"); # vfmadd231ps ymm0, ymm1, ymm2
a.vex(vec_vfmadd231ps | vec_wide, false, 3, 4, 5); encodes(t, &mut a, "c4e2d9b8dd"); # vfmadd231pd xmm3, xmm4, xmm5
a.vex_mem(vec_movdqu_load, true, 0, at(reg::rax, 0)); encodes(t, &mut a, "c5fe6f00"); # vmovdqu ymm0, [rax]
a.vex_mem(vec_movdqu_store, true, 9, at(reg::r13, 8)); encodes(t, &mut a, "c4417e7f4d08"); # vmovdqu [r13+8], ymm9
a.vex_imm(vec_roundps, true, 0, 0, 0, 9); encodes(t, &mut a, "c4e37d08c009"); # vroundps ymm0, ymm0, 9
a.vex_imm(vec_cmpps, true, 3, 3, 1, 1); encodes(t, &mut a, "c5e4c2d901"); # vcmpltps ymm3, ymm3, ymm1
a.vex_imm(vec_vinsertf128, true, 2, 2, 2, 1); encodes(t, &mut a, "c4e36d18d201"); # vinsertf128 ymm2, ymm2, xmm2, 1
a.vex_mem_imm(vec_vinsertf128, true, 3, 3, at(reg::rbp, -48), 1); encodes(t, &mut a, "c4e365185dd001"); # vinsertf128 ymm3, ymm3, [rbp-48], 1
a.vex_mem_imm(vec_vinsertf128, true, 10, 10, at(reg::r9, 16), 1); encodes(t, &mut a, "c4432d18511001"); # vinsertf128 ymm10, ymm10, [r9+16], 1
a.vex_mem(vec_movdqu_load, false, 10, at(reg::r9, 0)); encodes(t, &mut a, "c4417a6f11"); # vmovdqu xmm10, [r9]
a.vex(vec_movmskps, true, reg::rax as u32, 0, 0); encodes(t, &mut a, "c5fc50c0"); # vmovmskps eax, ymm0
a.vex(vec_pmovmskb, true, reg::rax as u32, 0, 0); encodes(t, &mut a, "c5fdd7c0"); # vpmovmskb eax, ymm0
a.vex(vec_psllw, true, 0, 0, 1); encodes(t, &mut a, "c5fdf1c1"); # vpsllw ymm0, ymm0, xmm1
a.vex(vec_sqrtps | vec_doubles, true, 0, 0, 1); encodes(t, &mut a, "c5fd51c1"); # vsqrtpd ymm0, ymm1
a.vex(vec_pabsd, true, 1, 0, 2); encodes(t, &mut a, "c4e27d1eca"); # vpabsd ymm1, ymm2
a.vex(vec_pminud, true, 12, 12, 3); encodes(t, &mut a, "c4621d3be3"); # vpminud ymm12, ymm12, ymm3
a.cpuid(); encodes(t, &mut a, "0fa2"); # cpuid
a.xgetbv(); encodes(t, &mut a, "0f01d0"); # xgetbv
a.vzeroupper(); encodes(t, &mut a, "c5f877"); # vzeroupper
}
# Code for processors with AVX writes SSE's instructions with VEX, the operand
# an instruction merges into named again. Each was written by GNU as, but
# `vmovaps xmm5, xmm12` and `vmovdqa xmm7, xmm13`, which it writes as stores;
# the loads are as good, and objdump reads them back.
@test def sse_instructions_encode_with_vex_in_code_for_avx(t: &mut tester): void {
var a := assembly::new();
a.avx = true;
a.sse(sse::addsd, 5, 6); encodes(t, &mut a, "c5d358ee"); # vaddsd xmm5, xmm5, xmm6
a.sse(sse::sqrtsd, 5, 9); encodes(t, &mut a, "c4c15351e9"); # vsqrtsd xmm5, xmm5, xmm9
a.sse_load(sse::addsd, 10, at(reg::rbp, -16)); encodes(t, &mut a, "c52b5855f0"); # vaddsd xmm10, xmm10, [rbp-16]
a.movsd_load(5, at(reg::rbp, -8)); encodes(t, &mut a, "c5fb106df8"); # vmovsd xmm5, [rbp-8]
a.movsd_store(at(reg::rax, 8), 12); encodes(t, &mut a, "c57b116008"); # vmovsd [rax+8], xmm12
a.movq_to_xmm(5, reg::rax); encodes(t, &mut a, "c4e1f96ee8"); # vmovq xmm5, rax
a.movq_to_xmm(11, reg::r9); encodes(t, &mut a, "c441f96ed9"); # vmovq xmm11, r9
a.movq_from_xmm(reg::rax, 5); encodes(t, &mut a, "c4e1f97ee8"); # vmovq rax, xmm5
a.movq_from_xmm(reg::r10, 12); encodes(t, &mut a, "c441f97ee2"); # vmovq r10, xmm12
a.movaps(5, 12); encodes(t, &mut a, "c4c17828ec"); # vmovaps xmm5, xmm12
a.xorpd(5, 5); encodes(t, &mut a, "c5d157ed"); # vxorpd xmm5, xmm5, xmm5
a.ucomisd(5, 6); encodes(t, &mut a, "c5f92eee"); # vucomisd xmm5, xmm6
a.cvtsi2sd(5, reg::rax); encodes(t, &mut a, "c4e1d32ae8"); # vcvtsi2sd xmm5, xmm5, rax
a.cvtsi2sd(12, reg::r9); encodes(t, &mut a, "c4419b2ae1"); # vcvtsi2sd xmm12, xmm12, r9
a.cvttsd2si(reg::rax, 5); encodes(t, &mut a, "c4e1fb2cc5"); # vcvttsd2si rax, xmm5
a.cvttsd2si(reg::r11, 13); encodes(t, &mut a, "c441fb2cdd"); # vcvttsd2si r11, xmm13
a.cvtsd2ss(0, 5); encodes(t, &mut a, "c5fb5ac5"); # vcvtsd2ss xmm0, xmm0, xmm5
a.cvtss2sd(5, 5); encodes(t, &mut a, "c5d25aed"); # vcvtss2sd xmm5, xmm5, xmm5
a.movss_load(5, at(reg::rax, 0)); encodes(t, &mut a, "c5fa1028"); # vmovss xmm5, [rax]
a.movss_store(at(reg::rbx, 4), 0); encodes(t, &mut a, "c5fa114304"); # vmovss [rbx+4], xmm0
a.packed(vec_paddb, 5, 6); encodes(t, &mut a, "c5d1fcee"); # vpaddb xmm5, xmm5, xmm6
a.packed_mem(vec_movdqu_load, 5, at(reg::rax, 0)); encodes(t, &mut a, "c5fa6f28"); # vmovdqu xmm5, [rax]
a.packed_mem(vec_movdqu_store, 9, at(reg::r12, 16)); encodes(t, &mut a, "c4417a7f4c2410"); # vmovdqu [r12+16], xmm9
a.packed(vec_pmovmskb, reg::rax as u32, 5); encodes(t, &mut a, "c5f9d7c5"); # vpmovmskb eax, xmm5
a.packed(vec_sqrtps, 5, 6); encodes(t, &mut a, "c5f851ee"); # vsqrtps xmm5, xmm6
a.packed_imm(vec_roundps, 5, 6, 9); encodes(t, &mut a, "c4e37908ee09"); # vroundps xmm5, xmm6, 9
a.packed_imm(vec_cmpps, 5, 6, 1); encodes(t, &mut a, "c5d0c2ee01"); # vcmpltps xmm5, xmm5, xmm6
a.packed(vec_pabsb, 5, 6); encodes(t, &mut a, "c4e2791cee"); # vpabsb xmm5, xmm6
a.packed(vec_movdqa, 7, 13); encodes(t, &mut a, "c4c1796ffd"); # vmovdqa xmm7, xmm13
}
@test def relative_branches_are_patched_to_their_targets(t: &mut tester): void {
var a := assembly::new();
val jump := a.jcc(cc::equal);
a.ret();
val target := a.length;
val call := a.call();
a.patch(jump, target);
a.patch(call, 0);
# `je +1` over the `ret`, then `call` back to the start.
val expected: u8[12] = [0x0F, 0x84, 0x01, 0x00, 0x00, 0x00, 0xC3, 0xE8, 0xF4, 0xFF, 0xFF, 0xFF];
var same := a.bytes.length == 12;
for i in 0..12u {
same = same && i < a.bytes.length && a.bytes.get_byte(i) == expected[i];
}
t.expects(same);
}
+122
View File
@@ -0,0 +1,122 @@
# Tests of DWARF's encodings: numbers, abbreviations, tables of strings, the
# headers of units and of lists, line programs and the header naming their
# files, and descriptions of frames and their instructions.
import std::io;
import binary::dwarf;
import std::testing;
# The bytes as hex.
def hex_of(bytes: span<u8>): string {
val digits: strview = "0123456789abcdef";
var made := string::new(nothing {});
for &each in bytes {
made.append(digits.substr((each >> 4) as u64, 1));
made.append(digits.substr((each & 15) as u64, 1));
}
return made;
}
def uleb_hex(value: u64): string {
var made := byte_writer::new();
dwarf::uleb(&mut made, value);
return hex_of(made.span);
}
def sleb_hex(value: i64): string {
var made := byte_writer::new();
dwarf::sleb(&mut made, value);
return hex_of(made.span);
}
@test def numbers_take_as_few_bytes_of_seven_bits_as_hold_them(t: &mut tester): void {
t.expects(uleb_hex(0).span == "00");
t.expects(uleb_hex(127).span == "7f");
t.expects(uleb_hex(128).span == "8001");
t.expects(uleb_hex(624485).span == "e58e26");
t.expects(sleb_hex(0).span == "00");
t.expects(sleb_hex(-1).span == "7f");
t.expects(sleb_hex(63).span == "3f");
t.expects(sleb_hex(64).span == "c000");
t.expects(sleb_hex(-128).span == "807f");
t.expects(sleb_hex(-123456).span == "c0bb78");
}
@test def abbreviations_strings_and_headers_are_as_dwarf_writes_them(t: &mut tester): void {
var abbrev := byte_writer::new();
val pairs: u64[4] = [dwarf::dw_at_producer, dwarf::dw_form_strp, dwarf::dw_at_language, dwarf::dw_form_data2];
dwarf::abbreviation(&mut abbrev, 1, dwarf::dw_tag_compile_unit, true, pairs[:]);
t.expects(hex_of(abbrev.span).span == "011101250e13050000");
var strings := dwarf::string_table::new();
t.expects(strings.offset_of("a") == 0 && strings.offset_of("bc") == 2 && strings.offset_of("a") == 0);
t.expects(hex_of(strings.bytes.span).span == "6100626300");
var info := byte_writer::new();
val unit := dwarf::begin_unit(&mut info, dwarf::dw_ut_compile, 8, 0);
info.byte(0);
info.end_length(unit);
t.expects(hex_of(info.span).span == "09000000050001080000000000");
var lists := byte_writer::new();
val list := dwarf::begin_lists(&mut lists);
lists.end_length(list);
t.expects(hex_of(lists.span).span == "080000000500080000000000");
}
@test def a_line_program_writes_what_changes_from_row_to_row(t: &mut tester): void {
var program := dwarf::line_program::new();
program.begin(0x1000);
program.row(0, 1, 1, 0, false);
program.row(4, 1, 3, 5, true);
program.row(10, 2, 3, 5, false);
program.end(16);
var expected := string::new(nothing {});
expected.append("0009020010000000000000"); # The sequence's address,
expected.append("01"); # the first row, as a program begins,
expected.append("0505030202040a01"); # a column, two lines, four bytes on, the prologue's end,
expected.append("0402020601"); # another file, six bytes on,
expected.append("0206000101"); # and the end, six bytes on.
t.expects(hex_of(program.bytes.span).span == expected.span, hex_of(program.bytes.span).span);
}
@test def the_line_tables_header_names_directories_and_files(t: &mut tester): void {
var strings := dwarf::string_table::new();
var table := byte_writer::new();
val paths: strview[2] = ["main.sakura", "/lib/x.sakura"];
val program: u8[1] = [0];
dwarf::write_line_table(&mut table, "/build", paths[:], &mut strings, program[:]);
# The build's directory, then the absolute path's, each file by its last part.
t.expects(hex_of(strings.bytes.span).span == "2f6275696c64002f6c6962006d61696e2e73616b75726100782e73616b75726100", hex_of(strings.bytes.span).span);
val all := table.span;
t.expects(all.length == 4 + table.get_u32(0) as u64);
t.expects(all[4] == 5 && all[5] == 0 && all[6] == 8 && all[7] == 0);
# Three files: the main one numbered 0 and 1, each with its directory.
val tail := all.length;
t.expects(all[tail - 1] == 0);
t.expects(all[tail - 2] == 1 && all[tail - 7] == 0 && all[tail - 12] == 0);
}
@test def frames_are_described_from_a_common_entry(t: &mut tester): void {
var frame := byte_writer::new();
val cie := dwarf::begin_cie(&mut frame, 1, -8, dwarf::amd64_return_address);
dwarf::cfa_def_cfa(&mut frame, dwarf::amd64_rsp, 8);
dwarf::cfa_offset(&mut frame, dwarf::amd64_return_address as u8, 1);
dwarf::end_entry(&mut frame, cie);
t.expects(hex_of(frame.span).span == "14000000ffffffff040008000178100c0708900100000000", hex_of(frame.span).span);
var described := byte_writer::new();
val fde := dwarf::begin_fde(&mut described, 0, 0x401000, 0x20);
var at: u64 = 0;
dwarf::cfa_advance(&mut described, &mut at, 1);
dwarf::cfa_def_cfa_offset(&mut described, 16);
dwarf::end_entry(&mut described, fde);
t.expects(hex_of(described.span).span == "1c0000000000000000104000000000002000000000000000410e100000000000", hex_of(described.span).span);
# Moves past what a byte of the instruction holds take bytes of their own.
var moves := byte_writer::new();
var from: u64 = 0;
dwarf::cfa_advance(&mut moves, &mut from, 0x40);
dwarf::cfa_advance(&mut moves, &mut from, 0x140);
dwarf::cfa_advance(&mut moves, &mut from, 0x10140);
t.expects(from == 0x10140 && hex_of(moves.span).span == "02400300010400000100", hex_of(moves.span).span);
}
+104
View File
@@ -0,0 +1,104 @@
# Tests of ELF files: an executable's headers, segments, and sections, its
# symbols, the machine it is for, the note naming its build, the file
# describing its segments without holding them, and the checksum of a link.
import binary::elf;
import std::testing;
# A word of bytes, least significant byte first.
def word(bytes: span<u8>, at: u64, size: u64): u64 {
var made: u64 = 0;
for k in 0..size {
made = made | (bytes[at + k] as u64 << (8 * k));
}
return made;
}
# Whether a section, by its number, is named so in the table of section names.
def section_named(file: span<u8>, k: u64, name: strview): bool {
val headers := word(file, 0x28, 8);
val names := headers + 64 * word(file, 0x3E, 2);
val at := word(file, names + 24, 8) + word(file, headers + 64 * k, 4);
for i in 0..name.length {
return false if file[at + i] != name[i];
}
return file[at + name.length] == 0;
}
# An executable of code and data, the code loaded with the headers.
def small_image(code: span<u8>): elf::image {
val headers := elf::headers_size(2, false);
var made := elf::image::new(0x400000 + headers);
made.segment(".text", 0x400000, 0, code, code.length, elf::readable | elf::executable, true);
made.segment(".data", 0x401000, 0x1000, "data", 4, elf::readable | elf::writable, false);
made.symbols.append(elf::symbol { name = "_start", address = 0x400000 + headers, size = code.length });
return made;
}
@test def an_executable_holds_its_segments_and_names_them(t: &mut tester): void {
val code: u8[3] = [0x31, 0xC0, 0xC3];
var image := small_image(code[:]);
image.build_id();
val bytes := image.file();
val all := bytes.span;
t.expects(all[0] == 0x7F && all[1] == 'E' as u8 && all[2] == 'L' as u8 && all[3] == 'F' as u8);
t.expects(all[4] == 2 && all[5] == 1 && word(all, 16, 2) == 2 && word(all, 18, 2) == 62);
t.expects(word(all, 24, 8) == 0x400000 + 64 + 2 * 56);
t.expects(word(all, 0x38, 2) == 2);
# The first segment holds the headers, then the code just past them.
val headers := elf::headers_size(2, false);
t.expects(headers == 64 + 2 * 56);
t.expects(word(all, 64, 4) == 1 && word(all, 64 + 4, 4) == 5 && word(all, 64 + 32, 8) == headers + 3);
t.expects(all[headers] == 0x31 && all[headers + 2] == 0xC3);
t.expects(word(all, 64 + 56 + 8, 8) == 0x1000 && all[0x1000] == 'd' as u8);
# The sections: none, each segment's, the note, then the tables.
val count := word(all, 0x3C, 2);
t.expects(count == 7 && word(all, 0x3E, 2) == 6);
val names: strview[7] = ["", ".text", ".data", ".note.gnu.build-id", ".symtab", ".strtab", ".shstrtab"];
for k in 0..7u {
t.expects(section_named(all, k, names[k]), names[k]);
}
}
@test def the_machine_is_the_one_given(t: &mut tester): void {
val code: u8[1] = [0xC3];
var image := small_image(code[:]);
image.machine = 183;
val bytes := image.file();
t.expects(word(bytes.span, 18, 2) == 183);
}
@test def the_build_is_named_by_what_it_loads(t: &mut tester): void {
val code: u8[3] = [0x31, 0xC0, 0xC3];
var first := small_image(code[:]);
first.build_id();
var again := small_image(code[:]);
again.build_id();
val other_code: u8[3] = [0x31, 0xC0, 0xC2];
var other := small_image(other_code[:]);
other.build_id();
val note := first.sections[0].data.span;
t.expects(note.length == 36 && word(note, 0, 4) == 4 && word(note, 4, 4) == elf::build_id_bytes && word(note, 8, 4) == 3);
t.expects(note == again.sections[0].data.span);
t.expects(note != other.sections[0].data.span);
}
@test def a_described_file_holds_no_segment(t: &mut tester): void {
val code: u8[3] = [0x31, 0xC0, 0xC3];
var image := small_image(code[:]);
image.described = true;
val bytes := image.file();
val all := bytes.span;
# Its segments are described, holding nothing in the file, as are their sections.
t.expects(word(all, 64 + 32, 8) == 0 && word(all, 64 + 40, 8) == elf::headers_size(2, false) + 3);
val headers := word(all, 0x28, 8);
t.expects(word(all, headers + 64 + 4, 4) == 8);
t.expects(all.length < 0x1000);
}
@test def links_are_checked_as_zlib_checks_them(t: &mut tester): void {
t.expects(elf::crc32("123456789") == 0xCBF43926);
t.expects(elf::crc32("") == 0);
}
+14
View File
@@ -0,0 +1,14 @@
# Runs the tests of one library, those in its folder beside this file. From the
# root of the repository, those of `binary::amd64`:
#
# sakurac run --lib binary::amd64=amd64 tests/main.sakura tests/amd64/*.sakura
#
# Add `-- --only TEXT` to run those whose name holds the text, and `-- --here` to
# run them in one program, as a debugger wants. Built with `sakurac build`, they
# run as an executable the same way.
import system;
import std::testing;
def main(args: span<strview>): void {
exit(tester::run(args));
}
+138
View File
@@ -0,0 +1,138 @@
# Tests of a whole PDB file, read back as a debugger reads one: the MSF file's
# description and map of free blocks, the stream naming the file and its map
# of named streams, the stream of modules and its numbers of the others, the
# table of names, and the GUID made from what the file holds.
import std::io;
import binary::pdb;
import std::testing;
# A small file: a type, a module with a procedure and its lines, the linker's,
# a public, the global naming the procedure, and two sections.
def small_file(public_name: strview): pdb::writer {
var made := pdb::writer::new();
val arguments := made.types.arguments(span::<u32>::blank());
val procedure := made.types.procedure(pdb::t_void, arguments, 0);
var symbols := pdb::symbol_stream::new();
symbols.object_name("main.sakura");
val version: u16[3] = [1, 0, 0];
symbols.compiler(pdb::language_cxx, pdb::cv_machine_x64, version, "sakura");
val at := symbols.procedure(true, "main", procedure, 2, 0, 16, 4, 15, pdb::proc_has_frame_pointer);
symbols.end();
var sums := pdb::file_checksums::new();
val file := sums.file(made.names.offset_of("/src/main.sakura"));
var lines := pdb::function_lines::new(2, 0, 16);
lines.line(file, 0, 1, 1);
lines.finish();
var subsections := byte_writer::new();
pdb::subsection(&mut subsections, pdb::debug_s_lines, lines.bytes.span);
pdb::subsection(&mut subsections, pdb::debug_s_file_checksums, sums.bytes.span);
val files: strview[1] = ["/src/main.sakura"];
val ours := made.add_module("main.sakura", "main.sakura", &mut symbols.bytes, &mut subsections, files[:]);
var linker := pdb::symbol_stream::new();
linker.object_name("* Linker *");
var none := byte_writer::new();
_ = made.add_module("* Linker *", "", &mut linker.bytes, &mut none, span::<strview>::blank());
# Two sections' headers: data, then code.
val names: strview[2] = [".data", ".text"];
val characteristics: u32[2] = [0xC0000040, 0x60000020];
for k in 0..2u {
for i in 0..8u {
made.sections.byte(i < names[k].length ? names[k][i] : 0);
}
made.sections.u32(16); # Its virtual size,
made.sections.u32(0x1000 * (k + 1)); # address,
made.sections.u32(0x1000); # bytes in the file,
made.sections.u32(0x1000 * (k + 1)); # and where.
made.sections.zeros(12);
made.sections.u32(characteristics[k]);
}
made.contribute(ours, 2, 0, 16, 0x60000020);
made.public(public_name, 2, 0, pdb::public_function | pdb::public_code);
made.procedure("main", ours, at, true);
return made;
}
@test def the_file_is_an_msf_file_of_blocks(t: &mut tester): void {
var made := small_file("main");
val bytes := made.file();
val all := bytes.span;
val magic: strview = "Microsoft C/C++ MSF 7.00\r\n";
t.expects(holds_at(all, 0, magic));
t.expects(all[26] == 0x1A && all[27] == 'D' as u8 && all[28] == 'S' as u8);
t.expects(word(all, 32, 4) == 4096 && word(all, 36, 4) == 1);
t.expects(word(all, 40, 4) * 4096 == all.length);
t.expects(stream_count(all) == 14);
# The map of free blocks says each block the file holds is taken, and those
# past them free.
val blocks := word(all, 40, 4);
for b in 0..blocks {
t.expects((all[4096 + b / 8] & (1u << (b % 8)) as u8) == 0);
}
t.expects((all[4096 + blocks / 8] & (1u << (blocks % 8)) as u8) != 0);
}
@test def the_file_is_named_by_its_guid_and_age(t: &mut tester): void {
var made := small_file("main");
val bytes := made.file();
val info := stream_of(bytes.span, 1);
val held := info.span;
t.expects(word(held, 0, 4) == 20000404);
t.expects(word(held, 4, 4) == made.signature as u64 && word(held, 8, 4) == 1);
var named := false;
for k in 0..16u {
t.expects(held[12 + k] == made.guid[k]);
named = named || made.guid[k] != 0;
}
t.expects(named);
# The map of named streams names `/names`, in its hash's bucket of eight; the
# table follows the name's seven bytes.
t.expects(word(held, 28, 4) == 7 && holds_at(held, 32, "/names"));
t.expects(word(held, 39, 4) == 1 && word(held, 43, 4) == 8 && word(held, 47, 4) == 1);
t.expects(word(held, 51, 4) == (1u << ((pdb::hash_v1("/names") & 0xFFFF) % 8)) as u64);
t.expects(word(held, 55, 4) == 0 && word(held, 59, 4) == 0 && word(held, 63, 4) == 5);
t.expects(word(held, 67, 4) == 20140508 && held.length == 71);
# The same build names its file the same way, and another another.
var again := small_file("main");
val same := again.file();
t.expects(same.span == bytes.span);
var other := small_file("start");
_ = other.file();
t.expects(other.signature != made.signature);
}
@test def the_stream_of_modules_numbers_the_others(t: &mut tester): void {
var made := small_file("main");
val bytes := made.file();
val dbi := stream_of(bytes.span, 3);
val held := dbi.span;
t.expects(word(held, 0, 4) == 0xFFFFFFFF && word(held, 4, 4) == 19990903 && word(held, 8, 4) == 1);
t.expects(word(held, 12, 2) == 8 && word(held, 16, 2) == 9 && word(held, 20, 2) == 10);
t.expects(word(held, 58, 2) == 0x8664);
# The headers of the executable's sections are the stream the debugging
# headers name.
val end := held.length;
t.expects(word(held, end - 22 + 10, 2) == 11);
val sections := stream_of(bytes.span, 11);
t.expects(sections.span == made.sections.span);
# The first module's stream holds its symbols then its lines.
val first := stream_of(bytes.span, 12);
t.expects(word(first.span, 0, 4) == 4 && word(first.span, 6, 2) == pdb::s_objname as u64);
}
@test def names_are_found_by_their_hash(t: &mut tester): void {
var made := small_file("main");
val bytes := made.file();
val names := stream_of(bytes.span, 5);
val held := names.span;
t.expects(word(held, 0, 4) == 0xEFFEEFFE && word(held, 4, 4) == 1);
val size := word(held, 8, 4);
val buckets := word(held, 12 + size, 4);
val wanted: strview = "/src/main.sakura";
var slot := pdb::hash_v1(wanted) as u64 % buckets;
val offset := word(held, 16 + size + 4 * slot, 4);
t.expects(offset != 0 && holds_at(held, 12 + offset, wanted));
t.expects(word(held, 16 + size + 4 * buckets, 4) == 1);
}
+51
View File
@@ -0,0 +1,51 @@
# Tests of the hashes a PDB file finds names and records by, against the values
# Microsoft's algorithms give, and of the digest naming a file.
import binary::pdb;
import std::testing;
@test def names_hash_as_microsofts_tools_hash_them(t: &mut tester): void {
# Words, then a half word, then a byte, cases made alike.
t.expects(pdb::hash_v1("") == 0x20240400);
t.expects(pdb::hash_v1("a") == 0x20240441);
t.expects(pdb::hash_v1("ab") == 0x20244649);
t.expects(pdb::hash_v1("abc") == 0x2024460A);
t.expects(pdb::hash_v1("abcd") == 0x646F8A62);
t.expects(pdb::hash_v1("abcde") == 0x646F8A27);
t.expects(pdb::hash_v1("/names") == 0x6D6CFC21);
t.expects(pdb::hash_v1("main") == 0x6E64C225);
t.expects(pdb::hash_v1("MAIN") == pdb::hash_v1("main"));
}
@test def records_hash_by_crc_begun_at_zero(t: &mut tester): void {
t.expects(pdb::hash_record("123456789") == 0x2DFD2D88);
t.expects(pdb::hash_record("") == 0);
}
@test def files_are_named_by_their_md5(t: &mut tester): void {
val digest := pdb::md5_of("abc");
val expected: u8[16] = [0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72];
var same := true;
for k in 0..16u {
same = same && digest[k] == expected[k];
}
t.expects(same);
val empty := pdb::md5_of("");
t.expects(empty[0] == 0xd4 && empty[15] == 0x7e); # d41d8cd98f00b204e9800998ecf8427e
}
@test def registers_are_numbered_as_codeview_numbers_them(t: &mut tester): void {
t.expects(pdb::amd64_register(0, 8) == 328); # rax
t.expects(pdb::amd64_register(3, 8) == 329); # rbx
t.expects(pdb::amd64_register(5, 8) == 334); # rbp
t.expects(pdb::amd64_register(6, 8) == 332); # rsi
t.expects(pdb::amd64_register(15, 8) == 343); # r15
t.expects(pdb::amd64_register(1, 4) == 18); # ecx
t.expects(pdb::amd64_register(9, 4) == 361); # r9d
t.expects(pdb::amd64_register(2, 2) == 11); # dx
t.expects(pdb::amd64_register(7, 1) == 325); # dil
t.expects(pdb::amd64_register(12, 1) == 348); # r12b
t.expects(pdb::amd64_xmm(0) == 154);
t.expects(pdb::amd64_xmm(7) == 161);
t.expects(pdb::amd64_xmm(8) == 252);
}
+54
View File
@@ -0,0 +1,54 @@
# Tests of a module's lines: the blocks of each file's lines with their
# columns, the subsections holding them, and the annotations of inline sites.
import std::io;
import binary::pdb;
import std::testing;
@test def lines_are_written_in_a_block_for_each_file(t: &mut tester): void {
var lines := pdb::function_lines::new(1, 0x10, 0x20);
lines.line(0, 0, 3, 5);
lines.line(0, 8, 4, 1);
lines.line(8, 12, 9, 2);
lines.finish();
var expected := string::new(nothing {});
expected.append("100000000100010020000000"); # Where the code is, with columns,
expected.append("000000000200000024000000000000000300008008000000040000800500000001000000"); # the first file's,
expected.append("0800000001000000180000000c0000000900008002000000"); # and the second's.
t.expects(hex_of(lines.bytes.span).span == expected.span, hex_of(lines.bytes.span).span);
var section := byte_writer::new();
pdb::subsection(&mut section, pdb::debug_s_lines, "abc");
t.expects(hex_of(section.span).span == "f20000000300000061626300");
}
@test def files_are_named_by_where_their_entries_are(t: &mut tester): void {
var sums := pdb::file_checksums::new();
t.expects(sums.file(1) == 0 && sums.file(9) == 8);
t.expects(hex_of(sums.bytes.span).span == "01000000000000000900000000000000");
var inlinees := pdb::inlinee_lines::new();
inlinees.add(0x1000, 8, 42);
t.expects(inlinees.count == 1 && hex_of(inlinees.bytes.span).span == "0000000000100000080000002a000000");
}
@test def annotations_say_each_part_of_a_site_and_its_line(t: &mut tester): void {
var notes := pdb::annotations::new(0, 10);
# The first part, of the line the function begins at, says it is.
notes.at_line(0x20, 0, 10);
t.expects(hex_of(notes.bytes.span).span == "06000320");
# A near part a near line on is one annotation.
notes.at_line(0x24, 0, 12);
# A part of the same line goes on.
notes.at_line(0x26, 0, 12);
# Code not the site's ends the part, then a part of another file follows.
notes.away(0x30);
notes.at_line(0x40, 8, 11);
notes.finish(0x48);
t.expects(hex_of(notes.bytes.span).span == "060003200b44040c0508060303100408");
# Lengths and offsets past seven bits take two bytes.
var far := pdb::annotations::new(0, 1);
far.at_line(0x1234, 0, 1);
far.finish(0x1240);
t.expects(hex_of(far.bytes.span).span == "0600039234040c");
}
+129
View File
@@ -0,0 +1,129 @@
# Tests of type records and symbols: numbers as numeric leaves, records padded
# to four bytes, records added twice held once but functions' IDs, field lists
# too long for one record going on in another, the header of a stream of types,
# and scopes naming where they end.
import std::io;
import binary::pdb;
import std::testing;
# The bytes a number is written as.
def unsigned_hex(value: u64): string {
var made := byte_writer::new();
pdb::put_unsigned(&mut made, value);
return hex_of(made.span);
}
def signed_hex(value: i64): string {
var made := byte_writer::new();
pdb::put_signed(&mut made, value);
return hex_of(made.span);
}
@test def numbers_are_written_as_numeric_leaves(t: &mut tester): void {
t.expects(unsigned_hex(0x7FFF).span == "ff7f");
t.expects(unsigned_hex(0x8000).span == "02800080");
t.expects(unsigned_hex(0x12345).span == "048045230100");
t.expects(unsigned_hex(0x123456789).span == "0a808967452301000000");
t.expects(signed_hex(5).span == "0500");
t.expects(signed_hex(-1).span == "0080ff");
t.expects(signed_hex(-200).span == "018038ff");
t.expects(signed_hex(-100000).span == "03806079feff");
}
@test def type_records_are_padded_and_held_once(t: &mut tester): void {
var table := pdb::type_table::new();
val pointer := table.pointer(pdb::t_int4, false);
t.expects(pointer == pdb::first_type);
t.expects(hex_of(table.records.span).span == "0a000210740000000c000100");
val again := table.pointer(pdb::t_int4, false);
t.expects(again == pointer && table.count == 1);
# A reference, and an array, whose name's zero is padded by `LF_PAD1`.
val reference := table.pointer(pdb::t_int4, true);
t.expects(reference == pdb::first_type + 1);
val array := table.array(pdb::t_int4, 16);
t.expects(array == pdb::first_type + 2);
val bytes := table.records.span;
t.expects(hex_of(span::<u8>::over(bytes.data + 24, 16)).span == "0e0003157400000023000000100000f1");
# Each function's ID is its own, though two are alike.
var ids := pdb::type_table::new();
val first := ids.function_id(0, 0x1001, "write_all");
val second := ids.function_id(0, 0x1001, "write_all");
t.expects(first != second && ids.count == 2);
}
@test def a_long_field_list_goes_on_in_a_record_before_it(t: &mut tester): void {
var table := pdb::type_table::new();
var list := pdb::field_list::new();
val name: strview = "a_member_whose_name_is_long_enough_to_fill_the_record";
for k in 0..1200u {
list.member(pdb::t_int8, 8 * k, name);
}
t.expects(list.count == 1200);
val fields := table.fields(&list);
t.expects(table.count == 2 && fields == pdb::first_type + 1);
# The second record, added last, is the list's first, and ends naming the
# one it goes on in.
val all := table.records.span;
val second := word(all, 0, 2) + 2;
val length := word(all, second, 2);
t.expects(length <= 0xFF00);
val end := second + 2 + length;
t.expects(word(all, end - 8, 2) == pdb::lf_index as u64 && word(all, end - 4, 4) == pdb::first_type as u64);
}
@test def a_stream_of_types_says_what_it_holds(t: &mut tester): void {
var table := pdb::type_table::new();
_ = table.pointer(pdb::t_void, false);
val named := table.structure("point", "sakura@1", 0, 0, 0, true);
val stream := table.stream(6);
val bytes := stream.span;
t.expects(word(bytes, 0, 4) == 20040203 && word(bytes, 4, 4) == 56);
t.expects(word(bytes, 8, 4) == 0x1000 && word(bytes, 12, 4) == 0x1002);
t.expects(word(bytes, 16, 4) == table.records.length && word(bytes, 20, 2) == 6);
t.expects(word(bytes, 28, 4) == 0x3FFFF);
t.expects(bytes.length == 56 + table.records.length);
# A declaration is hashed by its bytes, a definition by its name, so the one
# finds the other.
val complete := table.structure("point", "sakura@1", 0, 0, 16, false);
val hashes := table.hash_stream();
val held := hashes.span;
t.expects(named == 0x1001 && complete == 0x1002);
t.expects(word(held, 8, 4) == (pdb::hash_v1("point") % 0x3FFFF) as u64);
t.expects(word(held, 4, 4) != word(held, 8, 4));
# The first record's index and offset, which a reader begins from.
t.expects(word(held, 12, 4) == 0x1000 && word(held, 16, 4) == 0);
}
@test def scopes_name_where_they_begin_and_end(t: &mut tester): void {
var symbols := pdb::symbol_stream::new();
val proc := symbols.procedure(true, "main", 0x1001, 3, 0x40, 0x20, 4, 0x1F, pdb::proc_has_frame_pointer);
t.expects(proc == 4);
symbols.block(3, 0x48, 8);
val block := proc + word(symbols.bytes.span, proc, 2) + 2;
symbols.local(pdb::t_int8, 0, "x");
symbols.in_frame(-8, pdb::code_range { section = 3, offset = 0x48, length = 8 });
symbols.end();
val block_end := symbols.bytes.length - 4;
val notes: u8[6] = [6, 0, 3, 4, 4, 2];
symbols.inline_site(0x1000, notes[:]);
val site := block_end + 4;
symbols.end();
val site_end := symbols.bytes.length - 4;
symbols.end();
val proc_end := symbols.bytes.length - 4;
val all := symbols.bytes.span;
t.expects(word(all, 0, 4) == 4);
t.expects(word(all, proc + 2, 2) == pdb::s_gproc32 as u64 && word(all, proc + 4, 4) == 0 && word(all, proc + 8, 4) == proc_end);
t.expects(word(all, block + 2, 2) == pdb::s_block32 as u64 && word(all, block + 4, 4) == proc && word(all, block + 8, 4) == block_end);
t.expects(word(all, site + 4, 4) == proc && word(all, site + 8, 4) == site_end);
t.expects(word(all, block_end + 2, 2) == pdb::s_end as u64);
t.expects(word(all, site_end + 2, 2) == pdb::s_inlinesite_end as u64);
t.expects(word(all, proc_end + 2, 2) == pdb::s_end as u64);
# Every record is padded to four bytes.
t.expects(all.length % 4 == 0);
}
+88
View File
@@ -0,0 +1,88 @@
# What the tests share: reading words of bytes, and reading a stream back out
# of an MSF file, as a debugger does.
import std::io;
import binary::pdb;
import std::testing;
# A word of bytes, least significant byte first.
def word(bytes: span<u8>, at: u64, size: u64): u64 {
var made: u64 = 0;
for k in 0..size {
made = made | (bytes[at + k] as u64 << (8 * k));
}
return made;
}
# Whether bytes hold text at a place.
def holds_at(bytes: span<u8>, at: u64, text: strview): bool {
return false if at + text.length > bytes.length;
for k in 0..text.length {
return false if bytes[at + k] != text[k];
}
return true;
}
# The bytes as hex, as the tests write what they expect.
def hex_of(bytes: span<u8>): string {
val digits: strview = "0123456789abcdef";
var made := string::new(nothing {});
for &each in bytes {
made.append(digits.substr((each >> 4) as u64, 1));
made.append(digits.substr((each & 15) as u64, 1));
}
return made;
}
# How many streams an MSF file holds.
def stream_count(file: span<u8>): u64 {
val directory := directory_of(file);
return word(directory.span, 0, 4);
}
# The directory of an MSF file, gathered from the blocks the block map names.
def directory_of(file: span<u8>): byte_writer {
val block := word(file, 32, 4);
val size := word(file, 44, 4);
val map := word(file, 52, 4);
var made := byte_writer::new();
var left := size;
var k: u64 = 0;
while left > 0 {
val at := word(file, map * block + 4 * k, 4) * block;
val take := left < block ? left : block;
for i in 0..take {
made.byte(file[at + i]);
}
left -= take;
k++;
}
return made;
}
# A stream of an MSF file, gathered from its blocks.
def stream_of(file: span<u8>, number: u64): byte_writer {
val block := word(file, 32, 4);
val directory := directory_of(file);
val names := directory.span;
val count := word(names, 0, 4);
var at := 4 + 4 * count;
for s in 0..number {
val size := word(names, 4 + 4 * s, 4);
at += 4 * ((size + block - 1) / block);
}
val size := word(names, 4 + 4 * number, 4);
var made := byte_writer::new();
var left := size;
var k: u64 = 0;
while left > 0 {
val from := word(names, at + 4 * k, 4) * block;
val take := left < block ? left : block;
for i in 0..take {
made.byte(file[from + i]);
}
left -= take;
k++;
}
return made;
}
+162
View File
@@ -0,0 +1,162 @@
# Tests of PE files: the headers and sections of an executable, a long name in
# the table of strings, the data directories, how functions unwind, and the
# debug directory naming a PDB file, stamped with its GUID once it is written.
import std::io;
import binary::pe;
import std::testing;
# A word of bytes, least significant byte first.
def word(bytes: span<u8>, at: u64, size: u64): u64 {
var made: u64 = 0;
for k in 0..size {
made = made | (bytes[at + k] as u64 << (8 * k));
}
return made;
}
# The bytes as hex.
def hex_of(bytes: span<u8>): string {
val digits: strview = "0123456789abcdef";
var made := string::new(nothing {});
for &each in bytes {
made.append(digits.substr((each >> 4) as u64, 1));
made.append(digits.substr((each & 15) as u64, 1));
}
return made;
}
# Where a section's header is, by its number from 0.
def header_of(file: span<u8>, k: u64): u64 {
val pe := word(file, 0x3C, 4);
return pe + 24 + word(file, pe + 20, 2) + 40 * k;
}
@test def an_executable_holds_its_sections_where_they_load(t: &mut tester): void {
val code: u8[4] = [0x31, 0xC0, 0xC3, 0x90];
val data: u8[3] = [1, 2, 3];
var image := pe::image::new(0x400000, 0x402000);
image.stack_reserve = 0x100000;
image.stack_commit = 0x1000;
image.section(".data", 0x401000, data[:], 3, pe::readable | pe::writable);
image.section(".text", 0x402000, code[:], 4, pe::readable | pe::executable);
image.section(".empty", 0x403000, span::<u8>::blank(), 0, pe::readable);
image.section(".debug_info", 0x403000, data[:], 3, pe::readable | pe::discardable);
image.symbols.append(pe::symbol { name = "start", address = 0x402000 });
image.imports = pe::directory { address = 0x401000, size = 3 };
val bytes := image.file();
val all := bytes.span;
t.expects(all[0] == 'M' as u8 && all[1] == 'Z' as u8);
val pe := word(all, 0x3C, 4);
t.expects(word(all, pe, 4) == 0x4550 && word(all, pe + 4, 2) == 0x8664);
# The empty section is left out.
t.expects(word(all, pe + 6, 2) == 3);
val o := pe + 24;
t.expects(word(all, o, 2) == 0x20B && word(all, o + 16, 4) == 0x2000 && word(all, o + 24, 8) == 0x400000);
t.expects(word(all, o + 68, 2) == 3 && word(all, o + 56, 4) == 0x4000);
t.expects(word(all, o + 112 + 8, 4) == 0x1000 && word(all, o + 116 + 8, 4) == 3);
# Each section is where its address says, page for page, with its permissions.
val text := header_of(all, 1);
t.expects(word(all, text + 12, 4) == 0x2000 && word(all, text + 8, 4) == 4);
t.expects(word(all, text + 36, 4) == 0x60000020);
val at := word(all, text + 20, 4);
t.expects(all[at] == 0x31 && all[at + 2] == 0xC3);
t.expects(word(all, header_of(all, 0) + 36, 4) == 0xC0000040);
t.expects(word(all, header_of(all, 2) + 36, 4) == 0x42000040);
# A name of more than eight bytes is where `/` and its offset say, in the
# table of strings after the symbols.
val named := header_of(all, 2);
t.expects(all[named] == '/' as u8);
val symbols := word(all, pe + 12, 4);
t.expects(word(all, pe + 16, 4) == 1);
val strings := symbols + 18 * 1;
var offset: u64 = 0;
var k: u64 = 1;
while all[named + k] >= '0' as u8 && all[named + k] <= '9' as u8 {
offset = offset * 10 + (all[named + k] - '0' as u8) as u64;
k++;
}
val name: strview = ".debug_info";
var same := true;
for i in 0..name.length {
same = same && all[strings + offset + i] == name[i];
}
t.expects(same);
# The symbol names its function within the code, by its offset there.
t.expects(word(all, symbols + 8, 4) == 0 && word(all, symbols + 12, 2) == 2);
}
@test def a_prologue_is_described_latest_first(t: &mut tester): void {
# push rbp; mov rbp, rsp; push rbx: the frame found from `rbp`, sixteen past
# its base, `rbx` saved at its base plus eight.
var info := pe::unwind_info::new();
info.pushed(1, 5);
info.allocated(4, 16);
info.framed(4, 5, 16);
info.saved(5, 3, 8);
val bytes := info.bytes();
t.expects(hex_of(bytes.span).span == "01050515053401000403041201500000", hex_of(bytes.span).span);
# Allocations of each size take the slots their sizes need.
var big := pe::unwind_info::new();
big.allocated(4, 136);
big.allocated(9, 0x100000);
t.expects(hex_of(big.bytes().span).span == "01090500091100001000040111000000", hex_of(big.bytes().span).span);
}
@test def records_are_shared_and_the_table_sorted(t: &mut tester): void {
var records := pe::unwind_table::new();
var info := pe::unwind_info::new();
info.allocated(4, 40);
val first := records.add(&info);
val again := records.add(&info);
var other := pe::unwind_info::new();
other.pushed(1, 5);
val second := records.add(&other);
t.expects(first == 0 && again == 0 && second == 8);
var functions := pe::function_table::new();
functions.add(0x2040, 0x2080, second);
functions.add(0x2000, 0x2040, first);
val table := functions.bytes();
t.expects(hex_of(table.span).span == "002000004020000000000000402000008020000008000000");
}
@test def the_debug_directory_names_a_pdb_file_stamped_once_written(t: &mut tester): void {
val code: u8[1] = [0xC3];
var named := byte_writer::new();
val record := pe::codeview_record(1, "app.pdb");
pe::debug_entry(&mut named, pe::debug_codeview, 0x2000 + pe::debug_entry_bytes as u32, record.length as u32);
named.put(record.span);
var image := pe::image::new(0x400000, 0x401000);
image.section(".text", 0x401000, code[:], 1, pe::readable | pe::executable);
image.section(".buildid", 0x402000, named.span, named.length, pe::readable);
image.debug = pe::directory { address = 0x402000, size = pe::debug_entry_bytes };
var bytes := image.file();
# The entry says where its record is in the file.
val entry := word(bytes.span, header_of(bytes.span, 1) + 20, 4);
val raw := word(bytes.span, entry + 24, 4);
t.expects(word(bytes.span, entry + 12, 4) == 2 && word(bytes.span, entry + 20, 4) == 0x201C);
t.expects(bytes.span[raw] == 'R' as u8 && bytes.span[raw + 3] == 'S' as u8);
t.expects(word(bytes.span, raw + 20, 4) == 1 && bytes.span[raw + 24] == 'a' as u8);
var guid: u8[16];
for k in 0..16u {
guid[k] = (k * 17) as u8;
}
t.expects(pe::stamp_codeview(&mut bytes, guid, 0x12345678));
t.expects(word(bytes.span, entry + 4, 4) == 0x12345678);
var stamped := true;
for k in 0..16u {
stamped = stamped && bytes.span[raw + 4 + k] == guid[k];
}
t.expects(stamped);
# The headers of the sections, as a PDB file keeps them.
val headers := pe::section_headers(bytes.span);
t.expects(headers.length == 80 && word(headers.span, 40 + 12, 4) == 0x2000);
}