Difference between revisions of "MorphOS"

From Free Pascal wiki
Jump to navigationJump to search
m
(Typo/lang sweep)
Line 1: Line 1:
This page contains platform specific notes about MorphOS version.
+
This page contains platform specific notes about the MorphOS version.
  
  
 
===Stack===
 
===Stack===
Under MorphOS, the default stack is set to 256 kB. Stack size can be set directly by the programmer with the compiler switch (-Cs), or with the {$MEMORY} directive. The memory area for the stack is dynamically allocated on program startup, so if you set this value too high, in low memory situations your program may exit immediately on startup without any further notice.
+
Under MorphOS, the default stack is set to 256 kB. Stack size can be set directly by the programmer with a compiler switch (-Cs), or with the {$MEMORY} directive. The memory area for the stack is dynamically allocated on program startup, so if you set this value too high, in low memory situations your program may exit immediately on startup without any further notice.
  
Note to classic Amiga programmers: Increasing stack size with 'stack' utility provided with MorphOS '''will not work''' because it sets size of 68k stack for applications running in 68k emulation.
+
Note to classic Amiga programmers: Increasing stack size with the 'stack' utility provided with MorphOS '''will not work''' because it sets the size of the 68k stack for applications running in 68k emulation.
  
 
===Syscalls===
 
===Syscalls===
Free Pascal currently supports ABox-style calls for MorphOS. Using
+
Free Pascal currently supports ABox-style calls for MorphOS. You don't need to use additional hand-written assembly to call any ABox library function. However, you must declare every function you're going to use in the following way:
additional hand-written assembly is not needed to call any ABox library
 
function. However, you must declare every function you're going to use  
 
by the following way:
 
 
   
 
   
 
  Var  
 
  Var  
Line 22: Line 19:
 
Where my_LibBase is the library base returned by exec's OpenLibrary() call, and 1234 is the call  offset. Please note that offset values in Free Pascal must be specified as '''positive values''', and not negative as shown in MorphOS SDK.
 
Where my_LibBase is the library base returned by exec's OpenLibrary() call, and 1234 is the call  offset. Please note that offset values in Free Pascal must be specified as '''positive values''', and not negative as shown in MorphOS SDK.
  
The value after location can be any 68k registers from d0-d7/a0-a5. Register a6 is used internally to pass my_LibBase in it. Register a7/sp cannot be used. Register names are not case sensitive. In SysCalls you must specify location for every arguments explicity.
+
The value after location can be any 68k register from d0-d7/a0-a5. Register a6 is used internally to pass my_LibBase in it. Register a7/sp cannot be used. Register names are not case sensitive. In SysCalls you must specify a location for every argument explicitly.
  
'''MOST IMPORTANT:''' You must open libraries explicitly '''before''' using any functions from it, because the compiler will not do it for you. Don't forget to close libraries before you exit.  
+
'''MOST IMPORTANT:''' You must open the libraries you're going to use explicitly '''before''' using any function from them, because the compiler will not do it for you. Don't forget to close all libraries before you exit.  
  
Before declaring a SysCall function, please check the units provided with FPC, the function you want to use might already be declared in one of the units, and ready to use.
+
Before declaring a SysCall function, please check the units provided with FPC, the function you want to use might already be declared in one of the units, ready to be used.
  
 
===Alignment===
 
===Alignment===
Record elements are aligned to DWORD (4 bytes) under MorphOS by default. Use {$PACKRECORDS 2} if you need word aligned structures. For byte aligned records, use packed record.
+
Record elements are aligned to DWORD (4 bytes) under MorphOS by default. Use {$PACKRECORDS 2} if you need word aligned structures. For byte aligned records, use a packed record.
  
 
===FPCMake===
 
===FPCMake===
[[Fpcmake|FPCMake]] is not yet working on MorphOS. Needs to finish port of Classes unit.
+
[[Fpcmake|FPCMake]] is not yet working on MorphOS. Porting of the Classes unit must finish first.
  
 
===To Do===
 
===To Do===
Line 45: Line 42:
  
 
===Thanks===
 
===Thanks===
MorphOS http://www.morphos.net port of Free Pascal Compiler was possible, because Genesi S.a.r.l. http://www.genesi.lu provided a free Pegasos II/G4 http://www.pegasosppc.com machine to do the developments on it.
+
The MorphOS http://www.morphos.net port of Free Pascal Compiler was possible, because Genesi S.a.r.l. http://www.genesi.lu provided a free Pegasos II/G4 http://www.pegasosppc.com machine to do the development on.

Revision as of 20:01, 21 June 2004

This page contains platform specific notes about the MorphOS version.


Stack

Under MorphOS, the default stack is set to 256 kB. Stack size can be set directly by the programmer with a compiler switch (-Cs), or with the {$MEMORY} directive. The memory area for the stack is dynamically allocated on program startup, so if you set this value too high, in low memory situations your program may exit immediately on startup without any further notice.

Note to classic Amiga programmers: Increasing stack size with the 'stack' utility provided with MorphOS will not work because it sets the size of the 68k stack for applications running in 68k emulation.

Syscalls

Free Pascal currently supports ABox-style calls for MorphOS. You don't need to use additional hand-written assembly to call any ABox library function. However, you must declare every function you're going to use in the following way:

Var 
  my_LibBase: Pointer;

function my_LibCall(param1: longint location 'd0',
                    param2: longint location 'd1'): LongInt; 
         SysCall my_LibBase 1234;

Where my_LibBase is the library base returned by exec's OpenLibrary() call, and 1234 is the call offset. Please note that offset values in Free Pascal must be specified as positive values, and not negative as shown in MorphOS SDK.

The value after location can be any 68k register from d0-d7/a0-a5. Register a6 is used internally to pass my_LibBase in it. Register a7/sp cannot be used. Register names are not case sensitive. In SysCalls you must specify a location for every argument explicitly.

MOST IMPORTANT: You must open the libraries you're going to use explicitly before using any function from them, because the compiler will not do it for you. Don't forget to close all libraries before you exit.

Before declaring a SysCall function, please check the units provided with FPC, the function you want to use might already be declared in one of the units, ready to be used.

Alignment

Record elements are aligned to DWORD (4 bytes) under MorphOS by default. Use {$PACKRECORDS 2} if you need word aligned structures. For byte aligned records, use a packed record.

FPCMake

FPCMake is not yet working on MorphOS. Porting of the Classes unit must finish first.

To Do

There are still many things on the To Do list. Currently, these are the most important ones.

  • Fix startup code to exit gracefully when stack cannot be allocated
  • Clean up some messy parts of System unit
  • Clean up DOS unit, and fix the bugs
  • Clean up and finish SysUtils and Classes unit
  • Start to implement MorphOS specific units (Exec, DOSLib, Graphics, Intuition, etc.)
  • Release a snapshot
  • ... and more

Thanks

The MorphOS http://www.morphos.net port of Free Pascal Compiler was possible, because Genesi S.a.r.l. http://www.genesi.lu provided a free Pegasos II/G4 http://www.pegasosppc.com machine to do the development on.