cpu 6502
nam multiply
page 128,128
	
* = $0900  ; assemble at $900
code
	READST   = $FFB7
	SETLFS   = $FFBA
	SETNAM   = $FFBD
	OPEN     = $FFC0
	CLOSE    = $FFC3
	CHKIN    = $FFC6
	CHKOUT   = $FFC9
	CLRCHN   = $FFCC
	CHRIN    = $FFCF
	CHROUT   = $FFD2
	LOAD     = $FFD5
	SAVE     = $FFD8
	STOP     = $FFE1
	GETIN    = $FFE4
	CLALL    = $FFE7

	;; display random strings
	;; test of concept
	;; mkpellegrino
	;;

.begin	ldy #$00
.frst0	lda strings, y
	beq .frst1
	jsr $FFD2
	iny
.frst1	bne .frst0

.done	jsr .fill
	rts

	nop
	nop
	nop

	;; generate a random number
.rnd    lda $DC04   ;CIA#1  Timer A  Lo byte 
        eor $DC05   ;CIA#1  Timer A  Hi byte 
        eor $DD04   ;CIA#2  Timer A  Lo byte 
        adc $DD05   ;CIA#2  Timer A  Hi byte 
        eor $DD06   ;CIA#2  Timer B  Lo byte 
        eor $DD07   ;CIA#2  Timer B  Hi byte 
        rts

	nop
	nop
	nop
	

	;; create a random equation
	;; by storing random numbers below
.fill	ldx #$04
.fll0	jsr .rnd
	sta xis, x
	cpx #$00
	beq .fll1
	dex
	jmp .fll0
.fll1	rts

	nop

	;; (sign 1) cofx * xis (sign 2) cofy * yis = (sign 3) zis
	;; solve for xory
	db $FF, $FF
xis	db $00
yis	db $00
cofx	db $00
cofy	db $00
zis	db $00
sign1	db $00
sign2	db $00
sign3	db $00
xory	db $00
	db $FF, $FF

strings asc "THIS IS THE FIRST STRING\0"
	asc "THIS IS THE SECOND STRING\0"
	asc "THIS IS THE THIRD STRING\0"	
	asc "THIS IS THE FOURTH STRING\0"

	db $DE, $AD

STROUT	 PLA
         TAX              ;Lo byte
         PLA
         INX
         BNE .PRINT
         CLC
         ADC #01
.PRINT   STA .LOOP+2
.LOOP    LDA $A000,X
         BEQ .DONE2
         JSR $FFD2
         INX
         BNE .LOOP
         INC .LOOP+2
         BNE .LOOP

.DONE2    LDA .LOOP+2
         PHA              ;hi byte
         TXA
         PHA              ;lo byte
         RTS
code