Page 1 of 1

Bran's Kernel Dev

Posted: Mon Jul 23, 2007 12:05 pm
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

Posted: Mon Jul 23, 2007 11:14 pm
by TomTom
makefiles were invented for this very process of automating builds... ;)

Posted: Tue Jul 24, 2007 12:53 am
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

Posted: Tue Jul 24, 2007 1:10 am
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

Posted: Wed Jul 25, 2007 10:47 pm
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.