Page 1 of 1
Building goes wrong (sometimes)
Posted: Fri Aug 04, 2017 1:15 pm
by Bleksak
Hello, I'm having this strange problem, I started with the FAT filesystem and when I try to load a file into memory, I get different results every build.
I posted 2 images so you know, what I'm talking about.
This is my build code, I'm using Windows 10
Code: Select all
DEL /F Build\Image.img
DEL /F Bin\BootLoader.bin
DEL /F Bin\Kernel.bin
imdisk -D -m P:
nasm -f bin -o Bin/BootLoader.bin Dev/BootLoader.asm
nasm -f bin -o Bin/Kernel.bin Dev/Kernel.asm
nasm -f bin -o Bin/TestApp.bin Dev/RandomApp.asm
imdisk -a -f Build/Image.img -s 1440K -m P: -p "/FS:FAT /Y"
imdisk -D -m P:
dd if="Bin/BootLoader.bin" of="Build/Image.img" bs=512 count=1
imdisk -a -f Build/Image.img -m P:
copy Bin\Kernel.bin P:\
copy Bin\TestApp.bin P:\
copy Tische.txt P:\
imdisk -D -m P:
pause
- The wrong build
- The correct build
This happens randomly, but all the time.. I even tried assembling and copying all my files manually, but got the same result.
Re: Building goes wrong (sometimes)
Posted: Fri Aug 04, 2017 2:05 pm
by zaval
i quickly looked at the hexdump, it looks like directory entries. the only difference, i've noticed, is in the fields DIR_CrtTime and DIR_WrtTime. which is probably a normal behaviour.
Re: Building goes wrong (sometimes)
Posted: Fri Aug 04, 2017 2:29 pm
by Bleksak
Well then it's even more weird, cause I get random behavior..
Wrong Build
http://prntscr.com/g4h8ra
Correct Build
http://prntscr.com/g4h7hx
Re: Building goes wrong (sometimes)
Posted: Fri Aug 04, 2017 10:18 pm
by snijj
It's pretty hard to give advice on what is wrong if you don't provide us all the information. Please provide a link to the source code you are trying to compile.
Re: Building goes wrong (sometimes)
Posted: Sat Aug 05, 2017 4:47 am
by Bleksak
Re: Building goes wrong (sometimes)
Posted: Sat Aug 05, 2017 11:50 am
by Octocontrabass
Why are you writing a real-mode OS?
Are you setting up the stack? You might be overflowing the stack set up by the BIOS.
If your code has hlt with interrupts disabled, some emulators will stop before showing the last thing you displayed on the screen. Replace it with an infinite loop (jmp $) and see if that makes a difference.
Re: Building goes wrong (sometimes)
Posted: Sat Aug 05, 2017 1:57 pm
by Bleksak
Octocontrabass wrote:Why are you writing a real-mode OS?
Are you setting up the stack? You might be overflowing the stack set up by the BIOS.
If your code has hlt with interrupts disabled, some emulators will stop before showing the last thing you displayed on the screen. Replace it with an infinite loop (jmp $) and see if that makes a difference.
For fun, I guess.. I set the stack, changed all hlts to jmp $ but still have the same problem..
Re: Building goes wrong (sometimes)
Posted: Sat Aug 05, 2017 2:25 pm
by Octocontrabass
Your strcmp function clobbers several registers that are in use when you call it from disk_load_file.
You should document the calling conventions for all of your functions, so you know exactly which registers will be modified.
Re: Building goes wrong (sometimes)
Posted: Sun Aug 06, 2017 11:05 am
by Bleksak
Octocontrabass wrote:Your strcmp function clobbers several registers that are in use when you call it from disk_load_file.
You should document the calling conventions for all of your functions, so you know exactly which registers will be modified.
You sir, are a genius, I don't know why I didn't pusha/popa in strcmp when I was writing it though, but you sir fixed my problem! Thank you!