Espozo wrote:
One strange thing I noticed is that each file is 256KB long, and it used to be 6 bytes with the code that showed something in the debugger. Is there something wrong with your code?
No, that's intentional. The assembler can automatically put code in the right place in the ROM file, so that's what I did. You should be able to just split the output file from my example and load it with MAME. (Now that I look, I forgot to pad it to the correct size. It probably should have been exactly 512kiB total/256kiB each, but it's a few bytes short.)
Espozo wrote:
You know, could someone actually just tell me what everything means here?
I'll do my best.
Espozo wrote:
I switched the order you had the code to where the bottom is now at the top like so:
That probably broke it.
Anyway, time to explain things.
Code:
section code vstart=0 align=16
The first section is named "code". Its origin (vstart) is 0. It is aligned to a 16-byte boundary, since x86 segments are 16-byte aligned. Its physical location in the output is unspecified, so YASM puts it after the previous section. Since I put this section first, it ends up at the beginning of the ROM.
Code:
main_code:
---snip---
jmp infinite_loop
This is the code you want to run immediately after reset. You could replace this with whatever you want, as long as you update the reset vector to point to the correct label.
Code:
section reset start=0x7fff0 vstart=0
The second section is named "reset". It starts at 0x7FFF0 in the ROM file. Its origin is 0.
Code:
cli
jmp (section.code.start >> 4):main_code
This disables most interrupts, then performs a far jump to the start of your code. The purpose of "section.code.start >> 4" is to calculate the segment that should be used to access the "code" section. Since the code section is at the beginning of the ROM right now, I could have just written
jmp 0:main_code. At some point you'll be moving the code section to make room for the IVT, so I made sure it will automatically correct itself when that happens.
Espozo wrote:
I'm guessing that it jumps to an area with no code in it instead of the correct area, because if I let it run, it fills up with "add [bw+ix],al".
You should probably step through it instead of letting it run. At least that way, you'll be able to see what it's doing right before it jumps off to nowhere. (Plus, if anything triggers a NMI, it'll jump off to nowhere anyway since you don't have a NMI handler yet.)
Espozo wrote:
This has proven to be far more complicated than I had originally anticipated...
Don't worry. Once you've got the basic setup code functioning, it'll get easier.