about summary refs log tree commit diff stats
path: root/test/arch/x86/unit/mn_daa.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/arch/x86/unit/mn_daa.py')
-rw-r--r--test/arch/x86/unit/mn_daa.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/arch/x86/unit/mn_daa.py b/test/arch/x86/unit/mn_daa.py
new file mode 100644
index 00000000..cb96a22b
--- /dev/null
+++ b/test/arch/x86/unit/mn_daa.py
@@ -0,0 +1,76 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+
+
+class Test_DAA(Asm_Test):
+    TXT = '''
+    main:
+       MOV     EBP, ESP
+       LEA     ESI, DWORD PTR [array_al]
+    loop:
+
+       ; load original cf
+       LODSB
+       MOV     BL, AL
+       ; load original af
+       LODSB
+       SHL     AL, 4
+       OR      AL, BL
+       MOV     AH, AL
+       SAHF
+       ; load original al
+       LODSB
+
+       DAA
+       MOV     BL, AL
+
+       LAHF
+       MOV     CL, AH
+
+       ; test cf
+       LODSB
+       MOV     DL, CL
+       AND     DL, 1
+       CMP     DL, AL
+       JNZ BAD
+
+       MOV     DL, CL
+       SHR     DL, 4
+       AND     DL, 1
+       ; test af
+       LODSB
+       CMP     DL, AL
+       JNZ BAD
+
+       ; test value
+       LODSB
+       CMP     AL, BL
+       JNZ BAD
+
+       CMP     ESI, array_al_end
+       JB      loop
+
+
+    end:
+       RET
+
+BAD:
+       INT     0x3
+       RET
+
+array_al:
+.byte 0, 1, 0x08, 0, 1, 0x0E
+.byte 0, 1, 0x09, 0, 1, 0x0F
+.byte 0, 1, 0x0A, 0, 1, 0x10
+.byte 0, 1, 0x98, 0, 1, 0x9E
+.byte 0, 1, 0x99, 0, 1, 0x9F
+.byte 0, 1, 0x9A, 1, 1, 0x00
+array_al_end:
+.long 0
+    '''
+    def check(self):
+        pass
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_DAA]]