Bran's Kernel Dev

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
CompDever
Posts: 23
Joined: Sun Jul 22, 2007 12:21 pm

Bran's Kernel Dev

Post by CompDever »

I was doing his tutorial and i came across a strang phenomenon. my batch file that i wrote never creates main.o even though in a seperated batch file it works fine.

I was going to attach a zip file but... 64kb limit??\

batch file

Code: Select all

@echo off
if /h==%1 (GOTO exitc)
if /help==%1 (GOTO exitc)
echo Setting Up The Environment
cd C:\asm\
call C:\djgpp\bin\setdjgpp.bat C:\djgpp\ C:/djgpp/
echo Environment Setup Complete
echo Compiling assembly
echo          nasm
nasm.exe -E errors.txt ostest.asm -f aout -o ostest.o
echo          gcc
C:\djgpp\bin\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I.\include -c -o main.o main.c
REM Call gccbatch.bat
echo          ld
C:\djgpp\bin\ld.exe link.ld -o main.o ostest.o
echo Compile Attempt Finished
if exist "ostest.o" (GOTO DoPartCopy)
GOTO exita

:DoPartCopy
copy /b ostest.o+main.o ostest.img
call :InsertImgOnDisk "ostest.img"
GOTO exita

:InsertImgOnDisk
echo PartCopy.exe %1 0 %~z1 -f0
PartCopy.exe %1 0 %~z1 -f0
GOTO exitfinal

:exitb
echo .
echo ==================================
echo ========== Final Status ==========
echo ==================================
echo ==Operating System Not Installed==
echo ==================================
if /d==%1 (GOTO exitd)
if /d==%2 (GOTO exitd)
echo cleaning up...
del "main.o"
del "ostest.o"
del "ostest.img"
echo done.
pause
GOTO exitd

:exita
echo .
echo ==============================
echo ======== Final Status ========
echo ==============================
echo ==Operating System Installed==
echo ==============================
if /d==%1 (GOTO exitd)
if /d==%2 (GOTO exitd)
echo cleaning up...
del "main.o"
del "ostest.o"
del "ostest.img"
echo done.
GOTO exitd

:exitc
echo Operating System Installer
echo Usage "[LOCATION\]install ostest.bat" [/h, /help, /?] [/d]
echo Example "install ostest.bat" /d
echo Commands
echo "/d"                       Skips end of batch cleanup (which removes the objects, the OS Image, and the error log)
echo "/h" "/help"               Help commands, display this message (and ends the batch immediately)

:exitd
GOTO exitfinal
:exitfinal
dev tutorial
TomTom
Posts: 23
Joined: Tue May 01, 2007 2:03 am
Location: USA

Post by TomTom »

makefiles were invented for this very process of automating builds... ;)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Mate, seriously, do you expect us to debug a batch file for you??

1) Use makefiles.
2) Debug it yourself! It's good practice, if you can't debug a batch file what chance have you with an OS?!
3) [troll] UNIX ftw [/troll]

JamesM
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

To add to what has already been said (or that which has already been said? :) ):

I used to use djgpp and a combination of batch/makefiles to build which was a bit of a pain. I had to add each source file separately to the makefile as I didn't have all of the unix command line tools available.

Try using Cygwin or GCC on Linux, however, and you can use Solar's Makefile Tutorial which has mean't I can now forget about the makefile - it just works.

Cheers,
Adam
Solidus117
Posts: 23
Joined: Sun Dec 03, 2006 5:29 pm

Post by Solidus117 »

"Use make" is the general message, unless you're just playing around with code. Later on you'll appreciate how nice make is when your code blossoms into a nuclear deathcloud.
Post Reply