[comp.sys.cbm] Save a seq file in assembly

piskacrj@mentor.cc.purdue.edu (Robert J Piskac) (11/27/90)

I am learning machine language on the C= 128.  

I have been trying for some time to write a save routine in assembly.
What am I doing wrong?  I keep getting a file not found error.
I am trying to write to a new file called file.test which is a 
seq file.



savefile .byte "file.test,s,w"
;=======================
save   	lda #$0e
	ldx #<savefile
	ldy #>savefile
	jsr setnam
	ldx #0
	jsr setbnk
	lda #3
	ldx #$08
	ldy #0
	jsr setlfs
	jsr open
	bcs error3  ; error sub routine deleted
 	ldx #3
	jsr ckout
	ldy #$00
;
;    much deleted
;
eofsave	lda #3
	jsr close
	jsr clrchn
	jsr bank14
	rts

Thank you

Bob

piskacrj@mentor.cc.purdue.edu

bhelf@e40-008-11.MIT.EDU (Bill Helfinstine) (11/28/90)

In article <1854@mentor.cc.purdue.edu> piskacrj@mentor.cc.purdue.edu (Robert J Piskac) writes:
>	lda #3
>	ldx #$08
>	ldy #0
>	jsr setlfs
If you are going to do a save, the proper secondary address to use is 1.
If you use 0, the disk drive thinks you are trying to do a load, and gets
confused.

So, change it to

         lda #3
         ldx #8
         ldy #1
         jsr setlfs



Bill Helfinstine
bhelf@athena.mit.edu

cs4344af@evax.arl.utexas.edu (Fuzzy Fox) (11/28/90)

In article <1854@mentor.cc.purdue.edu> piskacrj@mentor.cc.purdue.edu (Robert J Piskac) writes:
>	lda #3
>	ldx #$08
>	ldy #0
>	jsr setlfs

You should not use addresses 0 or 1 when you are using data files
(accessed through the OPEN, CKOUT, etc. calls).  Choose a number from
2-14 instead.  For instance, LDY #3 would work great above.

>eofsave	lda #3
>	jsr close
>	jsr clrchn

You have the above routines called in the wrong order.  You should call
CLRCHN first to flush the last characters to the disk and shut down the
communication channel, then you can CLOSE it.

					Fuzzy