Skip to content

Commit

Permalink
[a8 dos] Exit via DOSVEC (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwedgwood committed May 30, 2024
1 parent e4aa926 commit 8ed2b87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mos-platform/atari8-dos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ if(NOT CMAKE_CROSSCOMPILING)
return()
endif()

add_platform_library(atari8-dos-crt0)
add_platform_library(atari8-dos-crt0 _Exit.c)
merge_libraries(atari8-dos-crt0
common-copy-zp-data
common-zero-bss
common-exit-return
common-exit-custom
)
target_link_libraries(atari8-dos-crt0 PRIVATE common-asminc)
8 changes: 8 additions & 0 deletions mos-platform/atari8-dos/_Exit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Atari DOS 2.5 (etc?) does not correctly detect if a chunk after the first
// clobbers the DUP, so it may crash after a RTS to DOS. Even if a DUP clobber
// is detected, the effect is the same as a JMP through DOSVEC, so may as well.
_Noreturn void _Exit(int status) {
// JMP (DOSVEC)
asm volatile("jmp ($a)");
__builtin_unreachable();
}

0 comments on commit 8ed2b87

Please sign in to comment.