Harry Potter Posted September 25, 2021 Share Posted September 25, 2021 Hi! I am working on a memory enhancement for the 8-bit Atari and cc65 and need to load a file into the extra memory (vocab. check req.!), and it's not working. I suspect an error in the drive access string. How do I read a file from the drive? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 Never mind, I don't think that's the problem. I'm getting an "ERROR-154" message for a split-second then garbage, then the computer crashes. What could cause this? I attached some code files. readauxfile.c atarixl_memx.cfg test.c Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 25, 2021 Share Posted September 25, 2021 more detail needed command line to build are you just running the exe in a emulator or making an ATR image with a DOS upon it and adding/running the file from that? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 I attached the batch file used to build the program. I am running it from a disk image with MyDOS on it. home.bat Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 25, 2021 Share Posted September 25, 2021 (edited) have you tried accessing the file as "D:" or "D1:" rather than "D0:"? Also, what is the spec for this call? aux_memcpyto (j, &auxbufx, i); as both i and j are unsigned (integers)? Edited September 25, 2021 by Wrathchild Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 Thank you. aux_memcpyto() copies a block of memory from main memory to the extra memory and has the same prototype as memcpy(). Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 It didn't work. The problem appears before the line to load the aux memory file. BTW, the error is #132. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 I attached the crt0.s and config files just in case. BTW, would the wrong DOS.SYS file cause this? atarixl_memx.cfg crt0.s Quote Link to comment Share on other sites More sharing options...
drac030 Posted September 26, 2021 Share Posted September 26, 2021 3 hours ago, Harry Potter said: BTW, the error is #132. 132 is "BAD CIO COMMAND", your program is invoking the CIOV with an invalid I/O command code stored in the control block. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 26, 2021 Share Posted September 26, 2021 12 hours ago, Harry Potter said: Thank you. aux_memcpyto() copies a block of memory from main memory to the extra memory and has the same prototype as memcpy(). memcpy is called :- memcpy(*dest, *src, size); so if your aux_memcpyto uses the same prototype, it's passing the wrong parameters, in your call, memcpy (j, auxbufx, i); you are passing an integer for the *dest I tested the file handling using "D:TEST.TXT" which I had created and printed out the read in data and it works fine. I think the problem is the memcpy function Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 26, 2021 Author Share Posted September 26, 2021 The error must be in the crt0.s file, as, when I add a code "while (1);" to the beginning of the main() function, the problem still occurs. BTW, I'm wondering if the problem is in the config file or the block headers. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 26, 2021 Share Posted September 26, 2021 This is what I used to test:- #include <stdlib.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <conio.h> #include <atari.h> // #include "memxtatari.h" unsigned char loadauxmem (char* f); //#pragma bss-name (push, "XBUFBSS") static unsigned char auxbufx [128]; char tempbufffortest[128]; void main(void) { char name[40]={"D:TEMP.TXT"}; loadauxmem(name); } unsigned char loadauxmem (char* f) { unsigned i=0, j=0; FILE* fi=fopen (f, "rb"); if (!fi) return 1; while (!feof(fi)) { i=fread (auxbufx, 1, 128, fi); if (i==-1) {fclose (fi); return 1;} memcpy(tempbufffortest,auxbufx,i); printf("%s\n",tempbufffortest); j+=i; } fclose (fi); return 0; } Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 26, 2021 Author Share Posted September 26, 2021 I tried disabling the unused memory areas and their headers, and now the screen is empty except for the cursor. I am reissuing the files now. crt0.s atarixl_memx.cfg readauxfile.c Quote Link to comment Share on other sites More sharing options...
danwinslow Posted September 26, 2021 Share Posted September 26, 2021 Unless you've modified it, the problem is not in the crt0.s file. aux_memcpyto (j, &auxbufx, i); Aren't you taking an address of an address here? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 26, 2021 Share Posted September 26, 2021 let's assume that's ok as he's told us that this is part of the banking so internally I would think the offset is being split to make a bank # and then offset, e.g. into $4000 Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 26, 2021 Author Share Posted September 26, 2021 auxbufx is an unsigned char array, and I did modify crt0.s. The modification is in the attached crt0.s file. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 26, 2021 Share Posted September 26, 2021 (edited) 21 minutes ago, danwinslow said: aux_memcpyto (j, &auxbufx, i); Aren't you taking an address of an address here? That will just waste some processing time, the call is just wrong as I explained earlier. When compiling you should be getting this error "Warning: Converting integer to pointer without a cast" unless your prototype for aux_memcpyto is defined incorrectly Edited September 26, 2021 by TGB1718 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted September 26, 2021 Share Posted September 26, 2021 1 hour ago, Wrathchild said: let's assume that's ok as he's told us that this is part of the banking so internally I would think the offset is being split to make a bank # and then offset, e.g. into $4000 Well I guess. It's been a while and I can't remember if &arrayname gives you the array start anyway, or it gives you an address formed from the contents of the first 2 bytes at arrayname. If you get a ** back he would be overwriting page 0 probably. Anyways, I'm out. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 26, 2021 Author Share Posted September 26, 2021 Again, auxbufx is an unsigned char array. j starts at 0 but refers to aux memory. The problem has to be in the crt0.s file, as, when I put "while (1);" at the beginning of the main() function, the problem still occurs. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 26, 2021 Share Posted September 26, 2021 If as @drac030 says that this is a bad CIO call, then the problem must be in the screen open call. From the code, I cant see what the code for findfreeiocb does, I assume it looks for a free IOCB. also scrdev , how is this formatted, there must be a $9B after the name i.e. scrdev .BYTE "E:",$9B if your passing in a "C" string as the device, it's going to have a '0' at the end, so will cause problems Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 26, 2021 Share Posted September 26, 2021 please just generate a the test xex and lst or label file with it, it'll be far easier to debug. the only real activity before main is called is the calling of entries in the constructor table but in theory you shouldn't have anything there. Quote Link to comment Share on other sites More sharing options...
sanny Posted September 27, 2021 Share Posted September 27, 2021 A much simple way to make use of the XMEM memory area 480-700 is to use the _heapadd function (https://cc65.github.io/doc/funcref.html#ss3.5). And then just malloc(). No fiddling with crt0.s and linker config needed. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 27, 2021 Author Share Posted September 27, 2021 I got it to ork a little better: now it displays nothing but a cursor before crashing. And sanny: I want to add initialized code and data to the XMEM and other low-memory areas as well. Quote Link to comment Share on other sites More sharing options...
sanny Posted September 27, 2021 Share Posted September 27, 2021 Check if the format of your EXE file is ok. And, if you would post a complete project with source code and how you are building it, please might be better able to help. Giving always just pieces of information leaves to much of guesswork to the others. Quote Link to comment Share on other sites More sharing options...
sanny Posted September 27, 2021 Share Posted September 27, 2021 50 minutes ago, Harry Potter said: And sanny: I want to add initialized code and data to the XMEM and other low-memory areas as well. Huh? Loading a file to this area is not having initialized code and data in this area. I guess you want to load it automatically as part of the EXE file loading. 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.