Page 1 of 1
Assembler with correct srec output
Posted: Fri Dec 10, 2010 2:01 pm
by Mindiell
Hello everyone,
I'm now looking for a correct assembler able of outputing a s-19 file. I use
the wikipedia page and
the linux man page to understand how this format file works.
I tried this very simple code
Code: Select all
org $4000
lda source
sta dest
sec
rts
source db $77
dest db $00
I tried thoses assemblers :
- FASM
S10D4000AD08408D094038607700D8
SA DEST 4009 0 17 2 0
SA SOURCE 4008 0 17 2 0
S9030000FC
The problem here is at the last line : a S9 command should contain the starting execution address, fasm is always giving 0000.
The address field contains the starting execution address and is interpreted as a 2-byte address.
- AS65
S10D4000AD08408D094038607700D8
S5030001FB
The problem here is on the first line. If you look at the "count bytes" it's 0D, but it have to be 0E, no ?
These characters when paired and interpreted as a hexadecimal value, display the count of remaining character pairs in the record.
Re: Assembler with correct srec output
Posted: Fri Dec 10, 2010 5:54 pm
by BigDumbDinosaur
S10D4000AD08408D094038607700D8
SA DEST 4009 0 17 2 0
SA SOURCE 4008 0 17 2 0
S9030000FC
The problem here is at the last line : a S9 command should contain the starting execution address, fasm is always giving 0000.
The address field contains the starting execution address and is interpreted as a 2-byte address.
Not necessarily. Motorola made that address optional (also true of S8 and S7 records), since S-records could be used for any kind of data transfer, not just transfer of an executable binary. It's up to the program that generates the S-records to decide whether or not to populate the execution address field. It's also up to the program that reads and interprets the S-records to decide if the address field in an S7, S8 or S9 record is meaningful. In your case, each S1 record implicitly states the load address.
S10D4000AD08408D094038607700D8
S5030001FB
The problem here is on the first line. If you look at the "count bytes" it's 0D, but it have to be 0E, no ?
These characters when paired and interpreted as a hexadecimal value, display the count of remaining character pairs in the record.
I counted 13 pairs, so $0D is correct. The byte count encompasses everything after the byte count. Hence the count includes the record load address (4000), the data (AD08408D094038607700) and the record checksum D8.
Posted: Sat Dec 11, 2010 8:05 pm
by teamtempest
Here's a link to part of the documentation of another assembler which purports to output Motorola S-Record files:
http://home.earthlink.net/~hxa/docs/hxa_mhex.htm
For that one a non-zero start address is generated by placing an expression representing it after an 'END' pseudo op. No 'END' pseudo op or no expression following it gets the default '0000' value in an S9 record.
I haven't read its documentation but FASM may also want the programmer to explicitly state somewhere what the start address value should be if it's supposed to be non-zero.
I notice that both FASM and AS65 generate the same first line, the S1 record, for your sample code. AS65's second output line is a correct S5 record (data record count), not an S9 (start address), which doesn't appear.
Posted: Sun Dec 12, 2010 1:54 am
by BigDumbDinosaur
I notice that both FASM and AS65 generate the same first line, the S1 record, for your sample code. AS65's second output line is a correct S5 record (data record count), not an S9 (start address), which doesn't appear.
The S5 or S6 record, according to the official Motorola standard, is optional but recommended to help detect corruption issues (i.e., missing records). The only mandatory records are 1 (as many as required) and 9. While required, the S9 record is usually ignored by most loaders. Its presence in the data stream merely signifies the end of data.
Posted: Sun Dec 12, 2010 4:47 pm
by teamtempest
The S5 or S6 record, according to the official Motorola standard, is optional but recommended to help detect corruption issues
Sorry, I didn't mean to imply these were required records. I simply meant that there is nothing wrong with the S5 record itself in AS65's output. The OP's concern seems to be about correct S1 records and S9 records that contain start addresses. I'm just pointing out that the S1 records are identical in both cases and that AS65 did not output any S9 record that was shown to us.
Posted: Sun Dec 12, 2010 7:56 pm
by Mindiell
Well, it seems I may did an error or two

FASM and AS65 are good for their first S1 line, I was wrong (I was not sure, as I said in the first post). For the start address, I will have another look in the FASM doc in order to be sure that I can ask for a correct address.
Thanks to everyone for your help !
Re: Assembler with correct srec output
Posted: Mon Dec 13, 2010 8:56 am
by Mindiell
Finally, with a little modification in the code :
Code: Select all
org $4000
lda source
sta dest
sec
rts
source db $77
dest db $00
end $4000
The as65 is giving me the S9 line with the correct value $4000.
Thanks again,