Update WIP with jump table for words and conditions
This commit is contained in:
parent
df73353bc6
commit
00bab636db
10 changed files with 234 additions and 116 deletions
|
@ -1,16 +1,29 @@
|
||||||
|
; Generated by Henceforth 0.1.0 (https://git.dergrimm.net/dergrimm/hence.git)
|
||||||
|
|
||||||
.include "$lib/core.asm"
|
.include "$lib/core.asm"
|
||||||
.include "$lib/std.asm"
|
.include "$lib/std.asm"
|
||||||
;.include "$lib/main.asm"
|
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
ts 0xffff
|
ts CORE_U16_MAX
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval diff, (OFFSET - prev)
|
.define_eval diff, (OFFSET - prev)
|
||||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
||||||
.org prev
|
.org prev
|
||||||
.delete prev, diff
|
.delete prev, diff
|
||||||
|
|
||||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - 3 - 1)
|
.define_eval prev, OFFSET
|
||||||
|
.bytes NULL
|
||||||
|
.bytes NULL
|
||||||
|
|
||||||
|
.define_eval INDEX_CONDITIONS_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.debug INDEX_CONDITIONS_SIZE
|
||||||
|
|
||||||
|
; index
|
||||||
|
index_conditions_if_0:
|
||||||
|
|
||||||
|
|
||||||
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
|
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
|
||||||
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
|
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
|
||||||
|
@ -66,39 +79,85 @@ return_call_stack_jump:
|
||||||
get
|
get
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
.macro call_stack_jump, call_stack_jump_arg_0_label, call_stack_jump_arg_1_offset
|
.define_eval prev, OFFSET
|
||||||
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_arg_1_offset + 7)
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
.define_eval CALL_STACK_JUMP_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.macro call_stack_jump, call_stack_jump_arg_0_label
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
|
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
||||||
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
|
ts call_stack_jump
|
||||||
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label, call_stack_jump_cond_if_arg_1_offset
|
.define_eval prev, OFFSET
|
||||||
|
.std_ld
|
||||||
|
tlr CORE_REG_A
|
||||||
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
|
ts call_stack_jump
|
||||||
|
tlrc CORE_REG_PC
|
||||||
|
.define_eval CALL_STACK_JUMP_COND_IF_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_arg_1_offset + 7)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label, call_stack_jump_cond_if_else_arg_2_offset
|
.define_eval prev, OFFSET
|
||||||
|
.std_ld
|
||||||
|
tlr CORE_REG_A
|
||||||
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
|
ts call_stack_jump
|
||||||
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
|
ts call_stack_jump
|
||||||
|
tlr CORE_REG_PC
|
||||||
|
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
|
||||||
.define_eval call_stack_jump_cond_if_else_local_end_offset, (call_stack_jump_cond_if_else_arg_2_offset + 11)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
.debug call_stack_jump_cond_if_else_local_end_offset
|
|
||||||
.std_rset CORE_REG_D, call_stack_jump_cond_if_else_local_end_offset
|
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset + 11)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.debug call_stack_jump_cond_if_else_local_end_offset
|
|
||||||
|
|
||||||
.delete call_stack_jump_cond_if_else_local_end_offset
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro return_call_stack_jump
|
.macro return_call_stack_jump
|
||||||
|
@ -117,10 +176,16 @@ return_call_stack_jump:
|
||||||
.std_set CORE_MEM_OUT
|
.std_set CORE_MEM_OUT
|
||||||
.std_rset CORE_REG_A, '\n'
|
.std_rset CORE_REG_A, '\n'
|
||||||
.std_set CORE_MEM_CHR
|
.std_set CORE_MEM_CHR
|
||||||
|
.call_stack_jump words_0
|
||||||
|
.call_stack_jump words_1
|
||||||
|
.call_stack_jump words_2
|
||||||
|
.call_stack_jump words_3
|
||||||
|
.call_stack_jump words_4
|
||||||
|
dbg
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
||||||
conditions_else_0:
|
conditions_else_0:
|
||||||
push 42
|
push 69
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_set CORE_MEM_OUT
|
.std_set CORE_MEM_OUT
|
||||||
|
@ -139,6 +204,29 @@ return_call_stack_jump:
|
||||||
tls
|
tls
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_1:
|
||||||
|
; name : "meep"
|
||||||
|
push 32
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_2:
|
||||||
|
; name : "morp"
|
||||||
|
push 4875
|
||||||
|
push 8748
|
||||||
|
dbg
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_3:
|
||||||
|
; name : "zeep"
|
||||||
|
push 8777
|
||||||
|
dbg
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_4:
|
||||||
|
; name : "borg"
|
||||||
|
dbg
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
|
||||||
; main
|
; main
|
||||||
main:
|
main:
|
||||||
|
@ -148,9 +236,12 @@ main:
|
||||||
|
|
||||||
.org main
|
.org main
|
||||||
push 0
|
push 0
|
||||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0, OFFSET
|
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
||||||
.call_stack_jump words_0, OFFSET
|
.call_stack_jump words_0
|
||||||
dbg
|
dbg
|
||||||
.call_stack_jump words_0, OFFSET
|
.call_stack_jump words_1
|
||||||
|
.call_stack_jump words_2
|
||||||
|
.call_stack_jump words_3
|
||||||
|
.call_stack_jump words_4
|
||||||
dbg
|
dbg
|
||||||
.std_stop
|
.std_stop
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
: test 40 2 + ;
|
: test 40 2 + ;
|
||||||
|
: meep 32 ;
|
||||||
|
: morp 4875 8748 debug ;
|
||||||
|
: zeep 8777 debug ;
|
||||||
|
: borg debug ;
|
||||||
|
|
||||||
\ 42 42 = debug if 69 . else 420 . then cr
|
\ 42 42 = debug if 69 . else 420 . then cr
|
||||||
|
|
||||||
0 if 42 . cr else 69 . cr then
|
0 if 42 . cr test meep morp zeep borg debug else 69 . cr then
|
||||||
test debug test debug
|
test debug meep morp zeep borg debug
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
; hence core lib
|
; hence core lib
|
||||||
|
|
||||||
.define_eval NULL, 0
|
.define_eval NULL, 0
|
||||||
.define_eval VOID, NULL
|
.define_eval VOID, NULL
|
||||||
|
|
||||||
.define_eval FALSE, NULL
|
.define_eval FALSE, NULL
|
||||||
.define_eval TRUE, 1
|
.define_eval TRUE, 1
|
||||||
|
|
||||||
.define_eval CORE_U8_MAX, 0x00ff
|
.define_eval CORE_U8_MAX, 0x00ff
|
||||||
.define_eval CORE_U16_MAX, 0xffff
|
.define_eval CORE_U16_MAX, 0xffff
|
||||||
|
|
||||||
.define_eval CORE_KB, 1024
|
.define_eval CORE_KB, 1024
|
||||||
|
|
||||||
.define_eval CORE_MEM_PRG, (0 * CORE_KB)
|
.define_eval CORE_MEM_PRG, (0 * CORE_KB)
|
||||||
.define_eval CORE_MEM_PRG_END, (32 * CORE_KB)
|
.define_eval CORE_MEM_PRG_END, (32 * CORE_KB)
|
||||||
.define_eval CORE_MEM_ST, CORE_MEM_PRG_END
|
.define_eval CORE_MEM_ST, CORE_MEM_PRG_END
|
||||||
.define_eval CORE_MEM_MEM, (40 * CORE_KB)
|
.define_eval CORE_MEM_MEM, (40 * CORE_KB)
|
||||||
.define_eval CORE_MEM_OUT, (48 * CORE_KB)
|
.define_eval CORE_MEM_OUT, (48 * CORE_KB)
|
||||||
.define_eval CORE_MEM_CHR, (CORE_MEM_OUT + 1)
|
.define_eval CORE_MEM_CHR, (CORE_MEM_OUT + 1)
|
||||||
.define_eval CORE_MEM_KEY, (CORE_MEM_CHR + 2)
|
.define_eval CORE_MEM_KEY, (CORE_MEM_CHR + 2)
|
||||||
|
|
||||||
.define_eval CORE_REG_PC, 0x0
|
.define_eval CORE_REG_PC, 0x0
|
||||||
.define_eval CORE_REG_OPC, 0x1
|
.define_eval CORE_REG_OPC, 0x1
|
||||||
.define_eval CORE_REG_ARG, 0x2
|
.define_eval CORE_REG_ARG, 0x2
|
||||||
.define_eval CORE_REG_S, 0x3
|
.define_eval CORE_REG_S, 0x3
|
||||||
.define_eval CORE_REG_SP, 0x4
|
.define_eval CORE_REG_SP, 0x4
|
||||||
.define_eval CORE_REG_A, 0x5
|
.define_eval CORE_REG_A, 0x5
|
||||||
.define_eval CORE_REG_B, 0x6
|
.define_eval CORE_REG_B, 0x6
|
||||||
.define_eval CORE_REG_C, 0x7
|
.define_eval CORE_REG_C, 0x7
|
||||||
.define_eval CORE_REG_D, 0x8
|
.define_eval CORE_REG_D, 0x8
|
||||||
|
|
||||||
.define_eval CORE_ALU_NOT, 0x00
|
.define_eval CORE_ALU_NOT, 0x00
|
||||||
.define_eval CORE_ALU_AND, 0x01
|
.define_eval CORE_ALU_AND, 0x01
|
||||||
.define_eval CORE_ALU_OR, 0x02
|
.define_eval CORE_ALU_OR, 0x02
|
||||||
.define_eval CORE_ALU_XOR, 0x03
|
.define_eval CORE_ALU_XOR, 0x03
|
||||||
.define_eval CORE_ALU_LSH, 0x04
|
.define_eval CORE_ALU_LSH, 0x04
|
||||||
.define_eval CORE_ALU_RSH, 0x05
|
.define_eval CORE_ALU_RSH, 0x05
|
||||||
.define_eval CORE_ALU_ADD, 0x06
|
.define_eval CORE_ALU_ADD, 0x06
|
||||||
.define_eval CORE_ALU_SUB, 0x07
|
.define_eval CORE_ALU_SUB, 0x07
|
||||||
.define_eval CORE_ALU_MUL, 0x08
|
.define_eval CORE_ALU_MUL, 0x08
|
||||||
.define_eval CORE_ALU_DIV, 0x09
|
.define_eval CORE_ALU_DIV, 0x09
|
||||||
.define_eval CORE_ALU_CMP, 0x0a
|
.define_eval CORE_ALU_CMP, 0x0a
|
||||||
.define_eval CORE_ALU_EQ, 0x0b
|
.define_eval CORE_ALU_EQ, 0x0b
|
||||||
.define_eval CORE_ALU_LT, 0x0c
|
.define_eval CORE_ALU_LT, 0x0c
|
||||||
.define_eval CORE_ALU_GT, 0x0d
|
.define_eval CORE_ALU_GT, 0x0d
|
||||||
.define_eval CORE_ALU_LEQ, 0x0e
|
.define_eval CORE_ALU_LEQ, 0x0e
|
||||||
.define_eval CORE_ALU_GEQ, 0x0f
|
.define_eval CORE_ALU_GEQ, 0x0f
|
||||||
.define_eval CORE_ALU_BOL, 0x10
|
.define_eval CORE_ALU_BOL, 0x10
|
||||||
.define_eval CORE_ALU_INV, 0x11
|
.define_eval CORE_ALU_INV, 0x11
|
||||||
.define_eval CORE_ALU_RND, 0x12
|
.define_eval CORE_ALU_RND, 0x12
|
||||||
.define_eval CORE_ALU_TME, 0x13
|
.define_eval CORE_ALU_TME, 0x13
|
||||||
|
|
|
@ -209,6 +209,18 @@ impl Assembler {
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
"delete_macro" => {
|
||||||
|
for arg in args {
|
||||||
|
match arg {
|
||||||
|
arg::Arg::Variable(x) => {
|
||||||
|
self.macros.remove(&x);
|
||||||
|
}
|
||||||
|
_ => bail!("Arguments need to be variables"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
"if" => {
|
"if" => {
|
||||||
let cond = (args[0].resolve_number(self)? & 1) == 1;
|
let cond = (args[0].resolve_number(self)? & 1) == 1;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn parse(tokens: Vec<lexer::Token>) -> Result<ast::AST> {
|
||||||
.peeking_next(|t| matches!(t, lexer::Token::Colon))
|
.peeking_next(|t| matches!(t, lexer::Token::Colon))
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
body.push(ast::Node::Label(x.clone()));
|
body.push(ast::Node::Label(x.to_owned()));
|
||||||
} else {
|
} else {
|
||||||
let args = match arg::parse_args(
|
let args = match arg::parse_args(
|
||||||
iter.by_ref()
|
iter.by_ref()
|
||||||
|
|
|
@ -166,14 +166,14 @@ impl Compiler {
|
||||||
.collect::<Result<Vec<_>>>()?
|
.collect::<Result<Vec<_>>>()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.collect(),
|
.collect::<Vec<_>>(),
|
||||||
c.else_instructions
|
c.else_instructions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ins| ins.compile(self))
|
.map(|ins| ins.compile(self))
|
||||||
.collect::<Result<Vec<_>>>()?
|
.collect::<Result<Vec<_>>>()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.collect(),
|
.collect::<Vec<_>>(),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1228,10 +1228,7 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
|
||||||
if w.times_used > 1 {
|
if w.times_used > 1 {
|
||||||
Ok(vec![hence::parser::ast::Node::MacroCall {
|
Ok(vec![hence::parser::ast::Node::MacroCall {
|
||||||
name: "call_stack_jump".to_string(),
|
name: "call_stack_jump".to_string(),
|
||||||
args: vec![
|
args: vec![hence::arg::Arg::Variable(format!("words_{}", w.id))],
|
||||||
hence::arg::Arg::Variable(format!("words_{}", w.id)),
|
|
||||||
hence::arg::Arg::Variable("OFFSET".to_string()),
|
|
||||||
],
|
|
||||||
}])
|
}])
|
||||||
} else {
|
} else {
|
||||||
Ok(w.instructions
|
Ok(w.instructions
|
||||||
|
@ -1252,10 +1249,7 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
|
||||||
Some(cond) => Ok(vec![if cond.only_if() {
|
Some(cond) => Ok(vec![if cond.only_if() {
|
||||||
hence::parser::ast::Node::MacroCall {
|
hence::parser::ast::Node::MacroCall {
|
||||||
name: "call_stack_jump_cond_if".to_string(),
|
name: "call_stack_jump_cond_if".to_string(),
|
||||||
args: vec![
|
args: vec![hence::arg::Arg::Variable(format!("conditions_if_{}", x))],
|
||||||
hence::arg::Arg::Variable(format!("conditions_if_{}", x)),
|
|
||||||
hence::arg::Arg::Variable("OFFSET".to_string()),
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hence::parser::ast::Node::MacroCall {
|
hence::parser::ast::Node::MacroCall {
|
||||||
|
@ -1263,7 +1257,6 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
|
||||||
args: vec![
|
args: vec![
|
||||||
hence::arg::Arg::Variable(format!("conditions_if_{}", x)),
|
hence::arg::Arg::Variable(format!("conditions_if_{}", x)),
|
||||||
hence::arg::Arg::Variable(format!("conditions_else_{}", x)),
|
hence::arg::Arg::Variable(format!("conditions_else_{}", x)),
|
||||||
hence::arg::Arg::Variable("OFFSET".to_string()),
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}]),
|
}]),
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
{% if name.starts_with('"') %}{{ name }}{% else %}"{{ name }}"{% endif %}
|
{% if name.starts_with('"') %}{{ name }}{% else %}"{{ name }}"{% endif %}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
; Generated by Henceforth {{ env!("CARGO_PKG_VERSION") }} ({{ env!("CARGO_PKG_REPOSITORY") }})
|
||||||
|
|
||||||
.include "$lib/core.asm"
|
.include "$lib/core.asm"
|
||||||
.include "$lib/std.asm"
|
.include "$lib/std.asm"
|
||||||
;.include "$lib/main.asm"
|
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
ts CORE_U16_MAX
|
ts CORE_U16_MAX
|
||||||
|
@ -14,7 +15,21 @@
|
||||||
.org prev
|
.org prev
|
||||||
.delete prev, diff
|
.delete prev, diff
|
||||||
|
|
||||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - 3 - 1)
|
.define_eval prev, OFFSET
|
||||||
|
{%- for c in conditions %}
|
||||||
|
.bytes NULL
|
||||||
|
{% if !c.data.1.is_empty() %}.bytes NULL{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
.define_eval INDEX_CONDITIONS_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.debug INDEX_CONDITIONS_SIZE
|
||||||
|
|
||||||
|
; index
|
||||||
|
{%- for c in conditions %}
|
||||||
|
index_conditions_if_{{ c.id }}:
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
|
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
|
||||||
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
|
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
|
||||||
|
@ -70,20 +85,50 @@ return_call_stack_jump:
|
||||||
get
|
get
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
.macro call_stack_jump, call_stack_jump_arg_0_label, call_stack_jump_arg_1_offset
|
.define_eval prev, OFFSET
|
||||||
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_arg_1_offset + 7)
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
.define_eval CALL_STACK_JUMP_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.macro call_stack_jump, call_stack_jump_arg_0_label
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
|
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
||||||
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
|
ts call_stack_jump
|
||||||
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label, call_stack_jump_cond_if_arg_1_offset
|
.define_eval prev, OFFSET
|
||||||
|
.std_ld
|
||||||
|
tlr CORE_REG_A
|
||||||
|
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||||
|
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||||
|
ts call_stack_jump
|
||||||
|
tlrc CORE_REG_PC
|
||||||
|
.define_eval CALL_STACK_JUMP_COND_IF_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
|
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_arg_1_offset + 7)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
|
@ -99,24 +144,26 @@ return_call_stack_jump:
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||||
|
.org prev
|
||||||
.delete prev
|
.delete prev
|
||||||
|
|
||||||
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label, call_stack_jump_cond_if_else_arg_2_offset
|
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
|
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||||
|
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
|
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
|
||||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset + 11)
|
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
.delete prev
|
.delete prev, offset_till_end
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro return_call_stack_jump
|
.macro return_call_stack_jump
|
||||||
|
@ -147,7 +194,7 @@ return_call_stack_jump:
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
||||||
conditions_else_{{ c.id }}:
|
conditions_else_{{ c.id }}:
|
||||||
{%- for ins in c.data.0 %}
|
{%- for ins in c.data.1 %}
|
||||||
{{ ins }}
|
{{ ins }}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"comments": {
|
"comments": {
|
||||||
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
||||||
"lineComment": "//",
|
"lineComment": ";",
|
||||||
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
||||||
"blockComment": [ "/*", "*/" ]
|
// "blockComment": [ "/*", "*/" ]
|
||||||
},
|
},
|
||||||
// symbols used as brackets
|
// symbols used as brackets
|
||||||
"brackets": [
|
"brackets": [
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
# Welcome to your VS Code Extension
|
|
||||||
|
|
||||||
## What's in the folder
|
|
||||||
|
|
||||||
* This folder contains all of the files necessary for your extension.
|
|
||||||
* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension.
|
|
||||||
* `syntaxes/hence.tmLanguage` - this is the Text mate grammar file that is used for tokenization.
|
|
||||||
* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets.
|
|
||||||
|
|
||||||
## Get up and running straight away
|
|
||||||
|
|
||||||
* Make sure the language configuration settings in `language-configuration.json` are accurate.
|
|
||||||
* Press `F5` to open a new window with your extension loaded.
|
|
||||||
* Create a new file with a file name suffix matching your language.
|
|
||||||
* Verify that syntax highlighting works and that the language configuration settings are working.
|
|
||||||
|
|
||||||
## Make changes
|
|
||||||
|
|
||||||
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
|
|
||||||
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
|
||||||
|
|
||||||
## Add more language features
|
|
||||||
|
|
||||||
* To add features such as IntelliSense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs
|
|
||||||
|
|
||||||
## Install your extension
|
|
||||||
|
|
||||||
* To start using your extension with Visual Studio Code copy it into the `<user home>/.vscode/extensions` folder and restart Code.
|
|
||||||
* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension.
|
|
Loading…
Reference in a new issue