From alsplace at pobox.com Sat Nov 1 11:26:03 2025 From: alsplace at pobox.com (Allen Huffman) Date: Sat, 1 Nov 2025 10:26:03 -0500 Subject: [Coco] DEF USR and strings? In-Reply-To: <20251031214338.GL10453@brevard.conman.org> References: <20251029221816.GA10453@brevard.conman.org> <20251030015204.GC10453@brevard.conman.org> <20251030034927.GE10453@brevard.conman.org> <3372EF76-D9A3-47B3-8FAC-9C4D12B78F85@pobox.com> <20251030195856.GF10453@brevard.conman.org> <774E0588-C8FD-4DAE-8AFF-72F3F1C47E3D@pobox.com> <20251031214338.GL10453@brevard.conman.org> Message-ID: <33F75AB0-52A8-4DDD-92B3-B83966657D65@pobox.com> > On Oct 31, 2025, at 4:43?PM, Sean Conner via Coco wrote: > > Based on all that, I think the best method might be (completely untested): > > mycode cmpx #mycode > beq called_by_exec > ; otherwise, assume called by USR/USRn Indeed. Needing to know the version of BASIC is a hassle. I did a test: start cmpx #start ;* Called by EXEC? beq yes leax nomsg,pcr lbsr print rts yes leax yesmsg,pcr lbsr print rts nomsg fcc "YES" fcb 0 yesmsg fcc "NO" fcb 0 If I EXEC &H3E00 is prints ?NO?. Then if I EXEC (it remembers that last address) is prints ?YES?. Almost. I did a STX 1024 so I could PEEK the value from BASIC. With EXEC xxxx, it has the xxxx value there. With just EXEC after that, it has ABAB. That seems to be the address of the EXEC token in Color BASIC. ABAB A5 3E FDB EXEC EXEC A2 I?ll check that 9D location next. Thanks for the ideas! - A From alsplace at pobox.com Sat Nov 1 14:05:14 2025 From: alsplace at pobox.com (Allen Huffman) Date: Sat, 1 Nov 2025 13:05:14 -0500 Subject: [Coco] DEF USR and strings? In-Reply-To: <20251031214338.GL10453@brevard.conman.org> References: <20251029221816.GA10453@brevard.conman.org> <20251030015204.GC10453@brevard.conman.org> <20251030034927.GE10453@brevard.conman.org> <3372EF76-D9A3-47B3-8FAC-9C4D12B78F85@pobox.com> <20251030195856.GF10453@brevard.conman.org> <774E0588-C8FD-4DAE-8AFF-72F3F1C47E3D@pobox.com> <20251031214338.GL10453@brevard.conman.org> Message-ID: Okay, a bit trickier, but I think I figured it out: > On Oct 31, 2025, at 4:43?PM, Sean Conner via Coco wrote: > > Based on all that, I think the best method might be (completely untested): > > mycode cmpx #mycode > beq called_by_exec > ; otherwise, assume called by USR/USRn > > Good luck. For debugging, I had my code take X and store it in the first two bytes of the 32 column screen. Then I would load what was in the $9D (EXEC address) and store it next to that. From looking at the pattern: EXEC &HABCD ?$ABCD is in X, and in $9D (EXECJP) EXEC (by itself) ?$ABAB is in X, and $ABCD is in $9D. Else, called by USR. How?s this? ;* lwasm whocalled.asm -fbasic -owhocalled.bas --map ;* decb copy -2 whocalled.bin drive0.dsk,WHOCALLD.BIN ORGADDR equ $3e00 ;* Where program loads in memory. ;* Absolute addresses of items in RAM variables. EXECJP equ $9d location of jump address for EXEC VIDRAM equ $400 VIDEO DISPLAY AREA ;* Absolute addresses of ROM calls. CHROUT equ $A002 org ORGADDR ;* This code expects to have been called by USRx(x). start cmpx #start ;* called by "EXEC xxxx"? beq fromexec ;* if yes, goto fromexec cmpx #$abab ;* called by "EXEC"? bne fromusr ;* if no, must be USR. goto fromusr ldx EXECJP ;* get EXEC address cmpx #start ;* called by "EXEC xxxx"? beq fromexec ;* if yes, goto from exec fromusr leax usrmsg,pcr lbsr print rts fromexec leax execmsg,pcr lbsr print rts ;* PRINT subroutine. Prints the 0-terminated string pointed to by X plus CR. print lda ,x+ beq printdone jsr [CHROUT] bra print printdone lda #13 jsr [CHROUT] rts usrmsg fcc "FROM USR" fcb 0 execmsg fcc "FROM EXEC" fcb 0 end