Compare commits
10 Commits
bb3d709ad6
...
f4a7e18b28
Author | SHA1 | Date | |
---|---|---|---|
f4a7e18b28 | |||
49e9dbff85 | |||
f537f9a2d8 | |||
|
f8e2fa453b | ||
|
da4adbb916 | ||
|
70a9006fb3 | ||
|
e28e8eceb0 | ||
|
09c0d8c215 | ||
|
57409ecb6e | ||
|
b1aa77aa70 |
18
.github/workflows/fox32rom-unstable.yml
vendored
18
.github/workflows/fox32rom-unstable.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
|||
branches:
|
||||
- main
|
||||
|
||||
name: fox32rom Unstable
|
||||
name: fox32rom
|
||||
|
||||
jobs:
|
||||
fox32rom-unstable-linux:
|
||||
|
@ -12,27 +12,21 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Download latest fox32asm artifact
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
- uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
repo: fox32-arch/fox32asm
|
||||
workflow: fox32asm-unstable-linux.yml
|
||||
workflow_conclusion: success
|
||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
chmod +x fox32asm/fox32asm
|
||||
fox32asm/fox32asm main.asm fox32.rom
|
||||
run: nix build .#fox32rom
|
||||
|
||||
- name: Upload fox32.rom
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: fox32.rom
|
||||
path: fox32.rom
|
||||
path: result/bin/fox32.rom
|
||||
|
||||
- name: Upload fox32rom.def
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: fox32rom.def
|
||||
path: fox32rom.def
|
||||
path: result/dev/fox32rom.def
|
||||
|
|
509
exception.asm
509
exception.asm
|
@ -41,12 +41,14 @@ system_page_fault_handler:
|
|||
system_page_fault_str: data.str "Page fault at virtual address r1" data.8 10 data.8 0
|
||||
|
||||
; called upon execution of a `brk` instruction
|
||||
; ensure the stack has at least 256 bytes of free space before triggering this exception!!
|
||||
; this code is extremely ugly, but it works :P
|
||||
; ensure the stack has at least 128 bytes of free space before triggering this exception!!
|
||||
system_breakpoint_handler:
|
||||
add rsp, 4
|
||||
|
||||
; push all registers once to save them
|
||||
push rfp
|
||||
push resp
|
||||
push rsp
|
||||
push r31
|
||||
push r30
|
||||
push r29
|
||||
|
@ -80,471 +82,16 @@ system_breakpoint_handler:
|
|||
push r1
|
||||
push r0
|
||||
|
||||
; then push all registers again so they can be popped one by one to print to the monitor
|
||||
push r31
|
||||
push r30
|
||||
push r29
|
||||
push r28
|
||||
push r27
|
||||
push r26
|
||||
push r25
|
||||
push r24
|
||||
push r23
|
||||
push r22
|
||||
push r21
|
||||
push r20
|
||||
push r19
|
||||
push r18
|
||||
push r17
|
||||
push r16
|
||||
push r15
|
||||
push r14
|
||||
push r13
|
||||
push r12
|
||||
push r11
|
||||
push r10
|
||||
push r9
|
||||
push r8
|
||||
push r7
|
||||
push r6
|
||||
push r5
|
||||
push r4
|
||||
push r3
|
||||
push r2
|
||||
push r1
|
||||
push r0
|
||||
; modify the saved rsp value to reflect the value of rsp before the
|
||||
; interrupt occured
|
||||
; resp (4) + rfp (4) + flags (1) + return address (4) = 13 bytes
|
||||
add [rsp+128], 13
|
||||
|
||||
; print breakpoint message
|
||||
mov r0, system_breakpoint_str
|
||||
call debug_print
|
||||
call print_string_to_monitor
|
||||
|
||||
; r0
|
||||
mov r0, system_breakpoint_r0_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r1
|
||||
mov r0, system_breakpoint_r1_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r2
|
||||
mov r0, system_breakpoint_r2_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r3
|
||||
mov r0, system_breakpoint_r3_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r4
|
||||
mov r0, system_breakpoint_r4_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r5
|
||||
mov r0, system_breakpoint_r5_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r6
|
||||
mov r0, system_breakpoint_r6_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r7
|
||||
mov r0, system_breakpoint_r7_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r8
|
||||
mov r0, system_breakpoint_r8_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r9
|
||||
mov r0, system_breakpoint_r9_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r10
|
||||
mov r0, system_breakpoint_r10_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r11
|
||||
mov r0, system_breakpoint_r11_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r12
|
||||
mov r0, system_breakpoint_r12_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r13
|
||||
mov r0, system_breakpoint_r13_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r14
|
||||
mov r0, system_breakpoint_r14_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r15
|
||||
mov r0, system_breakpoint_r15_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r16
|
||||
mov r0, system_breakpoint_r16_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r17
|
||||
mov r0, system_breakpoint_r17_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r18
|
||||
mov r0, system_breakpoint_r18_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r19
|
||||
mov r0, system_breakpoint_r19_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r20
|
||||
mov r0, system_breakpoint_r20_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r21
|
||||
mov r0, system_breakpoint_r21_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r22
|
||||
mov r0, system_breakpoint_r22_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r23
|
||||
mov r0, system_breakpoint_r23_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r24
|
||||
mov r0, system_breakpoint_r24_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r25
|
||||
mov r0, system_breakpoint_r25_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r26
|
||||
mov r0, system_breakpoint_r26_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r27
|
||||
mov r0, system_breakpoint_r27_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; r28
|
||||
mov r0, system_breakpoint_r28_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r29
|
||||
mov r0, system_breakpoint_r29_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r30
|
||||
mov r0, system_breakpoint_r30_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; r31
|
||||
mov r0, system_breakpoint_r31_str
|
||||
call print_string_to_monitor
|
||||
pop r0
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
; rsp
|
||||
mov r0, system_breakpoint_rsp_str
|
||||
call print_string_to_monitor
|
||||
mov r0, rsp
|
||||
add r0, 133 ; account for the registers pushed above, and for the int calling convention
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
|
||||
; rip
|
||||
mov r0, system_breakpoint_rip_str
|
||||
call print_string_to_monitor
|
||||
mov r0, rsp
|
||||
add r0, 129 ; read instruction pointer from the stack
|
||||
mov r0, [r0]
|
||||
call print_hex_word_to_monitor
|
||||
|
||||
; ---
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
; ---
|
||||
|
||||
call invoke_monitor
|
||||
|
||||
pop r0
|
||||
|
@ -579,39 +126,9 @@ system_breakpoint_handler:
|
|||
pop r29
|
||||
pop r30
|
||||
pop r31
|
||||
; don't restore rsp and resp. not sure whether restoring a potentially
|
||||
; modified resp would break things, but changing rsp definitely would.
|
||||
add rsp, 8
|
||||
pop rfp
|
||||
reti
|
||||
system_breakpoint_str: data.str "Breakpoint reached!" data.8 10 data.8 0
|
||||
system_breakpoint_r0_str: data.strz "r0: "
|
||||
system_breakpoint_r1_str: data.strz "r1: "
|
||||
system_breakpoint_r2_str: data.strz "r2: "
|
||||
system_breakpoint_r3_str: data.strz "r3: "
|
||||
system_breakpoint_r4_str: data.strz "r4: "
|
||||
system_breakpoint_r5_str: data.strz "r5: "
|
||||
system_breakpoint_r6_str: data.strz "r6: "
|
||||
system_breakpoint_r7_str: data.strz "r7: "
|
||||
system_breakpoint_r8_str: data.strz "r8: "
|
||||
system_breakpoint_r9_str: data.strz "r9: "
|
||||
system_breakpoint_r10_str: data.strz "r10: "
|
||||
system_breakpoint_r11_str: data.strz "r11: "
|
||||
system_breakpoint_r12_str: data.strz "r12: "
|
||||
system_breakpoint_r13_str: data.strz "r13: "
|
||||
system_breakpoint_r14_str: data.strz "r14: "
|
||||
system_breakpoint_r15_str: data.strz "r15: "
|
||||
system_breakpoint_r16_str: data.strz "r16: "
|
||||
system_breakpoint_r17_str: data.strz "r17: "
|
||||
system_breakpoint_r18_str: data.strz "r18: "
|
||||
system_breakpoint_r19_str: data.strz "r19: "
|
||||
system_breakpoint_r20_str: data.strz "r20: "
|
||||
system_breakpoint_r21_str: data.strz "r21: "
|
||||
system_breakpoint_r22_str: data.strz "r22: "
|
||||
system_breakpoint_r23_str: data.strz "r23: "
|
||||
system_breakpoint_r24_str: data.strz "r24: "
|
||||
system_breakpoint_r25_str: data.strz "r25: "
|
||||
system_breakpoint_r26_str: data.strz "r26: "
|
||||
system_breakpoint_r27_str: data.strz "r27: "
|
||||
system_breakpoint_r28_str: data.strz "r28: "
|
||||
system_breakpoint_r29_str: data.strz "r29: "
|
||||
system_breakpoint_r30_str: data.strz "r30: "
|
||||
system_breakpoint_r31_str: data.strz "r31: "
|
||||
system_breakpoint_rsp_str: data.strz "rsp: "
|
||||
system_breakpoint_rip_str: data.strz "rip: "
|
||||
|
|
126
flake.lock
Normal file
126
flake.lock
Normal file
|
@ -0,0 +1,126 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fox32asm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1706972401,
|
||||
"narHash": "sha256-HrbsibEnxC8va3LJhA6B8fDabxFRcmTk1or2pOKxlYo=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "bfd40db93b6cc5ec67517286e6c32a5bd8ecc702",
|
||||
"revCount": 67,
|
||||
"type": "git",
|
||||
"url": "https://githug.xyz/xenia/fox32asm"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://githug.xyz/xenia/fox32asm"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1697009197,
|
||||
"narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1697009197,
|
||||
"narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"fox32asm": "fox32asm",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
35
flake.nix
Normal file
35
flake.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
description = "fox32rom";
|
||||
|
||||
inputs = {
|
||||
fox32asm.url = "git+https://githug.xyz/xenia/fox32asm";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, fox32asm, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (sys:
|
||||
let pkgs = nixpkgs.legacyPackages.${sys};
|
||||
asm = fox32asm.packages.${sys}.default;
|
||||
fox32rom = pkgs.runCommand "fox32rom" {} ''
|
||||
cp -r ${./.}/* ./
|
||||
mkdir -p $out/{bin,dev}
|
||||
${asm}/bin/fox32asm ./main.asm $out/bin/fox32.rom
|
||||
cp ${./fox32rom.def} $out/dev/fox32rom.def
|
||||
'';
|
||||
|
||||
fox32rom-dev = pkgs.runCommand "fox32rom-dev" {} ''
|
||||
mkdir -p $out/dev
|
||||
cp ${./fox32rom.def} $out/dev/fox32rom.def
|
||||
'';
|
||||
|
||||
in rec {
|
||||
packages.fox32rom = fox32rom;
|
||||
packages.fox32rom-dev = fox32rom-dev;
|
||||
packages.default = fox32rom;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [ asm ];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
; add events to the event queue if a key was pressed or released
|
||||
; this should only be called by system_vsync_handler
|
||||
; inputs:
|
||||
; none
|
||||
; outputs:
|
||||
; r0: non-zero if F12 was pressed, zero otherwise
|
||||
keyboard_update:
|
||||
; pop a key from the keyboard queue
|
||||
in r0, 0x80000500
|
||||
|
@ -10,7 +14,7 @@ keyboard_update:
|
|||
|
||||
; invoke the debug monitor if F12 was pressed
|
||||
cmp r0, 0x58
|
||||
ifz jmp invoke_monitor
|
||||
ifz jmp keyboard_update_end
|
||||
|
||||
; check if this is a make or break scancode
|
||||
bts r0, 7
|
||||
|
@ -25,6 +29,7 @@ keyboard_update:
|
|||
mov r6, 0
|
||||
mov r7, 0
|
||||
call new_event
|
||||
mov r0, 0
|
||||
jmp keyboard_update_end
|
||||
keyboard_update_break_scancode:
|
||||
and r0, 0x7F
|
||||
|
@ -37,5 +42,6 @@ keyboard_update_break_scancode:
|
|||
mov r6, 0
|
||||
mov r7, 0
|
||||
call new_event
|
||||
mov r0, 0
|
||||
keyboard_update_end:
|
||||
ret
|
||||
|
|
|
@ -1,48 +1,20 @@
|
|||
; command parser
|
||||
|
||||
; FIXME: thjs is a terrible way to do this
|
||||
monitor_shell_parse_command:
|
||||
mov r0, MONITOR_SHELL_TEXT_BUF_BOTTOM
|
||||
|
||||
; exit
|
||||
mov r1, monitor_shell_exit_command_string
|
||||
; loop over the table of commands
|
||||
mov r2, monitor_shell_command_table
|
||||
monitor_shell_parse_command_loop:
|
||||
mov r1, [r2]
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_exit_command
|
||||
|
||||
; help
|
||||
mov r1, monitor_shell_help_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_help_command
|
||||
|
||||
; jump
|
||||
mov r1, monitor_shell_jump_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_jump_command
|
||||
|
||||
; list
|
||||
mov r1, monitor_shell_list_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_list_command
|
||||
|
||||
; load
|
||||
mov r1, monitor_shell_load_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_load_command
|
||||
|
||||
; set.8
|
||||
mov r1, monitor_shell_set8_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_set8_command
|
||||
|
||||
; set.16
|
||||
mov r1, monitor_shell_set16_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_set16_command
|
||||
|
||||
; set.32
|
||||
mov r1, monitor_shell_set32_command_string
|
||||
call compare_string
|
||||
ifz jmp monitor_shell_set32_command
|
||||
; if the string matches, jump to the corresponding address in the table
|
||||
ifz jmp [r2+4]
|
||||
; otherwise, move to the next entry
|
||||
add r2, 8
|
||||
; if the entry is zero, then we have reached the end of the table
|
||||
cmp [r2], 0
|
||||
ifnz jmp monitor_shell_parse_command_loop
|
||||
|
||||
; invalid command
|
||||
mov r0, monitor_shell_invalid_command_string
|
||||
|
@ -51,6 +23,26 @@ monitor_shell_parse_command:
|
|||
|
||||
ret
|
||||
|
||||
monitor_shell_command_table:
|
||||
data.32 monitor_shell_exit_command_string
|
||||
data.32 monitor_shell_exit_command
|
||||
data.32 monitor_shell_help_command_string
|
||||
data.32 monitor_shell_help_command
|
||||
data.32 monitor_shell_jump_command_string
|
||||
data.32 monitor_shell_jump_command
|
||||
data.32 monitor_shell_list_command_string
|
||||
data.32 monitor_shell_list_command
|
||||
data.32 monitor_shell_load_command_string
|
||||
data.32 monitor_shell_load_command
|
||||
data.32 monitor_shell_reg_command_string
|
||||
data.32 monitor_shell_reg_command
|
||||
data.32 monitor_shell_set8_command_string
|
||||
data.32 monitor_shell_set8_command
|
||||
data.32 monitor_shell_set16_command_string
|
||||
data.32 monitor_shell_set16_command
|
||||
data.32 monitor_shell_set32_command_string
|
||||
data.32 monitor_shell_set32_command
|
||||
data.32 0 data.32 0
|
||||
monitor_shell_invalid_command_string: data.str "invalid command" data.8 10 data.8 0
|
||||
|
||||
; all commands
|
||||
|
@ -59,4 +51,5 @@ monitor_shell_invalid_command_string: data.str "invalid command" data.8 10 data.
|
|||
#include "monitor/commands/jump.asm"
|
||||
#include "monitor/commands/list.asm"
|
||||
#include "monitor/commands/load.asm"
|
||||
#include "monitor/commands/reg.asm"
|
||||
#include "monitor/commands/set.asm"
|
||||
|
|
|
@ -16,5 +16,6 @@ monitor_shell_help_text:
|
|||
data.str "jump | jump to address $0" data.8 10
|
||||
data.str "list | list memory contents starting at address $0" data.8 10
|
||||
data.str "load | load disk $0's sector $1 to buffer at address $2 of size $3 sectors" data.8 10
|
||||
data.str "reg | list contents of all registers" data.8 10
|
||||
data.str "set.SZ | set [$0] to $1; equivalent to `mov.SZ [$0], $1`" data.8 10
|
||||
data.8 0
|
||||
|
|
102
monitor/commands/reg.asm
Normal file
102
monitor/commands/reg.asm
Normal file
|
@ -0,0 +1,102 @@
|
|||
; reg command
|
||||
|
||||
monitor_shell_reg_command_string: data.strz "reg"
|
||||
|
||||
monitor_shell_reg_command:
|
||||
push r0
|
||||
push r1
|
||||
push r2
|
||||
push r3
|
||||
|
||||
; print the display containing all of the registers
|
||||
; r1 - used to store a pointer to the current string
|
||||
; r2 - stores the current address on the stack
|
||||
; r3 - loop counter
|
||||
mov r1, monitor_shell_reg_command_r0_str
|
||||
mov r2, [MONITOR_OLD_RSP]
|
||||
inc r2, 4
|
||||
mov r3, 0
|
||||
monitor_shell_reg_command_print_loop:
|
||||
; print the register label
|
||||
mov r0, r1
|
||||
call print_string_to_monitor
|
||||
; print the register value
|
||||
mov r0, [r2]
|
||||
call print_hex_word_to_monitor
|
||||
; adjust string pointer, stack address, and loop counter
|
||||
add r1, MONITOR_SHELL_COMMAND_R_STR_SIZE
|
||||
inc r2, 4
|
||||
inc r3
|
||||
; decide whether to print a separator or a newline by checking if the loop
|
||||
; counter is a multiple of 4
|
||||
mov r0, r3
|
||||
and r0, 0x03
|
||||
ifnz jmp monitor_shell_reg_command_print_sep
|
||||
monitor_shell_reg_command_print_newline:
|
||||
mov r0, 10
|
||||
jmp monitor_shell_reg_command_print_last_char
|
||||
monitor_shell_reg_command_print_sep:
|
||||
mov r0, ' '
|
||||
call print_character_to_monitor
|
||||
mov r0, '|'
|
||||
call print_character_to_monitor
|
||||
mov r0, ' '
|
||||
monitor_shell_reg_command_print_last_char:
|
||||
call print_character_to_monitor
|
||||
; loop again if not on last register
|
||||
cmp r3, 35
|
||||
iflt jmp monitor_shell_reg_command_print_loop
|
||||
; print rip
|
||||
mov r0, monitor_shell_reg_command_rip_str
|
||||
call print_string_to_monitor
|
||||
mov r0, [r2+1]
|
||||
call print_hex_word_to_monitor
|
||||
mov r0, 10
|
||||
call print_character_to_monitor
|
||||
|
||||
call redraw_monitor_console
|
||||
|
||||
pop r3
|
||||
pop r2
|
||||
pop r1
|
||||
pop r0
|
||||
|
||||
ret
|
||||
|
||||
const MONITOR_SHELL_COMMAND_R_STR_SIZE: 7
|
||||
monitor_shell_reg_command_r0_str: data.strz "r0: "
|
||||
monitor_shell_reg_command_r1_str: data.strz "r1: "
|
||||
monitor_shell_reg_command_r2_str: data.strz "r2: "
|
||||
monitor_shell_reg_command_r3_str: data.strz "r3: "
|
||||
monitor_shell_reg_command_r4_str: data.strz "r4: "
|
||||
monitor_shell_reg_command_r5_str: data.strz "r5: "
|
||||
monitor_shell_reg_command_r6_str: data.strz "r6: "
|
||||
monitor_shell_reg_command_r7_str: data.strz "r7: "
|
||||
monitor_shell_reg_command_r8_str: data.strz "r8: "
|
||||
monitor_shell_reg_command_r9_str: data.strz "r9: "
|
||||
monitor_shell_reg_command_r10_str: data.strz "r10: "
|
||||
monitor_shell_reg_command_r11_str: data.strz "r11: "
|
||||
monitor_shell_reg_command_r12_str: data.strz "r12: "
|
||||
monitor_shell_reg_command_r13_str: data.strz "r13: "
|
||||
monitor_shell_reg_command_r14_str: data.strz "r14: "
|
||||
monitor_shell_reg_command_r15_str: data.strz "r15: "
|
||||
monitor_shell_reg_command_r16_str: data.strz "r16: "
|
||||
monitor_shell_reg_command_r17_str: data.strz "r17: "
|
||||
monitor_shell_reg_command_r18_str: data.strz "r18: "
|
||||
monitor_shell_reg_command_r19_str: data.strz "r19: "
|
||||
monitor_shell_reg_command_r20_str: data.strz "r20: "
|
||||
monitor_shell_reg_command_r21_str: data.strz "r21: "
|
||||
monitor_shell_reg_command_r22_str: data.strz "r22: "
|
||||
monitor_shell_reg_command_r23_str: data.strz "r23: "
|
||||
monitor_shell_reg_command_r24_str: data.strz "r24: "
|
||||
monitor_shell_reg_command_r25_str: data.strz "r25: "
|
||||
monitor_shell_reg_command_r26_str: data.strz "r26: "
|
||||
monitor_shell_reg_command_r27_str: data.strz "r27: "
|
||||
monitor_shell_reg_command_r28_str: data.strz "r28: "
|
||||
monitor_shell_reg_command_r29_str: data.strz "r29: "
|
||||
monitor_shell_reg_command_r30_str: data.strz "r30: "
|
||||
monitor_shell_reg_command_r31_str: data.strz "r31: "
|
||||
monitor_shell_reg_command_rsp_str: data.strz "rsp: "
|
||||
monitor_shell_reg_command_resp_str: data.strz "resp: "
|
||||
monitor_shell_reg_command_rfp_str: data.strz "rfp: "
|
||||
monitor_shell_reg_command_rip_str: data.strz "rip: "
|
|
@ -38,7 +38,7 @@ print_hex_word_to_monitor_loop:
|
|||
add r12, r11
|
||||
movz.8 r0, [r12]
|
||||
call print_character_to_monitor
|
||||
add r1, r6
|
||||
;add r1, r6
|
||||
loop print_hex_word_to_monitor_loop
|
||||
|
||||
pop r31
|
||||
|
@ -67,7 +67,7 @@ print_hex_byte_to_monitor_loop:
|
|||
add r12, r11
|
||||
movz.8 r0, [r12]
|
||||
call print_character_to_monitor
|
||||
add r1, r6
|
||||
;add r1, r6
|
||||
loop print_hex_byte_to_monitor_loop
|
||||
|
||||
pop r31
|
||||
|
|
|
@ -1,43 +1,11 @@
|
|||
; debug monitor
|
||||
|
||||
; only call this from system_breakpoint_handler!
|
||||
invoke_monitor:
|
||||
; return if we're already in the monitor
|
||||
cmp [0x000003FC], monitor_vsync_handler
|
||||
ifz jmp invoke_monitor_aleady_in_monitor
|
||||
|
||||
push r31
|
||||
push r30
|
||||
push r29
|
||||
push r28
|
||||
push r27
|
||||
push r26
|
||||
push r25
|
||||
push r24
|
||||
push r23
|
||||
push r22
|
||||
push r21
|
||||
push r20
|
||||
push r19
|
||||
push r18
|
||||
push r17
|
||||
push r16
|
||||
push r15
|
||||
push r14
|
||||
push r13
|
||||
push r12
|
||||
push r11
|
||||
push r10
|
||||
push r9
|
||||
push r8
|
||||
push r7
|
||||
push r6
|
||||
push r5
|
||||
push r4
|
||||
push r3
|
||||
push r2
|
||||
push r1
|
||||
push r0
|
||||
|
||||
; set the vsync handler to our own and reenable interrupts
|
||||
mov [MONITOR_OLD_VSYNC_HANDLER], [0x000003FC]
|
||||
mov [0x000003FC], monitor_vsync_handler
|
||||
|
@ -94,39 +62,6 @@ exit_monitor:
|
|||
|
||||
call enable_cursor
|
||||
|
||||
pop r0
|
||||
pop r1
|
||||
pop r2
|
||||
pop r3
|
||||
pop r4
|
||||
pop r5
|
||||
pop r6
|
||||
pop r7
|
||||
pop r8
|
||||
pop r9
|
||||
pop r10
|
||||
pop r11
|
||||
pop r12
|
||||
pop r13
|
||||
pop r14
|
||||
pop r15
|
||||
pop r16
|
||||
pop r17
|
||||
pop r18
|
||||
pop r19
|
||||
pop r20
|
||||
pop r21
|
||||
pop r22
|
||||
pop r23
|
||||
pop r24
|
||||
pop r25
|
||||
pop r26
|
||||
pop r27
|
||||
pop r28
|
||||
pop r29
|
||||
pop r30
|
||||
pop r31
|
||||
|
||||
ret
|
||||
|
||||
exit_monitor_and_jump:
|
||||
|
@ -140,39 +75,6 @@ exit_monitor_and_jump:
|
|||
; save the jump address in a temporary location
|
||||
mov [MONITOR_OLD_RSP], r0
|
||||
|
||||
pop r0
|
||||
pop r1
|
||||
pop r2
|
||||
pop r3
|
||||
pop r4
|
||||
pop r5
|
||||
pop r6
|
||||
pop r7
|
||||
pop r8
|
||||
pop r9
|
||||
pop r10
|
||||
pop r11
|
||||
pop r12
|
||||
pop r13
|
||||
pop r14
|
||||
pop r15
|
||||
pop r16
|
||||
pop r17
|
||||
pop r18
|
||||
pop r19
|
||||
pop r20
|
||||
pop r21
|
||||
pop r22
|
||||
pop r23
|
||||
pop r24
|
||||
pop r25
|
||||
pop r26
|
||||
pop r27
|
||||
pop r28
|
||||
pop r29
|
||||
pop r30
|
||||
pop r31
|
||||
|
||||
jmp [MONITOR_OLD_RSP]
|
||||
|
||||
invoke_monitor_aleady_in_monitor:
|
||||
|
|
16
vsync.asm
16
vsync.asm
|
@ -15,6 +15,9 @@ system_vsync_handler:
|
|||
call keyboard_update
|
||||
cmp.8 [UPDATE_ICON], 0
|
||||
ifnz call icon_update
|
||||
; check if monitor should be started
|
||||
cmp r0, 0
|
||||
ifnz jmp system_vsync_handler_breakpoint
|
||||
|
||||
pop r7
|
||||
pop r6
|
||||
|
@ -25,3 +28,16 @@ system_vsync_handler:
|
|||
pop r1
|
||||
pop r0
|
||||
reti
|
||||
|
||||
system_vsync_handler_breakpoint:
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
pop r4
|
||||
pop r3
|
||||
pop r2
|
||||
pop r1
|
||||
pop r0
|
||||
; breakpoint handler expects that there is an extra 4 bytes on the stack
|
||||
sub rsp, 4
|
||||
jmp system_breakpoint_handler
|
||||
|
|
Loading…
Reference in New Issue
Block a user