|
Post by stiggity on May 16, 2022 21:23:27 GMT
What would I have to do to find out, by calling a routine that simply reads from the stack and calculates how many GOSUB's are remaining on the stack? This may seem simple, but I'm having a difficult time. Any sort of assistance is greatly appreciated.
If this is possible, removing all gosub calls from stack, and or just remove 1 per call?
|
|
|
Post by stiggity on May 17, 2022 16:14:33 GMT
This seems to be doing the trick, but im wondering How-Many flaws it may/or might have... LDA #$ ; FIND NEXT RETURN ON BASIC STACK JSR $4FAA ; SEARCH FOR TOKEN ON STACK BEQ + ; FOUND IT RTS + JSR $5050 ; SAVE NEW STACK LDY #5 JMP $5059 ; INCREMENT STACK POINTER if im certain to bank qall roms in, call this and return, is it suitable for simply removing, if any, 1 gosub on the stack?
|
|
|
Post by stiggity on May 17, 2022 16:15:52 GMT
lda #141 ($ 8 D is interpreted as a emoji...)
|
|
|
Post by wendling on May 21, 2022 7:42:05 GMT
This is how I would do it and pfew, this took me a while to get it right and I am not 100% sure about it:
// sys 4864 ; get number of gosubs, store in $fb
*=$1300
ldx #$00 ;set number of gosubs to zero
lda $7d ;start at basic runtime stackpointer sta $fb lda $7e sta $fc
ldy #$00 entry: lda ($fb),y beq done ;end of stack = zero cmp #$eb ;check for “DO” beq add5 cmp #$81 ;check for “FOR” beq add18 inx ; not a DO or FOR then number of GOSUBs + 1 add5: lda #$05 ;skip 5 bytes for DO and GOSUB bne add add18: lda #$12 ;skip 18 bytes for FOR
add: clc ;add for next entry adc $fb sta $fb lda $fc adc #$00 sta $fc
bne entry ;next entry
done: stx $fb ;number of gosubs rts
// sys5120,x ; remove x gosubs
*=$1400
sta $fb ; number of gosubs to remove
pla ; save return address from the SYS to this routine sta $fc pla sta $fd
loop: pla ; remove from processor stack: $4af6 = execute next basic statement pla jsr $5264 ; perform “RETURN”. Cannot jsr to $5262 because of the jsr and the PLA's dec $fb bne loop ; next gosub to remove
lda $fd ; restore the SYS return address pha lda $fc pha rts
// demo
5 fort=1to8 6 print 10 gosub20:print"one":next:end 20 gosub30:print"two":return 30 gosub40:print"three":return 40 gosub50:print"four":return 50 gosub60:print"five":return 60 gosub70:print"six":return 70 gosub80:print"seven":return 80 gosub90:print"eight":return 90 sys5120,t 95 print"never reached"
|
|
|
Post by stiggity on May 23, 2022 0:58:24 GMT
Wendling!!!! Oi! Aye!! again, another surgical break down of a technique to accomplish the task!!!!! Heres another question.. RN when i read free blocks i open1,8,0,"$ " P=reverse BLACK Color, call the ML and free blocks are returned into a string variable!! Also, to get a directory entry, I open2,8,0,"$"+filename$, call the ML and a single directory entry is retrieved into a variable. What would the ML syntax look like to open The Above Channels?? Assuming "filename$" is in a buffer, with length determined??? And the "$ " P equaling a reverse BLACK petscii character, how else can i open a directory to find free blocks. I dont need the ML to actually find how many free bocks, nor retrieve the directory entry??? Thanks Wendling!!, your replies are like going to a copy party back in 1987!!! always great to see, and learning something, leaving with something new!! Thanks You Very Much!!!
|
|
|
Post by wendling on May 23, 2022 5:59:14 GMT
I will look into this, but for now maybe this will help you: archive.org/stream/1571UsersGuide/1571_Users_Guide_djvu.txtpage 66: CHAPTER 7 DIRECT ACCESS COMMANDS A TOOL FOR ADVANCED USERS
page70 THE BUFFER POINTER The buffer pointer points to where the next READ or WRITE will begin within a disk memory buffer. By moving the buffer pointer, you can access individual bytes within a block in any order.
|
|
|
Post by wendling on May 23, 2022 7:27:45 GMT
An quick example how to read the occupied blocks of the first two files in the directory with direct access and the buffer pointer:
5 rem read how many blocks are occupied by the first two files (<256 blocks) 10 open15,8,15,"b-r:5;0;18;1": rem block read first sector of directory 20 open5,8,5,"#": rem open direct access channel 30 print#15,"b-p",5,30: rem get blocks occupied by file 1 (5=open access channel number, 30=location in drive buffer of occupied blocks) 40 get#5,a$:f1=asc(a$) 50 print#15,"b-p",5,62: rem get blocks occupied by file 2 60 get#5,a$:f2=asc(a$) 70 print"free blocks 664 -";f1+f2;"=";664-f1-f2 80 close5 90 close15
|
|
|
Post by stiggity on May 23, 2022 14:09:49 GMT
Thank You, Wendling.. altho, i'm a bit confused.. I don't really need the BASIC syntax on opening the channel#15, or data channels. Finding the ML equivalent of open1,8,0,"$:(P)" (P)=REVERSE BLACK and
open2,8,0,"$"+filename$
in ASM. filename$ is a buffer with length determined. i guess finding the ASM equivalent of.
open15,8,15 and print#15,filename$
would also be something else i don't know how to accomplish, right now... i gave the link you sent me a read. Whoah!!! I may have not dug deep enough, but it looks like all BASIC
Your help is greatly appreciated, Wendling!!!
|
|
|
Post by wendling on May 24, 2022 5:24:20 GMT
Stiggity,
This drive business is too difficult for me, I pass on this one, Sorry.
|
|
|
Post by wendling on May 24, 2022 13:37:11 GMT
Remembered my basic text pointer trick: (not taking in account ram under rom, otherwise use jsrfar for the OPEN jsr).
;open 1,8,0,"$p" p=chr$(144) ;sys4864/jsr$1300 then call your ML
*=$1300
lda $3e ;save basic text pointer pha lda $3d pha
lda #<buffer ;redirect basic text pointer to buffer sta $3d lda #>buffer sta $3e
jsr $918d ;perform BASIC statement OPEN on buffer
pla ;restore basic text pointer sta $3d pla sta $3e rts
buffer byte $31,$2c,$38,$2c,$30,$2c,$22,$24,$90,$22,$00 ; 1,8,0,"$p"0
---------------------------------
; open 2,8,0,"$filename" ; filename in filenm ; lenght in len ; sys4864/jsr$1300 then call your ML
*=$1300
lda $3e ;save basic text pointer pha lda $3d pha
lda #<buffer ;redirect basic text pointer to buffer sta $3d lda #>buffer sta $3e
ldy #00 ;put filename at the end of buffer after the $ loop: lda filenm,y sta buffer+8,y iny cpy len bne loop lda #$22 ;end buffer with a quote and a zero sta buffer+8,y iny lda #$00 sta buffer+8,y
jsr $918d ;perform BASIC statement OPEN on buffer
pla ;restore basic text pointer sta $3d pla sta $3e rts buffer byte $32,$2c,$38,$2c,$30,$2c,$22,$24 ; 2,8,0,"$
;leave room after buffer for filename + 2 end bytes = max 18 bytes
|
|