*----------------------------------------------------------- * Title : Example of warm-reset-proof routine for Atari ST * Written by : z80andrew * Date : 2023-07-11 * Description: This is an example of a routine which prints a message to the screen * when the conditions for a reset-proof application are satisfied according * to Atari TOS. * This uses code from TOS derived from: https://github.com/sarnau/AtariSTRomListings/blob/master/TOS206,206STBook,206.asm#L2753 *----------------------------------------------------------- ORG $1000 START: ; first instruction of program bsr configresapp jmp runresapps printstring: lea MESSAGE,a1 move.b #14,d0 trap #15 rts configresapp: lea $80000,a0 ; start at the top of the address space (512K) suba.w #$200,a0 move.l #$12123456,(a0) move.l a0,4(a0) move.l #printstring,8(a0) move.w #0,12(a0) ; clear address used for checksum so it doesn't interfere with calculations ; Calculate checksum clr.w d0 movea.l a0,a1 move.w #$ff,d1 ; checksum over 256 words configresappschecksum: add.w (a1)+,d0 ; checksum over the block dbra d1,configresappschecksum move.w #$5678,d1 sub.w d0,d1 move.w d1,12(a0) rts *+ * runresapps - search address space for 512-byte resident code chunks * *- runresapps: lea $80000,a0 ; start at the top of the address space (512K) runresappsl: suba.w #$200,a0 cmpa.w #$400,a0 ; reach the lower bottom? bls.s runresappsx ; (bail out) cmpi.l #$12123456,(a0) ; check for magic bne.s runresappsl ; (no magic -> next block) cmpa.l 4(a0),a0 ; second long is equal the base address of the block? bne.s runresappsl ; (no -> next block) clr.w d0 movea.l a0,a1 move.w #$ff,d1 ; checksum over 256 words runresappsc: add.w (a1)+,d0 ; checksum over the block dbra d1,runresappsc cmp.w #$5678,d0 ; magic checksum? bne.s runresappsl ; (no -> next block) move.l a0,-(sp) ; save current address move.l 8(a0),d0 ; Easy68K doesn't support indrect address branching movea.l d0,a0 ; so we load it into a0 like so. jsr (a0) ; call code block movea.l (sp)+,a0 ; continue with next block bra.s runresappsl runresappsx: SIMHALT ; halt simulator MESSAGE dc.b 'Resident app verified',0 END START ; last line of source *~Font name~Courier New~ *~Font size~10~ *~Tab type~1~ *~Tab size~4~