whomper Posted May 3 Share Posted May 3 Hi, I'm trying to write an assembly program that renames a file using CIO. For some reason, it just does not want to work although I've built the right input string. Here's a code snippet that should work but apparently screws the file name: LDX #1 LDA #$20 STA ICCOM,X LDA #<BUFFER STA ICBAL,X LDA #>BUFFER STA ICBAH,X LDA #$08 STA ICAX1,X LDA #0 STA ICAX2,X JSR CIOV BUFFER = "D1:OLD,NEW" Any thoughts what am I doing wrong? The file will be renamed to wwwwwwww.www Quote Link to comment Share on other sites More sharing options...
vitoco Posted May 4 Share Posted May 4 LDX #16 might be? Quote Link to comment Share on other sites More sharing options...
Alfred Posted May 4 Share Posted May 4 Change the LDX to any of $10,$20,$30,$40,$50,$60,$70. $00 is reserved for the E: device. CIO expects X to be loaded with the channel (0-7) number times 16. Quote Link to comment Share on other sites More sharing options...
whomper Posted May 4 Author Share Posted May 4 14 hours ago, whomper said: Hi, I'm trying to write an assembly program that renames a file using CIO. For some reason, it just does not want to work although I've built the right input string. Here's a code snippet that should work but apparently screws the file name: LDX #1 LDA #$20 STA ICCOM,X LDA #<BUFFER STA ICBAL,X LDA #>BUFFER STA ICBAH,X LDA #$08 STA ICAX1,X LDA #0 STA ICAX2,X JSR CIOV BUFFER = "D1:OLD,NEW" Any thoughts what am I doing wrong? The file will be renamed to wwwwwwww.www Hi, Thanks, a typo on my side entering it here. Here's the fixed code that does not work LDX #$10 LDA #$20 STA ICCOM,X LDA #<BUFFER STA ICBAL,X LDA #>BUFFER STA ICBAH,X LDA #$08 STA ICAX1,X LDA #0 STA ICAX2,X JSR CIOV BUFFER = "D1:OLD,NEW" Quote Link to comment Share on other sites More sharing options...
whomper Posted May 4 Author Share Posted May 4 Another quick update, found the issue. When issuing XIO (extended CIO for disk) commands (greater than $0C) for ICCOM, both ICAX1 and ICAX2 must be 0. I had sent $08 amounts other attempts, which worked for me for commands such as protect and unprotect, but rename got messed up. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 4 Share Posted May 4 (edited) Not sure what assembler your using, but this is using MADS and this works , MADS uses single quotes for ASCII strings, yours may use double usually strings are defined as BUFFER .byte "D1:OLD.TXT,NEW.TXT",$9b The file "header.h" has all the Atari System Equates in it. I always close a channel before opening, just in case. 2 things that are probably wrong with your example, strings usually have to be terminated with $9b and the other filenames in DOS again usually require the "." even if there's no extension. If you think about it without a terminator or period it doesn't know the length of the filename or the extension. icl "header.h" org $600 LDX #16 LDA #CLOSE ICCOM,X JSR CIOV LDX #16 LDA #$20 STA ICCOM,X LDA #<NEW STA ICBAL,X LDA #>NEW STA ICBAH,X LDA #$12 STA ICAX1,X LDA #0 STA ICAX2,X JSR CIOV rts NEW .byte 'D1:OLD.TXT,NEW.TXT',$9b Edited May 4 by TGB1718 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted May 4 Share Posted May 4 4 hours ago, TGB1718 said: the other filenames in DOS again usually require the "." even if there's no extension. If you think about it without a terminator or period it doesn't know the length of the filename or the extension. The comma tells DOS the length of the first filename, and the string terminator indicates the length of the second one. Internally, DOS will pad both names with spaces before attempting a directory match on the first one or rename operation using the second one, so the presence or absence of an extender should not matter in the least. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 4 Share Posted May 4 Sorry @flashjazzcat but you do need the period for the filename to determine the filename length without the extension, the OS searches the input string for the period to determine this as it copies the filename to it's internal buffer, once it finds the period, it then searches for the comma for the file extension length, etc. until it has the source and destination filenames. The code that does this is around $B680 to $B6EF, it checks for the period at $B696 and the comma at $B6A0 Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 4 Share Posted May 4 What Dos are you referring to that has code in the B600 area? Cart based SDX? I think that the filespec needs the EOL terminator - so follow the "D1:OLD,NEW" with ,$9B And shouldn't it be BUFFER .BYTE "D1:OLD,NEW" and not BUFFER = I would have thought that would generate an assembly error. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 4 Share Posted May 4 15 minutes ago, Rybags said: What Dos are you referring to that has code in the B600 area? Cart based SDX? Using 130XE U1M with SDX 16 minutes ago, Rybags said: And shouldn't it be BUFFER .BYTE "D1:OLD,NEW" and not BUFFER = Hence my comment, "not sure what assembler your using", I've never seen BUFFER = before either. Strangely if you ask Micro$oft CoPilot for an example it comes back with this very similar looking code 🙃 Still wouldn't work, but closer LDX #1 LDA #$20 STA ICCOM,X ; Set command to rename LDA #<BUFFER STA ICBAL,X ; Set low byte of buffer address LDA #>BUFFER STA ICBAH,X ; Set high byte of buffer address LDA #$08 STA ICAX1,X ; Set function code for rename LDA #0 STA ICAX2,X ; Clear any flags JSR CIOV ; Call CIO routine BUFFER: .BYTE "D1:OLD,NEW",0 ; Old and new file names Quote Link to comment Share on other sites More sharing options...
drac030 Posted May 4 Share Posted May 4 1 hour ago, TGB1718 said: you do need the period for the filename to determine the filename length without the extension, the OS searches the input string for the period to determine this as it copies the filename to it's internal buffer, once it finds the period, it then searches for the comma for the file extension length, etc. until it has the source and destination filenames. Uhm, what? I just tried. XIO 32,#1,0,0,"D:OLD,NEW" from BASIC and it worked. Can you demonstrate an example where it does not work without the period? Quote Link to comment Share on other sites More sharing options...
thorfdbg Posted May 4 Share Posted May 4 2 hours ago, TGB1718 said: Sorry @flashjazzcat but you do need the period for the filename to determine the filename length without the extension, the OS searches the input string for the period to determine this as it copies the filename to it's internal buffer, once it finds the period, it then searches for the comma for the file extension length, etc. until it has the source and destination filenames. The code that does this is around $B680 to $B6EF, it checks for the period at $B696 and the comma at $B6A0 Err... no. There is no "internal buffer", and the only thing CIO does is to determine the handler responsible for XIO, and for that it locates only the letter upfront the colon, and that is it - it just passes the command to the handler found from HATABS. Everything beyond that point is interpreted by the FMS once it receives the command. Whether it needs a period or not depends on the FMS. For DOS 2 and related file systems, no period means just that the file name extension is blank, but the period is not exactly needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.