OSDev in Pascal..
Posted: Thu Sep 12, 2002 11:00 pm
Hi,
Ive started trying to code simple OS under FreePascalCompiler. If anyone is interested in it, or in OSDEV in Pascal then please read this:
If you want to skip RTL ommit the linking stage using the "-a" switch. FPC requires some external symbols, like:
FPC_INITIALIZEUNITS ; this function should initialize all the units
FPC_DO_EXIT ; what to do if the program ends
INIT$$SYSTEM ; init for basic system routines
It can looks like:
;--
global FPC_INITIALIZEUNITS
global FPC_DO_EXIT
global INIT$$SYSTEM
extern program_init
INIT$$SYSTEM:
start:
call program_init
ret
FPC_INITIALIZEUNITS:
ret
FPC_DO_EXIT:
ret
; --
compile this file, for example "nasm filename.asm -f aout"
all you have to do later is to link main pascal program and this tiny asm loader.
To output "flat binary":
ld asmout.o pascalprog.o --oformat binary -Ttext 0xtextsectionstart
If you`ll use some procedures/functions in the linking stage some errors will be displayed.. these are functions which FPC requires for property working, like copying parameters to a function. Look at FPC sources (it might be "rtl sources\inc\i386.inc"), if you dont find this procedure out there try to find it somewhere else in the sources tree.
Another useful thing is old, good intel syntax. To enable it use "-Rintel" switch in ppc386 command-line. You can then use assembler syntax like:
mov eax, $0DEADBEEF
mov esi, $012345
mov [esi], eax
...
This things are really basic. Its quite weird, but not difficult. When I`ll have some more free time I`ll try to describe this things much more clearier, and deeper.
If you have any questions, or you have write some your own piece of code, please write me: [email protected]
I hope this small text could help someone in Pascal-OSDEV.
Greetings, Crg.
Ive started trying to code simple OS under FreePascalCompiler. If anyone is interested in it, or in OSDEV in Pascal then please read this:
If you want to skip RTL ommit the linking stage using the "-a" switch. FPC requires some external symbols, like:
FPC_INITIALIZEUNITS ; this function should initialize all the units
FPC_DO_EXIT ; what to do if the program ends
INIT$$SYSTEM ; init for basic system routines
It can looks like:
;--
global FPC_INITIALIZEUNITS
global FPC_DO_EXIT
global INIT$$SYSTEM
extern program_init
INIT$$SYSTEM:
start:
call program_init
ret
FPC_INITIALIZEUNITS:
ret
FPC_DO_EXIT:
ret
; --
compile this file, for example "nasm filename.asm -f aout"
all you have to do later is to link main pascal program and this tiny asm loader.
To output "flat binary":
ld asmout.o pascalprog.o --oformat binary -Ttext 0xtextsectionstart
If you`ll use some procedures/functions in the linking stage some errors will be displayed.. these are functions which FPC requires for property working, like copying parameters to a function. Look at FPC sources (it might be "rtl sources\inc\i386.inc"), if you dont find this procedure out there try to find it somewhere else in the sources tree.
Another useful thing is old, good intel syntax. To enable it use "-Rintel" switch in ppc386 command-line. You can then use assembler syntax like:
mov eax, $0DEADBEEF
mov esi, $012345
mov [esi], eax
...
This things are really basic. Its quite weird, but not difficult. When I`ll have some more free time I`ll try to describe this things much more clearier, and deeper.
If you have any questions, or you have write some your own piece of code, please write me: [email protected]
I hope this small text could help someone in Pascal-OSDEV.
Greetings, Crg.