Well, I have somehow managed to get this working:
Code: Select all
unit kernel;
interface
implementation
label test;
procedure PMain; stdcall; [public, alias: 'PMain'];
begin
asm
test:
cmp cx,3
jne test
end;
end;
end.
Bochs debugger shows this:
Code: Select all
call .+0x00005014
(below: in function PMain, entering ASM directive)
push ebp
mov ebp, esp
(finished initialization of asm directive, below: the code itself)
cmp cx, 0x0003
jnz .+0xfffffffa
(code is alright)
leave
ret
(above:successful ending of directive END :))
jmp .+0xfffffffe (jmp $)
(end of function PMain, in STUB.ASM)
I used TASM to compile the assembly files generated by free pascal. (Using NASM it didnt work). So this worked, but TASM couldn't compile the unit PATSCREEN:
Code: Select all
**Error** screen.s(302) CS unreachable from current segment
- weird.
Combuster wrote:It looks like you are mixing 16 and 32 bit code and environments.
Actually no, the STUB.ASM will switch to protected mode before executing the function PMAIN.
I think I will download the original barebone freepascal OS, including the multiboot specifications, and if it would work, I will just load the OS with GRUB, after getting data from multiboot tables I'll just drop down the protected mode, go into real mode (for initializing OS specific functions etc) and go back into pmode.
//EDIT: It seems that I can't. The whole bloated thing of course must be in ELF, LD doesn't support 32bit OMF and it must have these multiboot stupid routines. Ah well, time to check to AnonymOS.