Implemented start of flagpole compiler and a few new things here and there for said compiler

This commit is contained in:
cannoli-fruit 2026-07-25 04:16:02 -04:00
commit 6098f88cc5
8 changed files with 401 additions and 2 deletions

19
tests/cmp.asm Normal file
View file

@ -0,0 +1,19 @@
include "fvm.inc"
org 0x4000000000000000
MovI64 r95, UART_TX
MovI64 r2, 8
MovI64 r3, 2
MovI64 r4, 0x30 ; ascii for 0
Cmp64 r2, r3
JmpIP Greater
LessEq:
AddR64 r3, r4
St8 r3, r95
Jmp Ending
Greater:
AddR64 r2, r4
; MovI64 r2, 0x38
St8 r2, r95
Ending:
Halt

View file

@ -236,6 +236,18 @@ macro St8 dst, addr
db addr
end macro
macro Ld64 dst, addr
db 0x8D
db dst
db addr
end macro
macro St64 dst, addr
db 0x8C
db dst
db addr
end macro
macro AddR64 dst, src
db 0x6E
db dst
@ -266,6 +278,12 @@ macro ModR64 dst, src
db src
end macro
macro Cmp64 A, B
db 0x7D
db A
db B
end macro
macro RSetF reg
db 0x42
db reg
@ -291,12 +309,22 @@ macro JmpIZ addr
JmpRIZ 127
end macro
macro callR addr
macro JmpRIP addr
db 0xC3
db addr
end macro
macro JmpIP addr
MovI64 127, addr
JmpRIP 127
end macro
macro CallR addr
db 0x46
db addr
end macro
macro call val
macro Call val
MovI64 127, val
db 0x46
db 127