       Title: Kernel Asm Program Format
     Version: 0.52
 Platform(s): TI-89, TI-92+
      Author: PpHd
    Web Site: http://www.timetoteam.fr.st
      E-Mail: ppelissier@hotmail.com, ppelissi@caramail.com
Release Date: 2002/05/28

+-------------------------------+
|	File 68kP / 68kL	|
+-------------------------------+

Label		Offset	Size	Desc
--------------------------------------------------------------------
Origin		$0000	4	Bsr to the loader code
					+ Library : $4E754E75
					+ Program : $61000000 + (stubCode-Origin-2)
Signa		$0004	4	Signature of the Kernel Format	
					+ Library : '68kL'
					+ Program : '68kP'
EFlags		$0008	1	Extra-Flags
					$00 (Always 0)
Reloc		$0009	1	Reloc count
					$00 (Used by the kernel itself)
Comment		$000A	2	offset to _comment
					_comment-Origin or 0 if there is no comment
Main		$000C	2	offset to _main
					_main-Origin or 0 if there is no main function
Exit		$000E	2	offset to _exit
					_exit-Origin or 0 if there is no exit function
Version		$0010	1	Version number
					??	(00 if there is no version number).
Flags		$0011	1	Flags
					bit 0 - runs on 92+ if set
					bit 1 - runs on 89 if set
					bit 2 - Do not redraw the screen after the end of the program if set
					bit 3 - Do not make a copy of the program (If it is archived) : Read only if set
					bit 4 - runs on V200 if set
					bit 5 - runs on Ti-92 if set
HdBss		$0012	2	Handle of BSS block (when program is in use)
					$00
BssOff		$0014	2	offset to BSS table
					_bssTab-Origin or 0 if there is no Bss
ExportOff	$0016	2	offset to export table
					_exportTab-Origin or 0 if there is no exported functions
ExtraRAMOff	$0018	2	offset to Extra RAM table
					_exportTab-Origin or 0 if there is no Extra-RamCalls

++++++++++++++++++++++++++++++++++++++++++++
++++	END OF THE STATIC HEADER	++++
++++++++++++++++++++++++++++++++++++++++++++

ImportTable	$001A		Import table
	NLib 	+ $00	2	Number of used libraries (0 if there is no used libraries).
		+ $02	$A*NLib	Name of the libraries : an array of special string.
			'NLib' times :
				+ 8 chars : Ascii Name of the library
				+ 1 char  : 0 (NULL string)
				+ 1 char  : Minimum version number
		+ $02+$A*NLib
			????	The reloc tables of the libraries
			'NLib' times :
				NFunc	+ 1 word : Number of the used functions in this library minus 1
				'NFunc'+1 times
					A reloc table : a null terminated list of the index from _origin 
						which have to be relocated with this address.

ROMTable	ImportTable_End	Format of ROM Table
		+$00	2	0 if there is no RomCall, otherwise 1.
	NROM	+$02	2	Number of used Rom_Calls minus 1.
			'NROM'+1 times:
				+ 1 word : Number of the used rom call.
				+ A reloc table.
				
RAMTable	ROMTable_End	Format of RAM Table
		+$00	2	0 if there is no RamCall, otherwise 1.
	NRAM	+$02	2	Number of used Ram_Calls minus 1.
			'NRAM'+1 times:
				+ 1 word :
					+ Bit 0-13	: RAM_CALL number or EXTRA_RAMCALL number.
	   				+ Bit 14	: Set if it is an "extra" RAM address.
					+ Bit 15	: Set if reference is word, clear if reference is dword
				+ A reloc table.

RelocTable	RAMTable_End	Format of the relocation table
		+$00	??	A reloc table (That's all) : the address is the origin of the program.
				
BssTable	????		Format of the BSS table.
	BssSize	+$00	4	Size of the BSS bloc to allocate
		+$04	??	A reloc table : the address if the origin of the BSS bloc.
		
ExportTable	????		Format of the exported table 
	ExportNbr +$00	2	Number of exported functions.
		+$02	??	A table of offset to get the function address from origin

Extra RAM address table (Not suported by the linker).
				It is an array of :
					+ 1 word : value for Ti-89
					+ 1 word : value for Ti-92p / Ti-92 / v200

stubCode	????	$A
	+ Normal stub : it is the folowing code :
		move.l	($34).w,-(a7)
		bne.s	\run
		addq.l	#8,a7
	\run	rts
	which corresponds to this hexa chain :
		0x2F,0x38,0x00,0x34,0x66,0x02,0x50,0x8F,0x4E,0x75

	+ MiStub Stub:
		move.l	($34).w,-(a7)
		beq.s	\error
		rts
	error	addq.l	#8,a7
	which corresponds to this hexa chain :
		0x2F,0x38,0x00,0x34,0x67,0x02,0x4E,0x75,0x50,0x8F
		
Program		????		????	The program itself
AMSReloc	EndOfFile-3	2	$0
ASMSigna	EndOfFile-1	1	$F3


+---------------------------------------------------------------+
|	File 68cA (Only supported by Preos at this moment)	|
+---------------------------------------------------------------+
	bsr.s	Loader
	dc.l	'68cA'
Loader	move.l	($50).w,-(a7)
	bne.s	Ok
	addq.l	#8,a7
Ok	rts
	
	dc.b	NumberOfFileInPack
	dc.b	LibraryMinVersion
	dc.b	LibraryFunctionNumber
	
	dc.b	'complib',0	; Name of the decompressing library
	dc.b	'file1',0
	dc.b	'file2',0
	...
	dc.b	'filen',0
	EVEN
Pack	incbin	"pack.bin"
	END

	The first file of an archive pack is an executable.
	You can run it from home or from an explorer just by running the archive.
	The other files can be accessed using kernel::ExtractFile function.
	They can be also libraries.
	
END OF FILE