MichaelPetch wrote:You could be having issues because of how you build this or how it is run .I don't know if this was in a bootloader or not. Are you using a linker script, if not what linker command do you use? Showing us exactly how you generate the code, and tell us how you run it.
This is my Makefile
Code: Select all
boot.iso: deploy/boot.bin
mkisofs -b boot.bin -hide boot.bin -iso-level 3 -no-emul-boot -o boot.iso deploy/
deploy/boot.bin: build/snake.o
ld -Ttext 7c00 --oformat=binary build/snake.o -nostartfiles -nostdlib -o deploy/boot.bin
build/snake.o: snake.s
as snake.s -o build/snake.o
MichaelPetch wrote:
With that being said the most obvious thing I see wrong is how you send EOI to the PIC. You do:
(youdo this in two places). That should be 0x20 hex not decimal. Try
Thanks, that fixed the problem of IRQ's not firing.
Brendan wrote:Hi,
The BIOS will probably need a few KiB of stack space, but you set SS:SP to 0x0000:0x07BF so that there's only about half a KiB of space before the BIOS overwrites its own data in the BDA. It's also strange to misalign the stack. I'm thinking that this might have been a typo (and that you actually wanted SS:SP to 0x0000:0x7C00 so that the first word pushed on the stack ends up just below the code at 0x00007BFE).
My intention was to put stack 2 byte below the 0x7C00. It was supposed to be 0x7BFD. I was in the impression that putting the stack at 0x7C00 would overwrite my code.
Brendan wrote:
If you're not using a linker (which doesn't make too much sense given that most tools don't support real mode); then you're missing an "ORG 0x7C00" at the top or something to define sections.
I am passing -Ttext 7c00 to my ld. Since I am booting with El Torito, I am not using bios magic value, since it works without it too.
Brendan wrote:Hi,
When registering your interrupt handlers, you're saving and restoring ES for no reason (because it wasn't set to anything that matters in the first place) and could use DS instead of ES (because DS is already set to 0x0000) and avoid an extra "segment override prefix" on some instructions. It would also be more efficient to do direct writes, so the entire thing becomes something like:
Code: Select all
cli
movw $timer_handler,(32)
movw $0,(34)
movw $keyboard_handler,(36)
movw $0,(38)
sti
That was the first thing I tried. After seeing that it didn't work, I tried random things until I gave up and started this thread.
Brendan wrote:
Your code to get a random number seems strange - after being called 8 times you can guarantee it will always return 0x5555, and after being called 4 times you can guarantee the value 0x55 will be in AL. I'm not sure if you wanted the last instruction to be "xor %ax,random".
My random sequence was supposed to be next = 5 * prev + 1 (mod 2^16). Maybe I should sleep more :/ Fixed it now.
Brendan wrote:
Finally; I'm not sure why you're doing this in the first place. The BIOS already has IRQ handlers that aren't broken (e.g. that convert scan codes to ASCII for you and may work with USB keyboards when the nasty and often buggy "PS/2 emulation" isn't enabled); and I'm worried that you're planning to fall into the
"real mode OS trap".
I am trying to do Snake game that works in real mode. I will read direction keys with keyboard interrupts and run main loop with timer interrupts.