I successfully loaded a hex file front panel program. Got that down.
In figuring that out, I also read the description in the Config Monitor doc regarding binary files. So for bin files a load address is needed. Can someone give an example of what loading bin files would be used for, vs. hex? And I assume all hex files go into address 0?
I just need a better understanding of the bin vs. hex file dynamic.
Loading hex and bin files
-
- Posts: 52
- Joined: February 9th, 2019, 12:11 pm
- Contact:
-
- Posts: 42
- Joined: March 8th, 2018, 3:13 pm
- Contact:
Re: Loading hex and bin files
BIN files are just "BINary" data. The file just contains a byte stream of the data. Since there's no provision in a BIN file for any control data, you need to specify a starting address when loading a BIN.
Note that COM files are identical to BIN files, but they always start at 0100h. So if you assemble your BIN files to 0100h, your programs can be run from CP/M.
On the other hand, Hex files have the address built in to the file format, and every line in the file allows you to set a new address. Hex files are plain ASCII files, with the data encoded in hex format.
So a hex file could, for example, load code at 100h-400h, then load a bunch of data at 2000h.
Here's a line from a hex file:
:10010000214601360121470136007EFE09D2190140
Hex file lines always start with a :
10 is the record size (16 bytes)
0100 is the address of this line of data.
00 is the record type (00=data, 01=end of file)
the next 32 characters are the data in hex (16 bytes worth)
the 40 at the end is a checksum of all the bytes on the line. (Add the values and get the two's complement.)
The Wikipedia page is actually pretty good, and I've written both hex encoders and loaders from this description:
https://en.wikipedia.org/wiki/Intel_HEX
Note that COM files are identical to BIN files, but they always start at 0100h. So if you assemble your BIN files to 0100h, your programs can be run from CP/M.
On the other hand, Hex files have the address built in to the file format, and every line in the file allows you to set a new address. Hex files are plain ASCII files, with the data encoded in hex format.
So a hex file could, for example, load code at 100h-400h, then load a bunch of data at 2000h.
Here's a line from a hex file:
:10010000214601360121470136007EFE09D2190140
Hex file lines always start with a :
10 is the record size (16 bytes)
0100 is the address of this line of data.
00 is the record type (00=data, 01=end of file)
the next 32 characters are the data in hex (16 bytes worth)
the 40 at the end is a checksum of all the bytes on the line. (Add the values and get the two's complement.)
The Wikipedia page is actually pretty good, and I've written both hex encoders and loaders from this description:
https://en.wikipedia.org/wiki/Intel_HEX
-
- Posts: 52
- Joined: February 9th, 2019, 12:11 pm
- Contact:
Re: Loading hex and bin files
Good info, thanks! So, this got me wondering:TomXP411 wrote:BIN files are just "BINary" data. The file just contains a byte stream of the data. Since there's no provision in a BIN file for any control data, you need to specify a starting address when loading a BIN.
Note that COM files are identical to BIN files, but they always start at 0100h. So if you assemble your BIN files to 0100h, your programs can be run from CP/M.
On the other hand, Hex files have the address built in to the file format, and every line in the file allows you to set a new address. Hex files are plain ASCII files, with the data encoded in hex format.
So a hex file could, for example, load code at 100h-400h, then load a bunch of data at 2000h.
Here's a line from a hex file:
:10010000214601360121470136007EFE09D2190140
Hex file lines always start with a :
10 is the record size (16 bytes)
0100 is the address of this line of data.
00 is the record type (00=data, 01=end of file)
the next 32 characters are the data in hex (16 bytes worth)
the 40 at the end is a checksum of all the bytes on the line. (Add the values and get the two's complement.)
The Wikipedia page is actually pretty good, and I've written both hex encoders and loaders from this description:
https://en.wikipedia.org/wiki/Intel_HEX
Let's say I have run across a program in hex format that says it's for the 8080. It starts out like this:
0000: 31 82 0D CD AC 09 21 6D 0B CD DA 01 21 93 0B CD
0010: DA 01 21 B9 0B CD DA 01 CD AC 09 CD AF 05 21 95
0020: 0A 22 7D 0A 21 CB 0A 22 7F 0A 21 01 0B 22 79 0A
0030: 21 37 0B 22 7B 0A AF 32 74 0A 32 78 0A 32 82 0A
...
I can massage the lines to match the template you provided:
:10010000214601360121470136007EFE09D2190140
If I load this into the Altair, will it run?
Besides the statement saying it's for the 8080, are there any other considerations?
-Ken
-
- Posts: 305
- Joined: June 7th, 2013, 12:54 pm
- Contact:
Re: Loading hex and bin files
It may or may not run. If it depends on certain peripherals (such as serial I/O) being at certain addresses, andkwiebe wrote: Good info, thanks! So, this got me wondering:
Let's say I have run across a program in hex format that says it's for the 8080. It starts out like this:
0000: 31 82 0D CD AC 09 21 6D 0B CD DA 01 21 93 0B CD
0010: DA 01 21 B9 0B CD DA 01 CD AC 09 CD AF 05 21 95
0020: 0A 22 7D 0A 21 CB 0A 22 7F 0A 21 01 0B 22 79 0A
0030: 21 37 0B 22 7B 0A AF 32 74 0A 32 78 0A 32 82 0A
...
I can massage the lines to match the template you provided:
:10010000214601360121470136007EFE09D2190140
If I load this into the Altair, will it run?
Besides the statement saying it's for the 8080, are there any other considerations?
those addresses are different than yours, it won't run. Likewise disk access instructions (if any) would have
to match the locations and protocols of your floppy controller. Also if the original program called ROM routines
that were present in the ROM of the original system, you'd have to have a compatible ROM in your system or
load a compatible monitor at the same addresses. The chances of taking a machine language routine written
for an unknown computer and having it run without change on your system are small.
-
- Posts: 42
- Joined: March 8th, 2018, 3:13 pm
- Contact:
Re: Loading hex and bin files
Yes.... the CPU is only part of the computer. You have the display, input devices, storage devices, and potentially the operating system.Besides the statement saying it's for the 8080, are there any other considerations?
An 8080 program can be made to work, but you have to know specifically what hardware it was made for, so if nothing else, you can convert the I/O routines to the Altair.
I wouldn't even bother trying to convert a binary program in the way you describe. You should be looking at source code: preferably a commented assembly file.
-
- Posts: 52
- Joined: February 9th, 2019, 12:11 pm
- Contact:
Re: Loading hex and bin files
I kinda figured someone would say that. But this at least helps me further understand all the variables.
My knowledge of source, assembly, machine, etc. code is from textbooks. I know the basic concepts, but I trained as a high-level language programmer so I was insulated. So I'm looking forward to getting more practical experience (in the hobbyist sense) with the lower-level code and how to work with it.
My knowledge of source, assembly, machine, etc. code is from textbooks. I know the basic concepts, but I trained as a high-level language programmer so I was insulated. So I'm looking forward to getting more practical experience (in the hobbyist sense) with the lower-level code and how to work with it.
-Ken
-
- Posts: 52
- Joined: February 9th, 2019, 12:11 pm
- Contact:
Re: Loading hex and bin files
Can anyone suggest a book or two which would be helpful for me to bridge the gap in my knowledge of Altair machine/assembly programming?
I do see the manual on the clone site but was hoping for something which might flatten the learning curve, first.
I do see the manual on the clone site but was hoping for something which might flatten the learning curve, first.
-Ken
-
- Posts: 104
- Joined: October 11th, 2014, 8:12 am
- Contact:
Re: Loading hex and bin files
I found that this book told me everything I needed to know, having started with no knowledge of 8080 assembly language programming:
https://www.tramm.li/i8080/Intel%208080 ... 0Intel.pdf
Regards
Gabriel Egan
https://www.tramm.li/i8080/Intel%208080 ... 0Intel.pdf
Regards
Gabriel Egan
-
- Posts: 305
- Joined: June 7th, 2013, 12:54 pm
- Contact:
Re: Loading hex and bin files
Thanks for the link! I have a paper copy but the PDF is certainly welcome. I made it searchable to it's easier to use than the paper copy.mail@gabrielegan.com wrote:I found that this book told me everything I needed to know, having started with no knowledge of 8080 assembly language programming:
https://www.tramm.li/i8080/Intel%208080 ... 0Intel.pdf
Regards
Gabriel Egan
Tom L
Who is online
Users browsing this forum: Amazon [Bot] and 10 guests