Compiling POSx86,

Tools Needed :

Ubuntu and Linux Users

You don't need to download nasm from the official Webiste,
Open up a Terminal a Type : sudo apt-get install nasm

Step 1 : Compiling POSx86 Kernel,NTLOAD and DOSMode

Windows Users

Once you have downloaded NASM, Goto the NASM install directory and copy the "nasm.exe" file.
Create a New Directory called C:\NASM, and then paste the nasm.exe file,
After that Open the Start Menu and type, Environment Variables, Click on Change the System Environment Variables,And Click Environment Variables And Find PATH in the bottom context menu., If the variable contains a value like C:\FAKEPATH or anyother value then put a semicolon ";" and add C:\NASM after that, Mine Looks like this :

*C:\Program Files\NVIDIACorporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem;%
SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\qemu;
C:\NASM*



DON'T COPY PASTE THIS, YOUR SYSTEM VARIABLES MIGHT HAVE BEEN CHOSEN BY YOUR HARDWARE MANUFACTURER, CHANGING THEM MAY CAUSE DAMAGE, JUST ADD A SEMICOLON AND ADD C:\NASM
If your PATH variable is empty then simply add C:\NASM,
If there is no path variable then Add a New one and Call it path with it's value as C:\NASM
Now goto cmd and type "nasm",
It should say :
  • nasm: error: no input file specified
  • type `nasm -h' for help
Once this is done, you have successfully set up the Build Environment :D!
Now download the POSx86 Source Code,
Goto the kernel folder and create a text file, and rename it to nasmbuild.bat,
Note: If you are not able to change extension because Windows Doesn't show file name extension like :
New text document.txt then goto Folder Options and then goto View and uncheck the box that says Hide File Extensions For Known File Types
On Linux rename the File to nasmbuild.sh
Now open the file through Notepad or gEdit and add the following Lines of Code
Linux
nasm -O0 -w+orphan-labels -f bin -o kern86.bin kernel.asm || exit
Windows
nasm -f bin kernel.asm -o kern86.bin
On Linux Open the Terminal and navigate to the source/kernel directory and type :
./nasmbuild.sh
It should Compile, If there are any errors please report us.
On Windows just double click the nasmbuild.bat, and it should compile.
Now check your kernel directory, there should be a new file called kern86.bin,
YAY! We compiled the POS Kernel!
Now let's compile DOSMode Kernel,
Navigate to dosmode directory and add a newfile called nasmbuild.bat
And open the file through gEdit or Notepad and type :
Linuxes should use nasmbuild.sh
Linux
nasm -O0 -w+orphan-labels -f bin -o blubrd.bin blubrd.asm || exit
Windows
nasm -f bin blubrd.asm -o blubrd.bin
On Linux Open the Terminal and navigate to the source/dosmode directory and type :
./nasmbuild.sh
It should Compile, If there are any errors please report us.
On Windows just double click the nasmbuild.bat, and it should compile.
Now check your kernel directory, there should be a new file called blubrd.bin,
Now let's compile NTLOAD our second stage bootloader!
Navigate to source/ntldr and make a new file called nasmbuild.bat
And open the file through gEdit or Notepad and type :
Linuxes should use nasmbuild.sh
Linux
nasm -O0 -w+orphan-labels -f bin -o NTLOAD.bin NTLOAD.asm || exit
Windows
nasm -f bin NTLOAD.asm -o NTLOAD.bin
On Linux Open the Terminal and navigate to the source/dosmode directory and type :
./nasmbuild.sh
It should Compile, If there are any errors please report us.
On Windows just double click the nasmbuild.bat, and it should compile.
Now check your kernel directory, there should be a new file called ntload.bin,
Weeee! Almost Done with the Kernels and Loaders, now the sectors and programs.

Step 2 : Compiling the Boot Sector and Programs

Goto source/boot and find mbr.asm file,
And open the file through gEdit or Notepad and type :
Linuxes should use nasmbuild.sh
Linux
nasm -O0 -w+orphan-labels -f bin -o mbr.bin mbr.asm || exit
Windows
nasm -f bin mbr.asm -o mbr.bin
On Linux Open the Terminal and navigate to the source/boot directory and type :
./nasmbuild.sh
It should Compile, If there are any errors please report us.
On Windows just double click the nasmbuild.bat, and it should compile.
Now check your kernel directory, there should be a new file called mbr.bin,
YAY! Now we are going to compile the programs!
Compiling programs could be a bit tough since each assembly file is a separate program, so if POS has 16 program we would have to make 16 build scripts? No! We will use some nice tricks provided by Mike Saunder's MikeOS build script!
Goto source/programs/assembly and create a file called nasmbuild.bat (Windows) or nasmbuild.sh (Linux) and add :
Linux
for i in *.asm
do
nasm -O0 -w+orphan-labels -f bin $i -o `basename $i .asm`.pex || exit
done
Windows
for %%i in (*.asm) do nasm -O0 -fbin %%i
for %%i in (*.pex) do del %%i
for %%i in (*.) do ren %%i %%i.pex
On Linux Open the Terminal and navigate to the source/boot directory and type :
./nasmbuild.sh
It should Compile, If there are any errors please report us.
On Windows just double click the nasmbuild.bat, and it should compile.
Now check your kernel directory, there should be files with the *.pex extensions,

Step 3 : Putting it together

Alright we compiled everything, now We will first create a floppy image throguh WinImage

ONLY FOR WINDOWS (Linuxes See Further)

Open WinImage, and goto File>Create New Image, and select 1.44 MB Floppy Image,
Now Goto Image>Inject,
Inject the following files>
kern86.bin
ntload.bin
blubrd.bin
and all the .pex and .pbe files in the program/assembly, and programs/posbasic directory,
and copy the HIMAN.IMG from the diskfiles directory
Also you may copy some dos programs, see the distribution disk and look for the .exe files.
NOTE : WINDOWS EXE OR DOS EXE FILES DON'T WORK IN DOS MODE, ONLY .COM FILES WORK!
SO THE PROGRAM MUST BE A .COM FILE RENAMED AS AN .EXE FILE.
Now goto Image>Boot Sector Properties
and select Open, And browse for the MBR.BIN file.
Goto File>Save as...
And choose the .ima extension and save it as posboot.ima
YAY! Process Complete. Now you could either use QEMU to boot this or write to a Real Floppy and boot it.

Linux (Creating the Image)

Add a file called updateimage.sh in your source directory and add the following lines of code :
if test "`whoami`" != "root" ; then
echo "You must be logged in as root to build (for loopback mounting)"
echo "Enter 'su' or 'sudo bash' to switch to root"
exit
fi
if [ ! -e pos.flp ]
then
echo ">>> Creating new floppy image..."
mkdosfs -C pos.flp 1440 || exit
fi
echo ">>> Adding bootloader to floppy image..."
dd status=noxfer conv=notrunc if=boot/mbr.bin of=pos.flp || exit
rm -rf tmp-loop

mkdir tmp-loop && mount -o loop -t vfat pos.flp tmp-loop && cp kernel/kern86.bin tmp-loop/
cp programs/assembly/*.bin programs/posbasic/*.pbe diskfiles/HIMAN.IMG dosmode/blubrd.bin cp ntldr/ntldr.bin tmp-loop
And run it from the terminal ./updateimage.sh

DONE!

Last edited Nov 2, 2013 at 7:58 AM by ALLDESP, version 2