Compare commits
2 Commits
c003e63d62
...
1b93cab4f6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b93cab4f6 | ||
|
|
9e68a6bb6e |
BIN
twasm/.bootle/disk
Normal file
BIN
twasm/.bootle/disk
Normal file
Binary file not shown.
@@ -24,6 +24,9 @@ TEST_LINE_LENGTH equ 80 ; right border of test suite results
|
||||
|
||||
[bits 64]
|
||||
[org LOAD_ADDR]
|
||||
[default abs] ; TODO see if I actually need to do this
|
||||
; afaik absolute addressing is not harmful on bare metal
|
||||
; reasoning: stops annoying warning =D
|
||||
|
||||
start:
|
||||
mov rsp, STACK_ADDR ; we might need more stack space, let's just be safe
|
||||
@@ -117,7 +120,7 @@ assemble:
|
||||
; di = next tte
|
||||
call get_opcode
|
||||
; al = opcode
|
||||
mov [.pending_operator_opcode], al ; save it fttb
|
||||
mov [.pending_operator_opcode], al ; save opcode fttb
|
||||
pop rdi
|
||||
|
||||
pop rax ; from start of label .operator
|
||||
@@ -139,7 +142,11 @@ assemble:
|
||||
; of 2 args, it could also be the
|
||||
; last of 1
|
||||
|
||||
; otherwise, quietly discard the token, reset things, and keep going :/
|
||||
; otherwise, discard the token, reset things, and keep going :/
|
||||
push rsi
|
||||
mov rsi, .warn_unexpected_register
|
||||
call print.warn
|
||||
pop rsi
|
||||
call .reset_state
|
||||
jmp .continue_register
|
||||
|
||||
@@ -189,6 +196,10 @@ assemble:
|
||||
.break:
|
||||
ret
|
||||
|
||||
; constants
|
||||
|
||||
.warn_unexpected_register db "ignoring unexpected register", 0x0A, 0x00
|
||||
|
||||
; procedures
|
||||
|
||||
; al = byte to write
|
||||
@@ -200,7 +211,7 @@ assemble:
|
||||
ret
|
||||
|
||||
; runs dec on .pending_operator_num_args
|
||||
.dec_num_args
|
||||
.dec_num_args:
|
||||
push rax
|
||||
mov al, [.pending_operator_num_args]
|
||||
dec al
|
||||
@@ -208,12 +219,12 @@ assemble:
|
||||
pop rax
|
||||
ret
|
||||
|
||||
.reset_state
|
||||
; I don't actually know if these `word` and `byte` directives are needed
|
||||
.reset_state:
|
||||
; I don't actually know if these `word` directives are needed
|
||||
; TODO check that. I think they are, becasue Nasm doesn't record the size
|
||||
; of labels?
|
||||
mov word [.pending_operator_opcode], UNRECOGNISED_TOKEN_ID
|
||||
mov byte [.pending_operator_num_args], 0x00
|
||||
mov [.pending_operator_num_args], 0x00
|
||||
mov word [.first_argument], UNRECOGNISED_TOKEN_ID
|
||||
ret
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ stdenv.mkDerivation {
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
buildPhase = ''
|
||||
${nasm}/bin/nasm asm/main.asm -o out.bin
|
||||
${nasm}/bin/nasm \
|
||||
asm/main.asm \
|
||||
-o out.bin \
|
||||
-w+all \
|
||||
-w-reloc-abs
|
||||
'';
|
||||
installPhase = ''
|
||||
dd if=/dev/zero of=disk bs=512 count=2880
|
||||
|
||||
Reference in New Issue
Block a user