+Rick Reynolds Posted March 16, 2023 Share Posted March 16, 2023 I've been working on a small project for my PET 2001. I also took this opportunity to learn a bit more about coding in assembly language. The program processes a stream of bytes that I want to eventually read from a disk file. Currently everything works by embedding the data stream into a memory block within the assembled program. So I'm ready to write a routine (or routines) that will allow it to read from a file. Can someone point me to resources to help with understanding disk reads via assembly? The only decent resources I've found are targeting the C64 and the routines to call are different. My use case is a simple byte-by-byte data stream from a file, and I'm using DASM as the assembler. I've been trying to understand the disk file open and disk reading routines in the LADS assembler via The Second Book of Machine Language from Compute books, but my first experiment using code modeled after what I found there didn't work at all. Quote Link to comment Share on other sites More sharing options...
+Rick Reynolds Posted March 16, 2023 Author Share Posted March 16, 2023 YOWCH! Sorry for not browsing through the topics here before starting a new thread. I just found this existing thead: The poster is wanting to use cc65 not DASM, but I'll see if I can find out what I need there. If that thread is completely off-topic for what I need, I'll post back here with further questions. Quote Link to comment Share on other sites More sharing options...
+Rick Reynolds Posted March 16, 2023 Author Share Posted March 16, 2023 Ok, I read that thread and I'm not really any closer to understanding what I need. I'd still be appreciative of pointers to resources that might help me with reading a disk file via assembler on a PET 2001. Quote Link to comment Share on other sites More sharing options...
+Rick Reynolds Posted March 17, 2023 Author Share Posted March 17, 2023 After more reading on this, I think I'm going to punt and see if I can do the file read in BASIC, then call my machine language code after all the data from the file is loaded into memory. It won't be as elegant as reading from the file byte-by-byte and processing it that way (or perhaps chunks of data at a time), but it will get me moving. It will instill a limitation on the program in that all the data for use by the program must now fit into memory. But I think I can live with that for version 1.0 at least. If anyone finds this thread and can give me more insight into this stuff, I'd be appreciative. Quote Link to comment Share on other sites More sharing options...
+Rick Reynolds Posted March 17, 2023 Author Share Posted March 17, 2023 I seem to be talking to myself, but in the interests of wrapping this up, here's what I settled on. 10 IFD=1THEN30 20 D=1:LOAD"MYDATA",8,1 30 SYS1088 I'm assembling raw byte data at $0401 to embed the above BASIC program, then I reset ORG to $0440 (which is 1088 decimal) and assemble the actual program. The MYDATA file has its loading address in the first two bytes and the BASIC LOAD command just pulls it all in at that memory location. It works, but as mentioned above it has the draw-back of needing to load all the data into memory up front, limiting the amount of data the program can process. But again, for v1.0 it's just fine. 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.