diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-05-01 18:34:07 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-05-01 18:34:07 +0200 |
commit | 22b4dd12c063090acc8a8a1297c41bde74e0de24 (patch) | |
tree | b6ec00abb9c88162f60c02a1c2adc76a3e1bd47d /miniasm | |
parent | 669f2c250379779f1b9bb7129d5909baef3df2e0 (diff) | |
download | compilertests-22b4dd12c063090acc8a8a1297c41bde74e0de24.tar.gz compilertests-22b4dd12c063090acc8a8a1297c41bde74e0de24.tar.bz2 |
quite some fixes
Diffstat (limited to 'miniasm')
-rw-r--r-- | miniasm/const.h | 4 | ||||
-rw-r--r-- | miniasm/test4.asm | 8 | ||||
-rw-r--r-- | miniasm/test5.asm | 26 | ||||
-rw-r--r-- | miniasm/test6.asm | 1 | ||||
-rw-r--r-- | miniasm/test7.asm | 1 | ||||
-rw-r--r-- | miniasm/test8.asm | 4 |
6 files changed, 37 insertions, 7 deletions
diff --git a/miniasm/const.h b/miniasm/const.h index 6ccc38d..f673e16 100644 --- a/miniasm/const.h +++ b/miniasm/const.h @@ -1,9 +1,9 @@ #pragma once enum { - MAX_LABEL_LEN = 12, + MAX_LABEL_LEN = 15, MAX_OP_LEN = 10, - MAX_IDENT_LEN = 12, + MAX_IDENT_LEN = 15, MAX_TMP_LEN = 80, INIT_NOF_LABELS = 4, DEFAULT_MEMORY_SIZE = 256 diff --git a/miniasm/test4.asm b/miniasm/test4.asm index c181468..ebdd954 100644 --- a/miniasm/test4.asm +++ b/miniasm/test4.asm @@ -1,16 +1,22 @@ -; test4 - arithmetics +; test4 - integer arithmetics and logical operations begin: mov ax, 5 mov bx, 3 +; ax should be 8 add ax, bx mov cx, 1 sub ax, cx +; ax should be 7 or ax, 64 +; ax should be 00000111 | 010000000 = 01000111 (0x47) mov dx, 8 add dx, 19 +; dx should be 27 (0x1b) and dx, 15 +; dx should be 00011011 & 00001111 = 00001011 (0xb) not dx +; ~ 00001011 - 11110100 (0xf4) jmp end end: diff --git a/miniasm/test5.asm b/miniasm/test5.asm index efa1d22..f518afb 100644 --- a/miniasm/test5.asm +++ b/miniasm/test5.asm @@ -9,11 +9,29 @@ begin: equals: mov cx, 1 - jmp end - +; cx is one on equality + jmp test2 + not_equals: mov cx, 0 - jmp end +; cx is zero on inequality + +test2: + mov ax, 5 + mov bx, 6 + cmp ax, bx + je equals2 + jmp not_equals2 + +equals2: + mov dx, 1 +; dx is one on equality + jmp end2 + +not_equals2: + mov dx, 0 +; dx is zero on inequality + jmp end2 -end: +end2: hlt diff --git a/miniasm/test6.asm b/miniasm/test6.asm index e452ec2..70802dc 100644 --- a/miniasm/test6.asm +++ b/miniasm/test6.asm @@ -7,6 +7,7 @@ loop: add bx, 1 cmp ax, bx jne loop +; loop ten times, bx and ax must be 10 in the end end: hlt diff --git a/miniasm/test7.asm b/miniasm/test7.asm index b822dea..19d2e1f 100644 --- a/miniasm/test7.asm +++ b/miniasm/test7.asm @@ -4,6 +4,7 @@ begin: mov ax, 2 mov bx, 3 jsr add +; getting back here from 'add' subroutine, ax must be 5 end: hlt diff --git a/miniasm/test8.asm b/miniasm/test8.asm index f261f08..493a12f 100644 --- a/miniasm/test8.asm +++ b/miniasm/test8.asm @@ -6,6 +6,10 @@ begin: mov cx, 3 mov dx, 4 jsr func +; the subroutine saves all registers to the stack, modifies them and +; then restores them to their original value +; while in the subroutine we should se 04 03 02 01 0a on the stack +; (the registers and the return address 0a) end: hlt |