diff --git a/App2/AsmTest.s b/App2/AsmTest.s new file mode 100644 index 0000000000..4de320057f --- /dev/null +++ b/App2/AsmTest.s @@ -0,0 +1,128 @@ +# Completely pointless test program to figure out how MacsBug function names work + +# The format for MacsBug function names: + +# if strlen(name) < 32: +# rts | jmp (%a0) // return instruction [required] +# .byte 0x80 + strlen(name) +# .ascii name +# .align 2,0 +# .short literalBytes +# // literalBytes of data +# else: // 32 <= strlen(name) <= 255 +# rts | jmp (%a0) // return instruction [required] +# .byte 0x80 +# .byte strlen(name) +# .ascii name +# .align 2,0 +# .short literalBytes +# // literalBytes of data + + .section .text.startup,"ax",@progbits + .align 2 + .globl main + .type main, @function +main: + link.w %fp,#0 + dc.w 0xa9ff + moveq #0,%d0 + + + move.w #42, -(%sp) + bsr foopas + + move.w #42, -(%sp) + bsr foopas2 + + move.w #42, -(%sp) + bsr barpas + + bsr quux + + # Some weird control flow to see under what + # circumstances MacsBug recognizes function names: + bra .L1 + unlk %fp +.L2: + rts +.L1: + moveq #1,%d0 + unlk %fp + bra .L2 + + # MacsBug recognizes the function name only + # after rts and a few other instructions, + # so we just add a rts + rts + + .byte 132 + .ascii "main" + .align 2,0 + # size of literals following function name + .short 0 + .size main, .-main + + + +foopas: + link.w %fp,#42 + unlk %fp + move.l (%sp)+, %a0 + addq #2, %sp + + # MacsBug knows about jmp (%a0) + jmp (%a0) + .byte 134 + .ascii "foopas" + .align 2,0 + # size of literals following function name + .short 0 + .size foopas, .-foopas + +foopas2: + link.w %fp,#42 + unlk %fp + move.l (%sp)+, %a1 + addq #2, %sp + + # MacsBug doesn't know about jmp (%a1) + jmp (%a1) + .byte 135 + .ascii "foopas2" + .align 2,0 + # size of literals following function name + .short 0 + .size foopas2, .-foopas2 + + + +barpas: + link.w %fp,#42 + unlk %fp + move.l (%sp)+, %a1 + addq #2, %sp + jmp (%a1) + + # ... but adding an extra rts doesn't hurt. + rts + .byte 134 + .ascii "barpas" + .align 2,0 + # size of literals following function name + .short 0 + .size barpas, .-barpas + + +quux: + link.w %fp,#42 + unlk %fp + rts + rts + .byte 152 + # MacsBug doesn't recognize names with weird characters + .ascii "quux::operator()(int)" + .align 2,0 + # size of literals following function name + .short 0 + .size quux, .-quux + diff --git a/App2/CMakeLists.txt b/App2/CMakeLists.txt index d34e031109..4b442e8a28 100644 --- a/App2/CMakeLists.txt +++ b/App2/CMakeLists.txt @@ -34,6 +34,13 @@ add_executable(Test add_executable(HelloWorld hello.c ) + +enable_language(ASM) +add_executable(AsmTest + AsmTest.s + ) +set_target_properties(AsmTest PROPERTIES LINKER_LANGUAGE C) + #target_link_libraries(Test :retrocrt.o) target_link_libraries(Test retrocrt) @@ -50,6 +57,14 @@ add_custom_command( DEPENDS HelloWorld) add_custom_target(HelloWorldAPPL ALL DEPENDS HelloWorld.bin) +target_link_libraries(AsmTest retrocrt) +add_custom_command( + OUTPUT AsmTest.bin + COMMAND ${MAKE_APPL} -c AsmTest -o AsmTest + DEPENDS AsmTest) +add_custom_target(AsmTestAPPL ALL DEPENDS AsmTest.bin) + + set(UPLOAD_URL "" CACHE STRING "ftp url to upload to") if(UPLOAD_URL)