Building goes wrong (sometimes)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Bleksak
Posts: 6
Joined: Fri Aug 04, 2017 7:39 am

Building goes wrong (sometimes)

Post 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 wrong build
The correct 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.
User avatar
zaval
Member
Member
Posts: 659
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Building goes wrong (sometimes)

Post 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.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Bleksak
Posts: 6
Joined: Fri Aug 04, 2017 7:39 am

Re: Building goes wrong (sometimes)

Post 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
snijj
Posts: 17
Joined: Sat Apr 04, 2015 9:35 am
Location: Scarborough, UK

Re: Building goes wrong (sometimes)

Post 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.
Bleksak
Posts: 6
Joined: Fri Aug 04, 2017 7:39 am

Re: Building goes wrong (sometimes)

Post by Bleksak »

Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: Building goes wrong (sometimes)

Post 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.
Bleksak
Posts: 6
Joined: Fri Aug 04, 2017 7:39 am

Re: Building goes wrong (sometimes)

Post 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..
Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: Building goes wrong (sometimes)

Post 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.
Bleksak
Posts: 6
Joined: Fri Aug 04, 2017 7:39 am

Re: Building goes wrong (sometimes)

Post 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!
Post Reply