Harry Potter #1 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 Share this post Link to post Share on other sites
Harry Potter #2 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 Share this post Link to post Share on other sites
Wrathchild #3 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 Share this post Link to post Share on other sites
Harry Potter #4 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 Share this post Link to post Share on other sites
Wrathchild #5 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 Share this post Link to post Share on other sites
Harry Potter #6 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 Share this post Link to post Share on other sites
Harry Potter #7 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 Share this post Link to post Share on other sites
Harry Potter #8 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 Share this post Link to post Share on other sites
drac030 #9 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 Share this post Link to post Share on other sites
TGB1718 #10 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 Share this post Link to post Share on other sites
Harry Potter #11 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 Share this post Link to post Share on other sites
TGB1718 #12 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 Share this post Link to post Share on other sites
Harry Potter #13 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 Share this post Link to post Share on other sites
danwinslow #14 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 Share this post Link to post Share on other sites
Wrathchild #15 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 Share this post Link to post Share on other sites
Harry Potter #16 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 Share this post Link to post Share on other sites
TGB1718 #17 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 Share this post Link to post Share on other sites
danwinslow #18 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 Share this post Link to post Share on other sites
Harry Potter #19 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 Share this post Link to post Share on other sites
TGB1718 #20 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 Share this post Link to post Share on other sites
Wrathchild #21 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 Share this post Link to post Share on other sites
sanny #22 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 Share this post Link to post Share on other sites
Harry Potter #23 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 Share this post Link to post Share on other sites
sanny #24 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 Share this post Link to post Share on other sites
sanny #25 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 Share this post Link to post Share on other sites