OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 2:02 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Building goes wrong (sometimes)
PostPosted: Fri Aug 04, 2017 1:15 pm 
Offline

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


Attachment:
File comment: The wrong build
Screenshot_1.png
Screenshot_1.png [ 34.47 KiB | Viewed 2603 times ]

Attachment:
File comment: The correct build
Screenshot_2.png
Screenshot_2.png [ 33.39 KiB | Viewed 2603 times ]


This happens randomly, but all the time.. I even tried assembling and copying all my files manually, but got the same result.


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Fri Aug 04, 2017 2:05 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
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).


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Fri Aug 04, 2017 2:29 pm 
Offline

Joined: Fri Aug 04, 2017 7:39 am
Posts: 6
Well then it's even more weird, cause I get random behavior..

Wrong Build
http://prntscr.com/g4h8ra

Correct Build
http://prntscr.com/g4h7hx


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Fri Aug 04, 2017 10:18 pm 
Offline

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


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Sat Aug 05, 2017 4:47 am 
Offline

Joined: Fri Aug 04, 2017 7:39 am
Posts: 6
https://bitbucket.org/Bleksak/velekos/


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Sat Aug 05, 2017 11:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5134
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.


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Sat Aug 05, 2017 1:57 pm 
Offline

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


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Sat Aug 05, 2017 2:25 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5134
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.


Top
 Profile  
 
 Post subject: Re: Building goes wrong (sometimes)
PostPosted: Sun Aug 06, 2017 11:05 am 
Offline

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 79 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group