From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2004-09-09 19:24:12
Hello, * On Thu, Sep 09, 2004 at 10:53:46AM +0200 Baltissen, GJPAA (Ruud) wrote: > Having had some good help from Spiro I thought it was time to shift my > brain into a higher gear. And I got this: M-R and M-W both have an > option to tell how many bytes I want to read/write. The question is if > the last byte is sent with an active EOI but that is something that > can be tested quite easy. From my understanding: Yes, it should be sent with an EOI. > But the docs state that one can only read from 1 up to 255 bytes. I > need to read 256. I could try if 0 is translated as 256 otherwise I > have to do it in two batches. I think: No, a zero should not (!) be interpreted as a 256. The memory (M-xxx) commands start at $CAF8, after the "M" (which is stored at $0200) has already been recognized ' The command can be found at $0200-$0229 .8:caf8 AD 01 02 LDA $0201 ' Check if the 2nd char is a '-' .8:cafb C9 2D CMP #$2D .8:cafd D0 4C BNE $CB4B ' No, output 31,SYNTAX ERROR .8:caff AD 03 02 LDA $0203 ' Now, store low address at $6F .8:cb02 85 6F STA $6F .8:cb04 AD 04 02 LDA $0204 ' ... and high address at $70 .8:cb07 85 70 STA $70 .8:cb09 A0 00 LDY #$00 .8:cb0b AD 02 02 LDA $0202 ' Which command do we have? .8:cb0e C9 52 CMP #$52 ' 'R'? .8:cb10 F0 0E BEQ $CB20 ' Yes, execute M-R .8:cb12 20 58 F2 JSR $F258 ' This is just a RTS .8:cb15 C9 57 CMP #$57 ' 'W'? .8:cb17 F0 37 BEQ $CB50 ' Yes, execute M-W .8:cb19 C9 45 CMP #$45 ' 'E'? .8:cb1b D0 2E BNE $CB4B ' No, output 31,SYNTAX ERROR .8:cb1d 6C 6F 00 JMP ($006F) ' Execute at the given address M-R starts at $CB20: .8:cb20 B1 6F LDA ($6F),Y ' Get 1st byte ... .8:cb22 85 85 STA $85 ' ... and store it at $85 .8:cb24 AD 74 02 LDA $0274 ' Get length of command string .8:cb27 C9 06 CMP #$06 ' less than 6? .8:cb29 90 1A BCC $CB45 ' yes, jump: Output just 1 byte .8:cb2b AE 05 02 LDX $0205 ' Get number of bytes to read .8:cb2e CA DEX ' subtract 1 .8:cb2f F0 14 BEQ $CB45 ' if it was 1, jump: Output just that 1 byte .8:cb31 8A TXA ' Now, add the (number of bytes - 1) to the start of the output ' area .8:cb32 18 CLC .8:cb33 65 6F ADC $6F ' Now, A contains the pointer to the ' last byte to be read .8:cb35 E6 6F INC $6F ' start at one byte higher than given ' remember: We already stored the 1st ' byte in $85! .8:cb37 8D 49 02 STA $0249 ' remember the last byte to be read .8:cb3a A5 6F LDA $6F ' now, store the start at $A5/$A6 .8:cb3c 85 A5 STA $A5 ' $A5/$A6 is the address of the error buffer! .8:cb3e A5 70 LDA $70 .8:cb40 85 A6 STA $A6 .8:cb42 4C 43 D4 JMP $D443 ' Output the buffer ' From here, we output just the one byte given (in $85) .8:cb45 20 EB D0 JSR $D0EB .8:cb48 4C 3A D4 JMP $D43A .8:cb4b A9 31 LDA #$31 ' Output 31,SYNTAX ERROR .8:cb4d 4C C8 C1 JMP $C1C8 (8:$cb50) Interestingly, you see that you cannot cross a page boundary with M-R! Thus, M-R starting at $02FF with length 2 will give the bytes at address $02FF and $0200, respectively! > More worrying is the fact that I only can write up to 34 byte. Is the > computer to blame or the drive? Surely, it is the drive. $0200-$0229 is the input buffer. Thus, the complete M-W command has to fit inside of the buffer: $0200-$0229 42 byte buffer M-Wxyz is 6 bytes - 6 byte --------- 36 bytes Now, I'm not sure how the difference of 2 bytes is determined. It could be related to a trailing CR and Null-Byte, but I'm not sure. BTW: The M-W command is rather simple: .8:cb50 B9 06 02 LDA $0206,Y ' get byte .8:cb53 91 6F STA ($6F),Y ' store at destination .8:cb55 C8 INY .8:cb56 CC 05 02 CPY $0205 ' have we reached the count? .8:cb59 90 F5 BCC $CB50 ' no, continue .8:cb5b 60 RTS Thinking about what I already commented here on the drive's code, I ask myself if it isn't time for a 1541 ROM Disassembly project? ;-) Regards, Spiro. -- Spiro R. Trikaliotis http://www.trikaliotis.net/ Message was sent through the cbm-hackers mailing list
Archive generated by hypermail pre-2.1.8.