From 2c18b593abaa7c56d8987f9e31f1339f08735c9f Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Fri, 7 Jan 2022 21:37:32 +0000 Subject: [PATCH] Expanded the assembly test code partially, and added some ideas on how to encode instructions. --- misc/test.asm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/misc/test.asm b/misc/test.asm index 65f83a5..ee42c60 100644 --- a/misc/test.asm +++ b/misc/test.asm @@ -1,6 +1,45 @@ ; comments are ignored ; This is a very simple test file for an assemblier. +.db msg "Hello, world!" + +copy r1, msg +copy r2, 0 +.loop: + cmp r1, 0 + jz .loop + add r1, 1 mov r1, 5 ; move the immediate value 5 into r1 add r1,5 ; add 5 into r1 int 21 ; maybe that will call some string drawing BIOS-like routine -ret \ No newline at end of file +ret +; form YYYY YYXX - Y opcode, X modifier +; nop: 0000 0000 +; copy: 0000 01XX +; add: 0000 10XX - | Perhaps running these will clear any overflow +; addc: 0000 11XX - | or under flow flags if no errors occur. +; sub: 0001 00XX - | jz should clear the zero flag. +; subb: 0001 01XX - | +; call: 0001 1100 - Always call [imm16] +; jmp: 0010 0000 - Always jmp [imm16] (No short jumps) +; jz: 0010 0100 - Always jz [imm16] (no short jumps) +; cmp: 0010 11XX +; push: 0011 11XX -| pop / push imm16/imm8 | reg +; pop: 0100 00XX -| + +; +; imm8 imm16 reg +; mov reg, imm16|reg +; add reg, imm16|reg +; int imm16 +; db [label] 'String data here' (Null byte is added implicatly by the assemblier) +; +; enum Type { +; Op, +; Reg, +; Imm16, +; Imm8 +; } +; struct Token { +; enum Type type; +; char *value; +; } \ No newline at end of file