Jump to content
IGNORED

DSRLINK Code Tutorial


TheBF

Recommended Posts

regarding my 1000 bytes in my CRAM..

Ive got 40 col screens and they total 1000 bytes

if I read more ill overlap into my SNPS2 page or 3, 4.

could I just PAD the following 28 BYTES with something? would that make things easier?

 

ill just have to place something in my code during a READ that deletes them out

Edited by GDMike
Link to comment
Share on other sites

ill set my VMBR to read my CRAM PAGE and get it to >1000 and set that routine up.

 

ive already setup my routine for my SNPS1-4. as R4(record counter increases, I move only the coresponding 1000 bytes and pad 28 bytes to follow, I have another counter,R3 that counts up to 4 and places R3 into PAGE at every increment, then it resets to 1 and SAVES again to PAGE BUT increases my SAMS page >0100 and sets my correct SNPS1-4 again for moving again. anyway, it adjusts my SAMS pages to make sure im moving the right data in sequence when its time.

 

 

 

Edited by GDMike
Link to comment
Share on other sites

ive got my data over to the VRAM Buffer @>1000

R3 contains my pages SNPS1-4, BUT one at a tiime as its going to loop AFTER I do a BL @ DSR then it will incremnt my record counter and adjust what pages need to be moved again, and loop until SAMS page ### OR EOF, OR no room on DISK, BUT hopefully I can plan to save out the DATA UP TO disk Full or prior!

I have SBUFF1 EQU >FE4

 

RFPRC  MOV  R3,R1        * CRAM DATA
       LI   R0,SBUFF     * VRAM BUFFER
       LI   R2,1000
       BLWP @VMBW
       LI   R0,SBUFF1
       LI   R1,PADD      * 28 SPACES
       LI   R2,28
       BLWP @VMBW

 

Edited by GDMike
Link to comment
Share on other sites

I added some things and I had to rename some of my previous labels, as some interfered with LABELS i was already using, IF the label IS NOT listed here, its existence is in another file, but it does exist.

i just wanted to get everything out into the post that ive gotten made so far

NOTE: DSRS is the entry point and Ive stopped at STOP because, well, im not sure what to do at this point. I do know, I tried to run this and received ERROR and I was returned back to my SNP program and everything was normal. BUT no write to DISK occured.

****************************************
* FILEM -  FILE MANAGAMENT  06/04/20   *
*                                      *
*  LAST UPDATE: 10/23/20               *
* HIST:FIX ERRROR HONK TIMING          *
* NEED: SAVE PAB SETUP                 *
*                                      *
****************************************
* BYTE 1 /0=OPEN 1 = CLOSED
* BYTE 2 FILE TYPE >12 =OUTPUT,VARIABLE DISPLAY
* NEXT POSITION=BUFFER ADDRESS
* NEXT RECORD LENGTH >50 = 80 BYTES
* NEXT CHARACTER COUNT
* NEXT RECORD NUMBER
* NEXT CASSETTE OFFSET
* LAST IS FILELENGTH DESCRIPTOR LENGTH
* NOTE: FILE DESCRIPTOR LENGTH
*       FOR FILE: 'DSK1.FILE1' = 10 >0A
TLOAD  TEXT 'LOAD DSK  '
 
***
*
* SAVE DSK FILE
*
***
GFERR1 B    @GFERR
DSRS   LI   R1,>1100     * SET TO PAGE 1 SAMS
       MOV  R1,@BANK#
       CLR  @PAGE
       INC  @PAGE        * SET PAGE TO 1
       LI   R0,929
       CLR  R2
       INC  R2           * R2=1
       LI   R3,>3000     * "0"
       BLWP @VSBR        * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME IN R2
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,>3900     * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,>2E00     * NOW ITS LEGAL, CONTINUE LOOKIN SG FOR "." PERIOD MARK
       INC  R0
       INC  R2           * R2=2
       BLWP @VSBR
       CB   R1,R3
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R0
       INC  R2           * R2=3
       LI   R3,>4100     * LOOKING FOR A CHAR VALUE UPPER A-Z
       BLWP @VSBR
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,>5A00     * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,>2000     * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  INC  R0
       INC  R2
       BLWP @VSBR
       CB   R1,R3        * FOUND END OF NAME YET?, NO, KEEP LOOKING
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,2         * WE ADD IN THE "DSK" 3 BYTES TO GET OUR FULL DESCRIP #
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR
 
* START PROCESSING...
 
       LI   R0,120
       LI   R1,>2000     * CLEAR SCREEN AREA
CSVA   BLWP @VSBW
       INC  R0
       CI   R0,960
       JLT  CSVA
       BL   @BEEP
       LI   R0,324       * MESSAGE "SAVING..."
       LI   R1,SVMG
       LI   R2,12
       BLWP @VMBW
       LI   R0,337
       LI   R1,FLNM
       MOV  @COUNTP,R2
       BLWP @VMBW
 
* DO THE WRITE!
       LI   R5,>1000     * USED T SET BANK#
       CLR  R3
       LI   R0,PBAD
       LI   R1,FSPAB
       MOVB @COUNTP,R2
       SRL  R2,8
       AI   R2,10
       BLWP @VMBW
       CLR  R4           * RECORD COUNTER
       AI   R5,>0100     * SET BANK#
       MOV  R5,@BANK#    * INITIALLY >1100
       INC  R3           * R3=PAGE# 1-4
       MOV  R3,@PAGE
       INC  R4           * IS A 1 THE FIRST TIME
RFPB   BL   @GTBNK       * GET THE BANK SET TO >1100 AND PAGE TO 1 (SNPS1)
RFPC   MOV  @PAGE,R3
       CI   R3,1
       JNE  RFPD
       LI   R3,S32P1
       B    @RFPRC
RFPD   CI   R3,2
       JNE  RFPE
       LI   R3,S32P2
       B    @RFPRC
RFPE   CI   R3,3
       JNE  RFPF
       LI   R3,S32P3
       B    @RFPRC
RFPF   LI   R3,S32P4
 
RFPRC  MOV  R3,R1        * CRAM DATA
       LI   R0,SBUFF     * VRAM BUFFER
       LI   R2,1000
       BLWP @VMBW
       LI   R0,SBUFF1
       LI   R1,PADD      * 28 SPACES
       LI   R2,28
       BLWP @VMBW
 
* LOOP HERE
       BL   @DSR
EOJPP  B    @EOJP
       MOVB @WRITE,R1
       BLWP @VSBW
       CLR  R4           * RECORD COUNTER
WRITEF BL   @DSR
       MOV  @EOFP,@EOFP
       JNE  EOJPP
 
*** STOP
 
 
STOP   LIMI 2
       LIMI 0
       JMP  STOP
 
       MOV  @PAGE,R3     * AFTER DSR IS DONE
       INC  R3
       CI   R3,4
       JLE  CJPB         * HIGHER THAN PAGE 4, INC SAMS BANK SET PAGE TO 1
       LI   R3,1
       MOV  R1,@PAGE
       MOV  @BANK#,R1
       AI   R1,>0100
       MOV  R1,@BANK#
       JMP  RFPB
 
CJPB   MOV  R3,@PAGE     * CONTINUE MOVING
       JMP  RFPC
* READ SNPS 1-4 PAGES
* SET BANK#
 
 
 
 
 
       BL   @DSR
       MOVB @READ,R1     * SET TO OPEN!
       LI   R0,PBAD
       BLWP @VSBW
       CLR  R4           * RECORD COUNTER
 
 
 
 
 
 
 
 
 
* NOT USED BELOW
READF
 
 
* AND EXIT
 
       BL   @PSTPG
       BL   @CCREST
       LI   R0,120
       MOV  R0,@POS
       B    @CRTN
 
 
* GFERR ERROR! AND RESTORE SCREEN AND HONK
 
GFERR  BL   @HONK
       LI   R0,920
       LI   R1,TER1
       LI   R2,40
       BLWP @VMBW
GFERS  CLR  @>837C
       CLR  @>8375
       LIMI 2
       LIMI 0
       BLWP @KSCAN
       MOVB @>837C,R0
       JEQ  GFERS
GFEXIT BL   @CCREST
       LI   R0,120
       MOV  R0,@POS
       CLR  @COUNTP
       B    @CRTN
 
***
*
* OLD DSK.FILE
*
***
 
DSRL   LI   R0,533
       LI   R1,TLOAD
       LI   R2,10
       BLWP @VMBW
       B    @DSRL
 
***
*
* VARIABLES AND BUFFERS
***
*
* SAVE FILE PAB INFORMATION DV 80 FORMAT
*
***
SBUFF  EQU  >1000             * BUFFER ADDRESS
SBUFF1 EQU  >1FE4             * PADDED WITH 28 SPACES
PBAD   EQU  >79E              * PAB ADDRESS
FSPAB  DATA >0012,SBUFF,>8000,>0000,>0000
*             OP DV     128
COUNTP BYTE 0
FLNM   BSS  48
STATUS EQU  >837C
POINT  EQU  >8356
READP  BYTE >02
WRITE  BYTE >03
CLOSP  BYTE >01
       EVEN
EOFP   DATA 0
ERRM   TEXT '* I/O ERROR * '
CPUBF  BSS  80
LENP   BSS  2
RETURN BSS  2
PADD   TEXT '                        '
 
 
TER1   TEXT '* INVALID DISK NUMBER * - PRESS ANY KEY '
SVMG   TEXT 'SAVING FILE:'
 
 
 
***
*
* USED FOR TRACING, DEBUGGING
*
***
 
TRACE  LI   R0,0
       LI   R1,>2A00
       BLWP @VSBW
TRASP  LIMI 2
       LIMI 0
       JMP  TRASP
 
 
DSR    MOV  R11,@SAVRTN
       LI   R6,FSPAB+9
       BLWP @DSRLNK
       DATA 8
       JEQ  DSRERP
       MOV  @SAVRTN,R11
       RT   *R11
 
DSRERP INC  @EOF
       LI   R0,PBAD+1
       BLWP @VSBR
       SRL  R1,13
       CI   R1,5
       JNE  IOERP
       MOV  @SAVRTN,R11
       RT   *R11
 
IOERP  AI   R1,>30
       SLA  R1,8
       LI   R0,288
       LI   R1,ERRM
       LI   R2,14
       BLWP @VMBW
 
EOJP   MOV  @EOF,@EOF
       JNE  NCLOSP
       MOVB @CLOSP,R1
       LI   R0,PBAD
       BLWP @VSBW
       BL   @DSR
NCLOSP DECT @RETURN
       MOV  @RETURN,R11
       RT   *R11
 
 
GTBNK  MOV  R11,@SAVRTN
       MOV  @BANK#,R1
       LI   R12,>1E00
       SBO  0                 * this sets my sAMS pages to the correct BANK#
       LI   R3,>4006
       MOV  R1,*R3
       SBZ  0
       MOV  @SAVRTN,R11
       RT

 

Edited by GDMike
Link to comment
Share on other sites

Just some hints.

 

When you comment like this, it gives you very little information about the size of the different data items.

 

* BYTE 1 /0=OPEN 1 = CLOSED
* BYTE 2 FILE TYPE >12 =OUTPUT,VARIABLE DISPLAY
* NEXT POSITION=BUFFER ADDRESS
* NEXT RECORD LENGTH >50 = 80 BYTES
* NEXT CHARACTER COUNT
* NEXT RECORD NUMBER
* NEXT CASSETTE OFFSET
* LAST IS FILELENGTH DESCRIPTOR LENGTH
* NOTE: FILE DESCRIPTOR LENGTH
*       FOR FILE: 'DSK1.FILE1' = 10 >0A
TLOAD  TEXT 'LOAD DSK  '

Do it like this instead.

 

* BYTE Opcode 0=OPEN 1 = CLOSED
* BYTE FILE TYPE >12 =OUTPUT,VARIABLE DISPLAY
* DATA BUFFER ADDRESS
* BYTE RECORD LENGTH >50 = 80 BYTES
* BYTE CHARACTER COUNT
* DATA RECORD NUMBER
* BYTE CASSETTE OFFSET
* BYTE FILELENGTH DESCRIPTOR LENGTH
* NOTE: FILE DESCRIPTOR LENGTH
*       FOR FILE: 'DSK1.FILE1' = 10 >0A
TLOAD  TEXT 'LOAD DSK  '

Now you can see the structure of the PAB.

 

Here is a code snippet.

 

       CLR  @PAGE
       INC  @PAGE        * SET PAGE TO 1
       LI   R0,929
       CLR  R2
       INC  R2           * R2=1
       LI   R3,>3000     * "0

This is a better version

 

       LI   R0,929
       LI   R2,1
       MOV  R2,@PAGE
       LI   R3,'0 '

It's more compact and obvious enough to make the comments you had there redundant.

 

Here too, use the character load for clarity

       BLWP @VSBR        * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME IN R2
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,>3900     * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,>2E00     * NOW ITS LEGAL, CONTINUE LOOKIN SG FOR "." PERIOD MARK
       INC  R0
       INC  R2           * R2=2
       BLWP @VSBR
       CB   R1,R3
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R0
       INC  R2           * R2=3
       LI   R3,>4100     * LOOKING FOR A CHAR VALUE UPPER A-Z
       BLWP @VSBR
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,>5A00     * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,>2000     * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  INC  R0
       INC  R2
       BLWP @VSBR
       CB   R1,R3        * FOUND END OF NAME YET?, NO, KEEP LOOKING
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,2         * WE ADD IN THE "DSK" 3 BYTES TO GET OUR FULL DESCRIP #
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR

When you read incremental data from the VDP, there's no need to use the VSBR procedure. The VDPRD address is autoincrementing, so it will give you the next byte each time you access it.

 

       SWPB R0           * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME INTO R1
       MOVB R0,@VDPWA    * Set up the VDP address for reading 
       SWPB R0
       MOVB R0,@BDPWA
       NOP
       MOVB @VDPRD,R1    * Now you fetch consecutive characters by just reading the data, which is much faster than calling VSBR
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,'9 '      * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,'. '      * NOW ITS LEGAL, CONTINUE LOOKING FOR "." PERIOD MARK
       INC  R2           * R2=2
       CB @VDPRD,R3      * Here you only compare once, so you don't need to save the value in R1
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R2           * R2=3
       LI   R3,'A '      * LOOKING FOR A CHAR VALUE UPPER A-Z
       MOVB @VDPRD,R1    * Here you must save it in R1, since you want to compare it against two values
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,'Z '      * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,'  '      * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  CB   @VDPRD,R3    * Since you are using the value only once here, you can compare what you get from the VDP directly to your match value. No need to store it in R1
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,3         * WE ADD IN THE "DSK" 3 BYTES TO GET OUR FULL DESCRIP # So you better add three, not two
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME Where is COUNT? The file name counter you have defined is called COUNTP. Since it's a byte, you can't move it like this either
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR

This part is still wrong. First you define 10 bytes with PAB data.

Then you have COUNTP (or should it be COUNT?) as the first byte after the PAB data fields. But it shouldn't be there, it should be the last byte in the PAB data field. The file name shall start at where COUNTP is now. The count should be at FSPAB+9, but now it's at FSPAB+10.

 

FSPAB  DATA >0012,SBUFF,>8000,>0000,>0000
*             OP DV     128
COUNTP BYTE 0
FLNM   BSS  48

You can take advantage of the fact that you don't intend to offer cassette storage when you move the file name length to the PAB. That means that instead of doing something like

SWPB R2

MOVB R2,@FSPAB+9

 

You can do this

MOV R2,@FSPAB+8

 

This means that the byte before the count will get the value zero, but since it's used by the tape DSR only, that doesn't matter here.

 

You still don't have to save R11 in routines where you don't destroy R11 inside the routine. Besides, when you don't use all workspace registers, it's more efficient to save R11 into a register, like R10. At the end, you can then just B *R10.

 

RT is not an instruction. It's a macro, which translates to B *R11. You can use RT, but then it's only RT, not RT *R11.

Edited by apersson850
  • Like 2
Link to comment
Share on other sites

7 hours ago, apersson850 said:

24 lines with 40 characters each is 960 characters, not 1000. So it's something else.

It's 840 bytes. I'm not saving 24*40

My editor starts at pos 120.

Then I have some tag data in ram that gets added after my 840 bytes, this happens when a user hits pgup/down. And that brings it up to 1000 bytes. 

I also, DID forget, to add a counter for each of my 120 byte writes(1 record) to track the next 120 bytes written, making it record#2 and so on.

I can fix that.

And I'll have to adjust that COUNTP mistake you found, and the

MOV R2,@FSPAB+8

Thank you.

Edited by GDMike
Link to comment
Share on other sites

No, that does not get you into trouble. Unless you want to compare it to zero. For which you don't need to compare against anything special, since a MOV R2,R2 will compare the data in R2 against zero. Since a CI also always compare a register against a literal, clearing the register before you make a comparison is redundant, since you then already know the register is zero.

You have made som other mistake that took you into that trouble, and then you fixed that by adding a kludge. Perhaps you did a MOVB into the register, then did the CI? And forgot about that the MOVB only changes half of the register, but CI always compare all of it? That's a special case where clearing the register before moving a byte into it and finally compare the whole register against something could make sense. But special cases should be kept special, not made any kind of general reason for complicating the code more than necessary.

 

Anyway, if you want to make a register to contain 1 by using INC, then of course you must start from 0. So CLR R2 INC R2 will indeed load one into R2. But it's a tad less obvious than LI R2,1, which consumes the same amount of memory and executes a little faster. It's also general, i.e. works with any value. Once you do a LI, anything that was in the register before is overwritten. So a preceeding CLR is completely redundant in that case.

 

The sequence

CLR @SOMEPLACE

INC @SOMEPLACE

CLR R2

INC R2

 

is very inefficient and illogical compared to

LI R2, 1

MOV R2,@SOMEPLACE

 

If a certain constant, like 120, is frequently used in a piece of code, it may be useful to load it into a register, if you have one available.

CON120 EQU 9

LI CON120,120

will give you a register (R9) with the value 120, and a name for it.

Then you can use

MOV CON120,R2

MOV CON120,@SOMEPLACE

C *R2+,CON120

A CON120,R2

It's of course important that you don't mess that register up. Don't do A R2,CON120, since the result will end up in the second parameter, and R9 will then contain 120+what was in R2.

As long as you keep that in mind, all these instructions are faster, and require less memory, than dealing with the immediate value (120) over and over again.

 

Remember that programming is not just about getting it to work. It's also about making the program elegant. If it is, then it's easier to understand, which makes it easier for you to work with. Both now and at a later date, when you want to change something. It's also easier for everybody else here to help you. Besides, an elegant program usually executes faster and require less memory, simply because it doesn't contain so many unnecessary things.

Edited by apersson850
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

ENTRY is DSRS

I added in MY POINT(er) that was "pointed" out to me. But i just ended up rebooting instead of getting the error i was getting prior. i beleive, the FILENAME address is still incorrect.

here is the latests code.

ALL DATA,BYTE, TEXT, BSS..are defined- either here or in another file.

NEW CODE COMING

Edited by GDMike
Link to comment
Share on other sites

****************************************
* FILEM -  FILE MANAGAMENT  06/04/20   *
*                                      *
*  LAST UPDATE: 10/23/20               *
* HIST:FIX ERRROR HONK TIMING          *
* NEED: SAVE PAB SETUP                 *
*                                      *
****************************************
TLOAD  TEXT 'LOAD DSK  '
 
***
*
* SAVE DSK FILE
*
***
GFERR1 B    @GFERR
DSRS   LI   R1,>1100     * SET TO PAGE 1 SAMS
       MOV  R1,@BANK#
       CLR  @PAGE
       INC  @PAGE        * SET PAGE TO 1
       LI   R0,929
       CLR  R2
       INC  R2           * R2=1
       LI   R3,>3000     * "0"
       BLWP @VSBR        * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME IN R2
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,>3900     * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,>2E00     * NOW ITS LEGAL, CONTINUE LOOKING FOR "." PERIOD MARK
       INC  R0
       INC  R2           * R2=2
       BLWP @VSBR
       CB   R1,R3
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R0
       INC  R2           * R2=3
       LI   R3,>4100     * LOOKING FOR A CHAR VALUE UPPER A-Z
       BLWP @VSBR
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,>5A00     * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,>2000     * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  INC  R0
       INC  R2
       BLWP @VSBR
       CB   R1,R3        * FOUND END OF NAME YET?, NO, KEEP LOOKING
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,2         * WE ADD IN THE "DSK" 3 BYTES TO GET OUR FULL DESCRIP #
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR
 
* START PROCESSING...
 
       LI   R0,120
       LI   R1,>2000     * CLEAR SCREEN AREA
CSVA   BLWP @VSBW
       INC  R0
       CI   R0,960
       JLT  CSVA
       BL   @BEEP
       LI   R0,324       * MESSAGE "SAVING..."
       LI   R1,SVMG
       LI   R2,12
       BLWP @VMBW
       LI   R0,337
       LI   R1,FLNM
       MOV  @COUNTP,R2
       BLWP @VMBW
 
* DO THE WRITE!
       LI   R5,>1000     * THIS JUST SETS THE SAMS BASE BANK#
       CLR  R3
       LI   R0,PBAD
       LI   R1,FSPAB
       MOVB @COUNTP,R2
       SRL  R2,8
       AI   R2,10
       BLWP @VMBW
       CLR  R4           * RECORD COUNTER
 
* THE FOLLOWING CODE JUST SETS UP THE PAGE TO PLACE INTO THE BUFFER
 
       AI   R5,>0100     * SET BANK#
       MOV  R5,@BANK#    * INITIALLY >1100
       INC  R3           * R3=PAGE# 1-4
       MOV  R3,@PAGE
       INC  R4           * IS A 1 THE FIRST TIME
RFPB   BL   @GTBNK       * GET THE BANK SET TO >1100 AND PAGE TO 1 (SNPS1)
RFPC   MOV  @PAGE,R3
       CI   R3,1
       JNE  RFPD
       LI   R3,S32P1     * THIS IS >3000
       B    @RFPRC
RFPD   CI   R3,2
       JNE  RFPE
       LI   R3,S32P2     * THIS IS >3349
       B    @RFPRC
RFPE   CI   R3,3
       JNE  RFPF
       LI   R3,S32P3     * THIS IS >3692
       B    @RFPRC
RFPF   LI   R3,S32P4     * AND THIS IS >39DB
 
 
* NOW WE HAVE THE PAGE AND DATA TO PLACE INTO THE BUFFER
 
 
RFPRC  MOV  R3,R1        * CRAM DATA
       LI   R0,SBUFF     * VRAM BUFFER
       LI   R2,1000
       BLWP @VMBW
       LI   R0,SBUFF1
       LI   R1,PADD      * 28 SPACES
       LI   R2,28
       BLWP @VMBW
 
* LOOP HERE
 
       BL   @DSR
 
 
 
       MOVB @WRITE,R1
       BLWP @VSBW
       CLR  R4           * RECORD COUNTER
WRITEF BL   @DSR
       MOV  @EOFP,@EOFP
       JNE  EOJPP
 
*** STOP
 
 
STOP   LIMI 2
       LIMI 0
       JMP  STOP
 
       MOV  @PAGE,R3     * AFTER DSR IS DONE
       INC  R3
       CI   R3,4
       JLE  CJPB         * HIGHER THAN PAGE 4, INC SAMS BANK SET PAGE TO 1
       LI   R3,1
       MOV  R1,@PAGE
       MOV  @BANK#,R1
       AI   R1,>0100
       MOV  R1,@BANK#
       JMP  RFPB
 
CJPB   MOV  R3,@PAGE     * CONTINUE MOVING
       JMP  RFPC
* READ SNPS 1-4 PAGES
* SET BANK#
 
 
 
 
 
       BL   @DSR
       MOVB @READ,R1     * SET TO OPEN!
       LI   R0,PBAD
       BLWP @VSBW
       CLR  R4           * RECORD COUNTER
 
 
 
 
 
 
 
 
 
* NOT USED BELOW
READF
 
 
* AND EXIT
 
       BL   @PSTPG
       BL   @CCREST
       LI   R0,120
       MOV  R0,@POS
       B    @CRTN
EOJPP  B    @EOJPP
 
* GFERR ERROR! AND RESTORE SCREEN AND HONK
 
GFERR  BL   @HONK
       LI   R0,920
       LI   R1,TER1
       LI   R2,40
       BLWP @VMBW
GFERS  CLR  @>837C
       CLR  @>8375
       LIMI 2
       LIMI 0
       BLWP @KSCAN
       MOVB @>837C,R0
       JEQ  GFERS
GFEXIT BL   @CCREST
       LI   R0,120
       MOV  R0,@POS
       CLR  @COUNTP
       B    @CRTN
 
***
*
* OLD DSK.FILE
*
***
 
DSRL   LI   R0,533
       LI   R1,TLOAD
       LI   R2,10
       BLWP @VMBW
       B    @DSRL
 
***
*
* VARIABLES AND BUFFERS
***
*
* SAVE FILE PAB INFORMATION DV 80 FORMAT
*
***
SBUFF  EQU  >1000             * BUFFER ADDRESS
SBUFF1 EQU  >1FE4             * PADDED WITH 28 SPACES
PBAD   EQU  >79E              * PAB ADDRESS
FSPAB  DATA >0012,SBUFF,>8000,>0000,>0000
*             OP DV     128
COUNTP BYTE 0
FLNM   BSS  48
STATUS EQU  >837C
POINT  EQU  >8356
READP  BYTE >02
WRITE  BYTE >03
CLOSP  BYTE >01
       EVEN
EOFP   DATA 0
ERRM   TEXT '* I/O ERROR * '
CPUBF  BSS  80
LENP   BSS  2
RETURN BSS  2
PADD   TEXT '                        '
 
 
TER1   TEXT '* INVALID DISK NUMBER * - PRESS ANY KEY '
SVMG   TEXT 'SAVING FILE:'
 
 
 
***
*
* USED FOR TRACING, DEBUGGING
*
***
 
TRACE  LI   R0,0
       LI   R1,>2A00
       BLWP @VSBW
TRASP  LIMI 2
       LIMI 0
       JMP  TRASP
 
DSR    MOV  R11,@SAVRTN
       LI   R6,FSPAB+9
       MOV  R6,@POINT
       BLWP @DSRLNK
       DATA 8
       JEQ  DSRERP
       MOV  @SAVRTN,R11
       RT   *R11
 
DSRERP INC  @EOF
       LI   R0,PBAD+1
       BLWP @VSBR
       SRL  R1,13
       CI   R1,5
       JNE  IOERP
       MOV  @SAVRTN,R11
       RT   *R11
 
IOERP  AI   R1,>30
       SLA  R1,8
       LI   R0,288
       LI   R1,ERRM
       LI   R2,14
       BLWP @VMBW
 
EOJP   MOV  @EOF,@EOF
       JNE  NCLOSP
       MOVB @CLOSP,R1
       LI   R0,PBAD
       BLWP @VSBW
       BL   @DSR
NCLOSP DECT @RETURN
       MOV  @RETURN,R11
       RT   *R11
 
 
GTBNK  MOV  R11,@SAVRTN
       MOV  @BANK#,R1
       LI   R12,>1E00
       SBO  0                 * EACH CONTAINING SNPS1-4
       LI   R3,>4006
       MOV  R1,*R3
       SBZ  0
       MOV  @SAVRTN,R11
       RT
 
 
 
 
 
 
 

my problem so far, is this: i need to keep track of the 128 bytes per record counter.

I thought I was doing this JUST PRIOR to the RFPB LABEL in R4.

But not true, that is only tracking my PAGE for SAMS!

im lost on how to track that, is it done at the DSR routine or ?

 

Edited by GDMike
Link to comment
Share on other sites

IM not sure, BUT the BL @DSR prior to the REM * LOOP HERE, might be out of place.

removing it is ok, Im now in the area to where I MOVB @write to R1.

then I clear my R4 record counter to prepare for the 128 bytes record #1, and call DSR routine.

but Im getting a reboot.

 

Edited by GDMike
Link to comment
Share on other sites

The DSRLNK only executes one I/O operation. Like writing one record.

 

I've now understood that you seem to plan to store 120 bytes in each record. My previous comments were related to that when people use the internal fixed 128 format, it's usually due to a desire to use the entire sector on a floppy disk. The I/F 128 format allows two records in a sector, and that fills it completely.

But you can very well use 120 bytes in a record. You'll waste a few bytes, but when it makes your program simpler, then that's no problem.

 

However, if the code two posts up is what you're working on now, you still haven't done any of the fixes I showed you. Some of them are just to increase the quality of your coding, but the PAB is still not correctly defined, which is catastrophic.

It also seems you haven't grasped the concept of records in a file. Here's a piece of pseudo code to show how to do file handing, storing a buffer that's larger than the record.

 

const recordSize = 120; // How much you actually use in each record

const screenSize = 1000; // How much you want to save

screenIndex: interger; // Index into the current position in the screen

recordNumber: integer;

buffer = array[0..recordSize]; // The file handling buffer

screen = array[0..screenSize]; // The screen with characters

 

open(file);

screenIndex := 0; // Start with the beginning of the screen

recordNumber := 0;

while screenindex<screenSize do // As long as you haven't reached the end of the screen

begin

  move(screen[screenIndex],buffer,recordSize); // Move one chunk of data from the current position in the screen to the file buffer

  write(file(recordNumber),buffer); // Write the file buffer

  recordNumber := recordNumber+1;

  screenIndex := screenIndex+recordSize; // Move index to the start of the next record in the screen

end;

close(file);

  • Like 1
Link to comment
Share on other sites

Well, if you are going to start over, which indeed may be a good idea, since your original code is pretty much a mess, then I suggest you plan your code on a pseudo code level. Like the one I suggest above, or anthing that's appropriate to you. It's easier to set a game plan that way, and only when you are certain it seems functional, do you enter into all the details that need to be correct to get an assembly program working.

  • Like 1
Link to comment
Share on other sites

****************************************
* FILEM -  FILE MANAGAMENT  06/04/20   *
*                                      *
*  LAST UPDATE: 11/01/20               *
*                                      *
****************************************
 
***
*
* SAVE DSK FILE
*
***
 
* the following ASKS the user to enter a filename to be used: EX: DSK2.FILE
 
DSRS   LI   R1,>1100     * SET TO PAGE 1 SAMS
       MOV  R1,@BANK#
       CLR  @PAGE
       INC  @PAGE        * SET PAGE TO 1
       LI   R0,929
       LI   R2,>0001
       LI   R3,>3000     * "0"
       BLWP @VSBR        * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME IN R2
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,>3900     * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,>2E00     * NOW ITS LEGAL, CONTINUE LOOKING FOR "." PERIOD MARK
       INC  R0
       INC  R2           * R2=2
       BLWP @VSBR
       CB   R1,R3
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R0
       INC  R2           * R2=3
       LI   R3,>4100     * LOOKING FOR A CHAR VALUE UPPER A-Z
       BLWP @VSBR
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,>5A00     * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,>2000     * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  INC  R0
       INC  R2
       BLWP @VSBR
       CB   R1,R3        * FOUND END OF NAME YET?, NO, KEEP LOOKING
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,2         * WE ADD IN THE "DSK" 3 BYTES TO GET OUR FULL DESCRIP #
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR
 
* FLNM contains the PATH
* COUNT contains the length of the PATH
 
       LI   R0,120
       LI   R1,>2000     * CLEAR SCREEN AREA
CSVA   BLWP @VSBW
       INC  R0
       CI   R0,960
       JLT  CSVA
       BL   @BEEP
       LI   R0,324       * MESSAGE "SAVING..."
       LI   R1,SVMG
       LI   R2,12
       BLWP @VMBW
       LI   R0,337
       LI   R1,FLNM
       MOV  @COUNTP,R2
       BLWP @VMBW
 
* DO THE WRITE: here is where we need to SET WRITE operation for DF 128
 
 
* i got nothing... BUT im looking at
* @BEERY's SEARCH routine. MAYBE itll give me
* SOME insight on how to setup the
* structure.  THANKS MR. BEERY!
 
 
 
 
 
 
 
 
*
***
SBUFF  EQU  >1000             * BUFFER ADDRESS
SBUFF1 EQU  >1FE4             * PADDED WITH 28 SPACES
PBAD   EQU  >79E              * PAB ADDRESS
FSPAB  DATA >0012,SBUFF,>8000,>0000,>0000
*             OP DV     128
COUNTP BYTE 0
FLNM   BSS  48
STATUS EQU  >837C
POINT  EQU  >8356
READP  BYTE >02
WRITE  BYTE >03
CLOSP  BYTE >01
       EVEN
EOFP   DATA 0
ERRM   TEXT '* I/O ERROR * '
CPUBF  BSS  80
LENP   BSS  2
RETURN BSS  2
PADD   TEXT '                        '
 
TLOAD  TEXT 'LOAD DSK '
TER1   TEXT '* INVALID DISK NUMBER * - PRESS ANY KEY '
SVMG   TEXT 'SAVING FILE:'
 
 
 
***
*
* USED FOR TRACING, DEBUGGING
*
***
 
TRACE  LI   R0,0
       LI   R1,>2A00
       BLWP @VSBW
TRASP  LIMI 2
       LIMI 0
       JMP  TRASP
 

here is my starting point

 

Edited by GDMike
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...