Question for Guru's :System Calls

General FreeBASIC programming questions.
Dinosaur
Posts: 1331
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Question for Guru's :System Calls

Postby Dinosaur » Aug 22, 2007 8:16

Hi all

This may sound like a stupid question , but I have been imprisoned in 16 bit dos, so humor me.

If I compile a program in console mode, and in that program I dont do any screen, printer or disk access, does the compiled program make any system calls or interupts.?
I know I can look at the asm files, but is that valid 32bit x86 code or Fb's version of it.?

The reason:
I have been looking at lots of options for a gui, and came across a site called KolibriOS. It is a 32 bit operating system that masks all the system calls and allows access through one interupt (int 40h)
The unusual thing about this sytem is that by filling in a few registers in inline asm, you can call up a very professional XP looking window, buttons etc. It was originally based on MenuetOS, but is now freestanding.

I have already asked a number of questions on their site, but before I go further, I need to confirm that I can get Fb to work on it. Would be interested if anyone has gone down this path.

For me the benefits are obvious, as I dont need to purchase an OS for each installation, and having asm experience can easily implement a Gui.

Regards
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Aug 22, 2007 22:04

I'm no expert on the subject, but unless KolibriOS is a Linux shell, I seriously doubt FB will work on it. From what I gathered on their website, it looks like a completely proprietary OS.

Cheers!
-Vince
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Postby notthecheatr » Aug 22, 2007 22:38

You might try it, just to see, but I suspect you'd have a difficult time. However, you may be right - if you can avoid anything that would make a system call, you might be able to use inline asm to get everything done. I'm not sure it would be the prettiest code, but it might work.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Aug 22, 2007 22:58

If I compile a program in console mode, and in that program I dont do any screen, printer or disk access, does the compiled program make any system calls or interupts.?

It would have to, to terminate if nothing else, and most programs written in a HLL would probably do a lot else. Using the Win32 version of FB, if I compile an empty source file as a console app, I get a 6144-byte exe with the following imports:

Code: Select all

Imp Addr Hint Import Name from KERNEL32.dll - Not Bound
 -------- ---- ---------------------------------------------------------------
 000090B8    1 AddAtomA
 000090BC   9B ExitProcess
 000090C0   AF FindAtomA
 000090C4   DC GetAtomNameA
 000090C8  2DF SetUnhandledExceptionFilter

 Imp Addr Hint Import Name from MSVCRT.DLL - Not Bound
 -------- ---- ---------------------------------------------------------------
 000090D4   3B __getmainargs
 000090D8   52 __p__environ
 000090DC   54 __p__fmode
 000090E0   69 __set_app_type
 000090E4   90 _assert
 000090E8   9A _cexit
 000090EC   A8 _controlfp
 000090F0   D3 _fileno
 000090F4   DE _fmode
 000090F8   E1 _fpreset
 000090FC  111 _iob
 00009100  186 _onexit
 00009104  1B3 _setmode
 00009108  250 abort
 0000910C  257 atexit
 00009110  265 exit
 00009114  274 fprintf
 00009118  27A free
 0000911C  2AD malloc
 00009120  2B5 memset
 00009124  2CB signal

At least most of these imports are functions that are being called.
Dinosaur
Posts: 1331
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Postby Dinosaur » Aug 22, 2007 23:15

Thanks guys

I dont want to program the whole lot in asm, which is what the idea is on this OS.

I will ask the question and see how they handle calls to the system.

MichaelW, that looks like the old .lst file from Qb in your code example.
I looked through a .asm file compiled by Fb, and couldnt find any references such as yours. How did you create this listing. Couldnt find any switches in the compiler help.

Regards

Edit: Sorry I meant Qb .map file
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Aug 22, 2007 23:29

I used Clive Turvey’s DumpPE, available here.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Postby notthecheatr » Aug 23, 2007 22:42

MichaelW wrote:
If I compile a program in console mode, and in that program I dont do any screen, printer or disk access, does the compiled program make any system calls or interupts.?

It would have to, to terminate if nothing else, and most programs written in a HLL would probably do a lot else. Using the Win32 version of FB, if I compile an empty source file as a console app, I get a 6144-byte exe with the following imports:

Code: Select all

Imp Addr Hint Import Name from KERNEL32.dll - Not Bound
 -------- ---- ---------------------------------------------------------------
 000090B8    1 AddAtomA
 000090BC   9B ExitProcess
 000090C0   AF FindAtomA
 000090C4   DC GetAtomNameA
 000090C8  2DF SetUnhandledExceptionFilter

 Imp Addr Hint Import Name from MSVCRT.DLL - Not Bound
 -------- ---- ---------------------------------------------------------------
 000090D4   3B __getmainargs
 000090D8   52 __p__environ
 000090DC   54 __p__fmode
 000090E0   69 __set_app_type
 000090E4   90 _assert
 000090E8   9A _cexit
 000090EC   A8 _controlfp
 000090F0   D3 _fileno
 000090F4   DE _fmode
 000090F8   E1 _fpreset
 000090FC  111 _iob
 00009100  186 _onexit
 00009104  1B3 _setmode
 00009108  250 abort
 0000910C  257 atexit
 00009110  265 exit
 00009114  274 fprintf
 00009118  27A free
 0000911C  2AD malloc
 00009120  2B5 memset
 00009124  2CB signal

At least most of these imports are functions that are being called.


The idea is that he would replace all these things with inline assembly. Err... not much left if you take those away, but it's probably possible, at least in theory. Though I personally would rather just use C or assembly if I had to do such a gruesome task.

Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests