SmileyDude Posted July 27, 2014 Share Posted July 27, 2014 This is kinda off topic, since it's not for the Atari 2600, but I figured I would ask it here since I'm using DASM for this. I need to be able to output a small header at the front of a binary generated with DASM -- 2 bytes for the start address and 2 bytes for the length of the assembled file. Does anyone know how I can go about this easily with DASM? I would rather not do this with a separate script of some sort in my Makefile. Since DASM should already know both of these values, it would be ideal to do it inside there. Thanks! Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted July 27, 2014 Share Posted July 27, 2014 -f# controls the output format, 2 might do what you need. FORMAT OPTIONS: 1 (DEFAULT) The output file contains a two byte origin in LSB,MSB order, then data until the end of the file. Restrictions: Any instructions which generate output (within an initialized segment) must do so with an ascending PC. Initialized segments must occur in ascending order. 2 RAS (Random Access Segment) The output file contains one or more hunks. Each hunk consists of a 2 byte origin (LSB,MSB), 2 byte length (LSB,MSB), and that number of data bytes. The hunks occur in the same order as initialized segments in the assembly. There are no restrictions to segment ordering (i.e. reverse indexed ORG statements are allowed). The next hunk begins after the previous hunk's data, until the end of the file. 3 RAW (Raw) The output file contains data only (format #1 without the 2 byte header). Restrictions are the same as for format #1. Format 3 RAW (Raw format) Same as format 1, but NO header origin is generated. You get nothing but data. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted July 27, 2014 Share Posted July 27, 2014 You can define a couple of labels 'start' and 'end' at start and end of your program. Then you would do this: .byte start,start>>8,(end-start),(end-start)>>8 start: ...your code... end: Quote Link to comment Share on other sites More sharing options...
SmileyDude Posted July 28, 2014 Author Share Posted July 28, 2014 (edited) -f# controls the output format, 2 might do what you need. This was exactly what I needed. You can define a couple of labels 'start' and 'end' at start and end of your program. Then you would do this: .byte start,start>>8,(end-start),(end-start)>>8 start: ...your code... end: I was initially trying something like this, but was running into problems with multiple .orgs. I didn't want dasm to pad my output file. I guess I could've gone with one .org, just 4 bytes ahead of my real origin. But that didn't really feel right. Maybe that's just something I need to get over myself, though For now, SpiceWare's answer works for me. Thanks! Edited July 28, 2014 by SmileyDude 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.