Skip to content

Commit

Permalink
More byte and long preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
drmortalwombat committed Sep 14, 2021
1 parent e2e2058 commit 37828f2
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 95 deletions.
3 changes: 2 additions & 1 deletion autotest/recursiontest.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int fib(int a)
{
Expand Down Expand Up @@ -75,7 +76,7 @@ void btest(void)
}

collect(tree, buff)[0] = 0;

assert(strcmp(buff, " DEHLLLOORW") == 0);
}

Expand Down
87 changes: 87 additions & 0 deletions include/crt.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ __asm inp_native
}

#pragma bytecode(BC_NATIVE, inp_native)

__asm inp_const_8
{
lda (ip), y
tax
iny
lda (ip), y
sta $00, x
iny
jmp startup.exec
}

#pragma bytecode(BC_CONST_8, inp_const_8)

__asm inp_const_p8
{
Expand Down Expand Up @@ -351,6 +364,32 @@ __asm inp_const_32
}

#pragma bytecode(BC_CONST_32, inp_const_32)

__asm inp_load_reg_8
{
lda (ip), y
tax
iny
lda $00, x
sta accu
lda #0
sta accu + 1
jmp startup.exec
}

#pragma bytecode(BC_LOAD_REG_8, inp_load_reg_8)

__asm inp_store_reg_8
{
lda (ip), y
tax
iny
lda accu
sta $00, x
jmp startup.exec
}

#pragma bytecode(BC_STORE_REG_8, inp_store_reg_8)

__asm inp_load_reg_16
{
Expand Down Expand Up @@ -445,6 +484,37 @@ __asm inp_addr_reg

#pragma bytecode(BC_ADDR_REG, inp_addr_reg)

__asm inp_load_abs_8
{
lda (ip), y
sta addr
iny
lda (ip), y
sta addr + 1
iny
lda (ip), y
tax
sty tmpy
ldy #0
L0:
lda (addr), y
sta $00, x
ldy tmpy
iny
jmp startup.exec
inp_load_addr_8:
lda (ip), y
tax
iny
lda (ip), y
sty tmpy
tay
jmp L0
}

#pragma bytecode(BC_LOAD_ABS_8, inp_load_abs_8)
#pragma bytecode(BC_LOAD_ADDR_8, inp_load_abs_8.inp_load_addr_8)

__asm inp_load_abs_u8
{
lda (ip), y
Expand Down Expand Up @@ -761,6 +831,23 @@ __asm inp_load_local_32
}

#pragma bytecode(BC_LOAD_LOCAL_32, inp_load_local_32)

__asm inp_load_local_8
{
lda (ip), y
tax
iny
lda (ip), y
iny
sty tmpy
tay
lda (fp), y
sta $00, x
ldy tmpy
jmp startup.exec
}

#pragma bytecode(BC_LOAD_LOCAL_8, inp_load_local_8)

__asm inp_load_local_u8
{
Expand Down
6 changes: 6 additions & 0 deletions include/crt.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ enum ByteCode
BC_NOP,
BC_EXIT,

BC_CONST_8,
BC_CONST_P8,
BC_CONST_N8,
BC_CONST_16,
BC_CONST_32,

BC_LOAD_REG_8,
BC_STORE_REG_8,
BC_LOAD_REG_16,
BC_STORE_REG_16,
BC_ADDR_REG,
BC_LOAD_REG_32,
BC_STORE_REG_32,

BC_LOAD_ABS_8,
BC_LOAD_ABS_U8,
BC_LOAD_ABS_I8,
BC_LOAD_ABS_16,
Expand All @@ -41,6 +45,7 @@ enum ByteCode

BC_LEA_ABS,

BC_LOAD_LOCAL_8,
BC_LOAD_LOCAL_U8,
BC_LOAD_LOCAL_I8,
BC_LOAD_LOCAL_16,
Expand All @@ -56,6 +61,7 @@ enum ByteCode
BC_STORE_FRAME_16,
BC_STORE_FRAME_32,

BC_LOAD_ADDR_8,
BC_LOAD_ADDR_U8,
BC_LOAD_ADDR_I8,
BC_LOAD_ADDR_16,
Expand Down
Loading

0 comments on commit 37828f2

Please sign in to comment.