From bdf0008c61dc47ce740bcd4c939e8d1189783095 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 26 Apr 2020 00:08:36 -0700 Subject: [PATCH 1/2] Implements a pushf unit test Missed this during the implementation. Checks to make sure we get the default initialization value for rflags --- unittests/ASM/Primary/Primary_9C.asm | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 unittests/ASM/Primary/Primary_9C.asm diff --git a/unittests/ASM/Primary/Primary_9C.asm b/unittests/ASM/Primary/Primary_9C.asm new file mode 100644 index 000000000..f84c08acf --- /dev/null +++ b/unittests/ASM/Primary/Primary_9C.asm @@ -0,0 +1,29 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x2", + "RBX": "0x2" + }, + "MemoryRegions": { + "0x100000000": "4096" + } +} +%endif + +mov rsp, 0xe0000010 + +; These pushes will end up being the default rflags initialization value +pushfq + +; nasm doesn't encode 16bit pushf +; put the prefix before the instruction manually +db 0x66 +pushfq + +mov rax, 0x0 +mov rbx, 0x0 + +mov ax, word [rsp] +mov rbx, qword [rsp + 2] + +hlt From 589b6e636844c72be79872701fb781b1ea0fe5bc Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 26 Apr 2020 00:14:51 -0700 Subject: [PATCH 2/2] Implements a popf unit test --- unittests/ASM/Primary/Primary_9D.asm | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 unittests/ASM/Primary/Primary_9D.asm diff --git a/unittests/ASM/Primary/Primary_9D.asm b/unittests/ASM/Primary/Primary_9D.asm new file mode 100644 index 000000000..7eed72498 --- /dev/null +++ b/unittests/ASM/Primary/Primary_9D.asm @@ -0,0 +1,38 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x2", + "RBX": "0x2" + }, + "MemoryRegions": { + "0x100000000": "4096" + } +} +%endif + +mov rax, 0x0 +mov rbx, 0x0 +mov rsp, 0xe0000010 + +; These pushes will end up being the default rflags initialization value +pushfq + +cmp rax, 1 +popfq +pushfq + +mov rax, qword [rsp] + +; These pushes will end up being the default rflags initialization value +db 0x66 +pushfq + +cmp rax, 1 +db 0x66 +popfq +db 0x66 +pushfq + +mov bx, word [rsp] + +hlt