ampersand_usr: add code here

hopefully these examples will be useful in the future
This commit is contained in:
Vince Weaver 2025-02-25 20:16:29 -05:00
parent c7d4ec9bf3
commit 05b6d71430
6 changed files with 163 additions and 0 deletions

View File

@ -0,0 +1,43 @@
include ../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../linker_scripts
EMPTYDISK = ../../empty_disk
all: starpath.dsk ANDOR
$(DOS33):
cd ../../utils/dos33fs-utils && make
starpath.dsk: $(DOS33) HELLO STARPATH.BAS
cp $(EMPTYDISK)/empty.dsk starpath.dsk
$(DOS33) -y starpath.dsk SAVE A HELLO
$(DOS33) -y starpath.dsk SAVE A STARPATH.BAS
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
STARPATH.BAS: starpath.bas
$(TOKENIZE) < starpath.bas > STARPATH.BAS
####
ANDOR: andor.o
ld65 -o ANDOR andor.o -C $(LINKERSCRIPTS)/apple2_300.inc
andor.o: andor.s
ca65 -o andor.o andor.s -l andor.lst
###
clean:
rm -f *~ *.o HELLO STARPATH.BAS ANDOR *.lst

View File

@ -0,0 +1,22 @@
Some experiments with using & and USR() to call into assembly
language from BASIC.
Neither is very convenient when sizecoding.
; When &/ampersand call
; jumps to address $3F5 (applesoft already has a placeholder jmp there)
; when called next char/token in A (so can easily do things like &PLOT)
; can't return anything unless you look up a variable by name and
; write to the pointer
; USR() can take one argument, returns value
; jumps to $0A in zero page, which is usually a jump
; to a USER handler. BASIC is set up to illegal quant error
; by default
; need to manipulate the FAC accumulator to handle input/return
https://mirrors.apple2.org.za/ftp.apple.asimov.net/documentation/magazines/misc/theappleorchard_v1n1_applesoftinternalentrypoints_ocr.pdf
https://6502disassembly.com/a2-rom/Applesoft.html
https://wiki.reactivemicro.com/images/f/f7/Applesoft_II_2019.pdf

View File

@ -0,0 +1,54 @@
; calculates &X,Y,Z,C
; C = (X|Y)&Z
; Routine for calling from &
; when called next char/token in A
; can't return anything unless you look up a variable by name
; and write to it
; USER() can take one argument, returns value
; dump with od -t u1 ./ANDOR
VARPNTL = $83
VARPNTH = $84
FRMEVL = $DD7B
GETADDR= $E752
CHKCOM = $DEBE
SNGFLT = $E301
PTRGET = $DFE3 ; returns pointer to variable in VARPNT and (Y,A)
MOVMF = $EB2B
andor:
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $50
sta $24
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $50 ; A5 50
sta $25 ; 85 50
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $24 ; A5 24
ora $25 ; 05 25
and $50 ; 25 50
sta $24
jsr PTRGET ; 20 E3 DF
ldy $24 ; A8
jsr SNGFLT ; 20 01 E3 unsigned Y -> FAC
ldx VARPNTL ;VARPNT
ldy VARPNTH ;VARPNT+1
jmp MOVMF

View File

@ -0,0 +1,2 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"

View File

@ -0,0 +1,12 @@
0FOR I=0 TO 57:READ D:POKE 768+I,D:NEXT:POKE 1014,0:POKE 1015,3
1DIML(16):FORI=0TO14:READL(I):NEXT:GR:POKE49234,0
2FORY=0TO47:FORX=0TO39:D=I
3Z=Y*4*D:T=X*6-D:IFT<0THENC=31:A=X*6+Z:&0,A,255,A:GOTO8
4&T*D/256,Z/256,D+F,C:D=D+1:A=0:IFC<16THEN3
8IFA>6THENC=Y/4+32
9COLOR=L(C/2-8):PLOTX,Y:NEXTX,Y:F=F+1:GOTO2
100 DATA 32,123,221,32,82,231,32,190,222,165,80,133,36,32,123,221
110 DATA 32,82,231,32,190,222,165,80,133,37,32,123,221,32,82,231
120 DATA 32,190,222,165,36,5,37,37,80,133,36,32,227,223,164,36
130 DATA 32,1,227,166,131,164,132,76,43,235
140 DATA0,5,10,5,10,7,15,15,2,1,3,9,13,12,4,4

View File

@ -0,0 +1,30 @@
.org 300
FRMEVL = $DD7B
GETADDR= $E752
CHKCOM = $DEBE
SNGFLT = $E301
andor:
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $50
sta $24
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $50 ; A5 50
sta $25 ; 85 50
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
jsr CHKCOM ; 20 BE DE move past comma
lda $50 ; A5 50
ora $24 ; 05 24
and $25 ; 25 25
tay ; A8
jmp SNGFLT ; 20 01 E3 unsigned Y -> FAC