Re: Writing binary data to disk.
Posted: Sat Jul 18, 2015 2:06 pm
You use the RTS at the end of CLRCHN to return directly to basic!Mike wrote:Only if I had JSR'd to CLRCHN.
Nice!
The Commodore Vic 20 Forum
http://www.sleepingelephant.com/ipw-web/bulletin/bb/
http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?t=7538
You use the RTS at the end of CLRCHN to return directly to basic!Mike wrote:Only if I had JSR'd to CLRCHN.
orion70 and I used CBM files with a four digit number of blocks, with partitions, to hold the text body of the two instances of our Bible Series (#1: The 4 Gospels, Acts of the Apostels and Revelation, and #2: Pentateuch).eslapion wrote:First time I see a 1033 blocks file in a 1581 directory without an error causing it!
You didn't need this information! At that point it was clear to me that I had a routine which read the bytes from the dumped device one at a time and copied it in RAM and THEN I wanted to dump the RAM section. However, the device reader routine which you demanded wasn't complete because the hardware itself was still a work in progress.What is done in the subroutine at line 100?
I guess it's my fault really. I should NEVER have placed myself in a situation of dependency to someone who expresses such boundless contempt towards my efforts to meet their requirements.it *was* necessary to get some information from you while you went to change the hardware register setup *three times in a row*, and then you continued with an extra inquiry about a verifying routine. No thanks.
Code: Select all
14 OPEN2,11,2,"READ.BIN,S,R"
15 FORT=0TO15:POKE38912,T:SYS673,2:NEXT
16 CLOSE2
Code: Select all
.02A1 20 F1 D7 JSR $D7F1 ; read channel number from BASIC text into X
.02A4 20 C6 FF JSR $FFC6 ; CHKIN - set channel in X for input
.02A7 A9 00 LDA #$00
.02A9 85 FB STA $FB
.02AB A8 TAY
.02AC A9 40 LDA #$40
.02AE 85 FC STA $FC ; set high byte of pointer to $40
.02B0 AA TAX ; ... incidentally also number of pages to read
.02B1 +---+---> 8A TXA ; put current X and Y on stack
.02B2 | | 48 PHA
.02B3 | | 98 TYA
.02B4 | | 48 PHA
.02B5 | | 20 CF FF JSR $FFCF ; CHRIN from file
.02B8 | | 91 FB STA ($FB),Y ; write byte to RAM
.02BA | | 68 PLA ; restore X and Y from stack
.02BB | | A8 TAY
.02BC | | 68 PLA
.02BD | | AA TAX
.02BE | | C8 INY ; increment effective address within page
.02BF | +---< D0 F0 BNE $02B1
.02C1 | E6 FC INC $FC ; increment high byte of pointer
.02C3 | CA DEX ; decrement remaining pages
.02C4 +-------< D0 EB BNE $02B1 ; until =0.
.02C6 4C CC FF JMP $FFCC ; CLRCHN - restore default output
Code: Select all
14 OPEN2,11,2,"PROPER.BIN,S,R"
15 FORT=0TO15:POKE38912,T:SYS673,2
16 IF PEEK(251)>0 THEN PRINT"FAIL AT BLOCK ";T:END
17 NEXT
18 CLOSE2
Code: Select all
.02A1 20 F1 D7 JSR $D7F1 ; read channel number from BASIC text into X
.02A4 20 C6 FF JSR $FFC6 ; CHKIN - set channel in X for input
.02A7 A9 00 LDA #$00
.02A9 85 FB STA $FB
.02AB A8 TAY
.02AC A9 40 LDA #$40
.02AE 85 FC STA $FC ; set high byte of pointer to $40
.02B0 AA TAX ; ... incidentally also number of pages to read
.02B1 +---+---> 8A TXA ; put current X and Y on stack
.02B2 | | 48 PHA
.02B3 | | 98 TYA
.02B4 | | 48 PHA
.02B5 | | 20 CF FF JSR $FFCF ; CHRIN from file
.02B8 | | D1 FB CMP ($FB),Y ; compare ACC with RAM
.02BA | | D0 0F BNE $02CB ; Go to FAIL condition
.02BC | | 68 PLA ; restore X and Y from stack
.02BD | | A8 TAY
.02BE | | 68 PLA
.02BF | | AA TAX
.02C0 | | C8 INY ; increment effective address within page
.02C1 | +---< D0 EE BNE $02B1
.02C3 | E6 FC INC $FC ; increment high byte of pointer
.02C5 | CA DEX ; decrement remaining pages
.02C6 +-------< D0 E9 BNE $02B1 ; until =0.
.02C8 4C CC FF JMP $FFCC ; CLRCHN - restore default output
.02CB 68 PLA
.02CC 68 PLA ; restore stack to previous condition
.02CD A9 FF LDA #$FF
.02CF 85 FB STA $FB ; flag error code for BASIC
.02D1 4C CC FF JMP $FFCC ; CLRCHN - restore default output
This is exactly what happened during the tests.Mike wrote:When a comparison fails, X and Y are still stacked and the routine will crash.
I agree pushing Y is redundant. In my defence, it is a snippet reused from old code. Better safe than sorry.TNT wrote:Why push/pop Y at all if your code already relies on it to not to change in CHRIN?
That's the rub. Tape use for CHRIN happens to affect the X register (and I fell over this in one application indeed), but ...Also, while Programmer's reference guide says that X is affected, the example given there uses X as index, implying that you don't need to push/pop it either.
... you really don't want to read that huge amount of data from tape, indeed.At least for IEC bus that's safe.
That depended on what was in X and Y at the time they were pushed, and what was in RAM at the place of the wrongly assumed return address. Could be anything from a collection of (illegal) opcodes leading to a BRK and causing a BASIC warmstart (as if STOP/RESTORE had been pressed); or that chain of instructions ending up at an opcode ending in $x2 other than $A2 (LDX #imm) or $82, $C2, $E2 ("illegal" NOPs), which cause the state machine of the 6502 to lock up. In the latter case, only a reset revives the CPU.eslapion wrote:2. When the VIC crashed there were no error messages at all - it completely froze. RUN STOP/RESTORE didn't work and the drive kept on spinning.
The applications discussed in this thread can save, load and verify data in amounts ranging from 16k up to 512k. Definitely, this is not for tape.Mike wrote:... you really don't want to read that huge amount of data from tape, indeed.