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]
|
[bits 64]
|
||||||
[org LOAD_ADDR]
|
[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:
|
start:
|
||||||
mov rsp, STACK_ADDR ; we might need more stack space, let's just be safe
|
mov rsp, STACK_ADDR ; we might need more stack space, let's just be safe
|
||||||
@@ -117,7 +120,7 @@ assemble:
|
|||||||
; di = next tte
|
; di = next tte
|
||||||
call get_opcode
|
call get_opcode
|
||||||
; al = opcode
|
; al = opcode
|
||||||
mov [.pending_operator_opcode], al ; save it fttb
|
mov [.pending_operator_opcode], al ; save opcode fttb
|
||||||
pop rdi
|
pop rdi
|
||||||
|
|
||||||
pop rax ; from start of label .operator
|
pop rax ; from start of label .operator
|
||||||
@@ -139,7 +142,11 @@ assemble:
|
|||||||
; of 2 args, it could also be the
|
; of 2 args, it could also be the
|
||||||
; last of 1
|
; 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
|
call .reset_state
|
||||||
jmp .continue_register
|
jmp .continue_register
|
||||||
|
|
||||||
@@ -189,6 +196,10 @@ assemble:
|
|||||||
.break:
|
.break:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; constants
|
||||||
|
|
||||||
|
.warn_unexpected_register db "ignoring unexpected register", 0x0A, 0x00
|
||||||
|
|
||||||
; procedures
|
; procedures
|
||||||
|
|
||||||
; al = byte to write
|
; al = byte to write
|
||||||
@@ -200,7 +211,7 @@ assemble:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
; runs dec on .pending_operator_num_args
|
; runs dec on .pending_operator_num_args
|
||||||
.dec_num_args
|
.dec_num_args:
|
||||||
push rax
|
push rax
|
||||||
mov al, [.pending_operator_num_args]
|
mov al, [.pending_operator_num_args]
|
||||||
dec al
|
dec al
|
||||||
@@ -208,12 +219,12 @@ assemble:
|
|||||||
pop rax
|
pop rax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.reset_state
|
.reset_state:
|
||||||
; I don't actually know if these `word` and `byte` directives are needed
|
; 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
|
; TODO check that. I think they are, becasue Nasm doesn't record the size
|
||||||
; of labels?
|
; of labels?
|
||||||
mov word [.pending_operator_opcode], UNRECOGNISED_TOKEN_ID
|
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
|
mov word [.first_argument], UNRECOGNISED_TOKEN_ID
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ stdenv.mkDerivation {
|
|||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildPhase = ''
|
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 = ''
|
installPhase = ''
|
||||||
dd if=/dev/zero of=disk bs=512 count=2880
|
dd if=/dev/zero of=disk bs=512 count=2880
|
||||||
|
|||||||
Reference in New Issue
Block a user