Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jbirddog committed Jul 6, 2024
1 parent 6ec2b8c commit 3d234c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
12 changes: 7 additions & 5 deletions blue.asm
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ segment readable
blue_bye:
db '16 base '
db ''
db ': bye '
db ' 31 b, FF b, '
db ' B8 b, 3C d, '
db ' 0F b, 05 b, '
db '; immediate '
db ': xor-edi 31 b, FF b, ; '
db ': mov-eax-60 B8 b, 3C d, ; '
db ': syscall 0F b, 05 b, ; '
db ''
db ': ok xor-edi ; '
db ': exit mov-eax-60 syscall ; '
db ': bye ok exit ; immediate '
db ''
db ': _start bye ; entry '
.length = $ - blue_bye
Expand Down
3 changes: 2 additions & 1 deletion dictionary.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

DE_HIDDEN = 1
DE_IMMEDIATE = 2
DE_CORE = 4

FLAGS_OFFSET = 0
FLAGS_MASK = 0xff
Expand All @@ -25,7 +26,7 @@ IN_EFFECTS_LEN_MASK = 0x0000ff

macro __w word, word_len, flags, code, ise_len, ose_len {
.##code:
db flags, word_len, ise_len, ose_len
db flags or DE_CORE, word_len, ise_len, ose_len
dd 0
dq _core_words.prev_word
dq code
Expand Down
46 changes: 25 additions & 21 deletions kernel.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ kernel_deinit:
; expects
; - word in rax
;
_compile_word:
_compile_word_abs:
push rax
call flow_in

Expand All @@ -76,11 +76,6 @@ _compile_word:
add rax, _dictionary.code_offset
mov rax, [rax]

cmp rax, _code_buffer.base
jl .c

.c:
call q_comma

mov al, 0xff
Expand All @@ -94,28 +89,32 @@ _compile_word:
; expects
; - word in rax
;
_interpret_word:
push [_code_buffer.here]

_compile_word_rel:
push rax
call flow_in

mov al, 0x48
call b_comma
mov al, 0xbf
mov al, 0xe8
call b_comma

pop rax
add rax, _dictionary.code_offset
mov rax, [rax]
sub rax, [_code_buffer.here]
sub rax, 4

call q_comma
call d_comma

mov al, 0xff
call b_comma
mov al, 0xd7
call b_comma
ret

;
; expects
; - word in rax
;
_interpret_word:
push [_code_buffer.here]

call _compile_word_abs
mov al, 0xc3
call b_comma

Expand All @@ -136,12 +135,17 @@ _handle_word:
mov rsi, [rax]
test sil, DE_IMMEDIATE
jnz .interpret
test sil, DE_CORE
jnz .compile_core

call _compile_word
jmp .done
call _compile_word_rel
ret
.compile_core:
call _compile_word_abs
ret

.interpret:
call _interpret_word

.done:
ret

0 comments on commit 3d234c3

Please sign in to comment.