FreeDOS, Hello World program crashes

DOS specific questions.
IchMagBier
Posts: 43
Joined: Jan 13, 2018 8:47

FreeDOS, Hello World program crashes

Postby IchMagBier » Apr 19, 2019 16:31

Hello :)

So I wanted to try out the new fbc 1.06.0 on FreeDOS 1.2. However, I can't seem to get a simple "Hello World" program working. It is crashing with a "Page fault".
I am using CSDPMI7, which is working on Dosbox.

The program looks like this:

Code: Select all

print "Hi"

The generated .asm like this:

Code: Select all

   .intel_syntax noprefix

.section .text
.balign 16

.globl _main
_main:
push ebp
mov ebp, esp
and esp, 0xFFFFFFF0
sub esp, 12
mov dword ptr [ebp-4], 0
push 0
push dword ptr [ebp+12]
push dword ptr [ebp+8]
call _fb_Init
add esp, 12
.Lt_0002:
push 1
push 10
push offset _Lt_0004
call _fb_StrAllocTempDescZEx
add esp, 8
push eax
push 0
call _fb_PrintString
add esp, 12
.Lt_0003:
push 0
call _fb_End
add esp, 4
mov eax, dword ptr [ebp-4]
mov esp, ebp
pop ebp
ret

.section .data
.balign 4
_Lt_0004:   .ascii   "Hi\0"

The error message from FreeDOS like this:
FreeDOS wrote:D:\>test.exe
Page fault cr2=45071024 at eip=1a52; flags=3246
... register output
error=0006


I am using Qemu as the virtualizer, it has 512 MB RAM, which should be more than enough for fbc.

EDIT: Compiling it with FreeBasic 1.05.0 crashes too.

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest