Here is a sample of a linked function compiled as a code resource:
{$S Wally}
Unit StrayProcedure;
Interface
function Test(t:integer):Integer;
Implementation
Function Test(t:Integer):Integer;
begin
Test:=t*2;
end;
end.
{ This sample unit shows how to use MPW Pascal to create a 68000 function that
can stand alone. This technique can be used to create stand alone procedures
and functions. Here are the commands that you use to compile and link this
unit, as well as a disassembly of the resultant file:
pascal test
link -o steve -rt CODE=2 -sn Wally=Main test.o
dumpcode steve -rt CODE=2
File: steve, Resource 2, Type: CODE, Name: Main
Offset of first jump table entry: $00004E56
Segment is $00000020 bytes long, and uses 0 jump table entries
000000: 302E 0008 '0...' MOVE.W $0008(A6),D0
000004: E340 '.@' ASL.W #$1,D0
000006: 3D40 000A '=@..' MOVE.W D0,$000A(A6)
00000A: 4E5E 'N^' UNLK A6
00000C: 205F ' _' MOVEA.L (A7)+,A0
00000E: 544F 'TO' ADDQ.W #$2,A7
000010: 4ED0 'N.' JMP (A0)
000012: D445 '.E' ADD.W D5,D2
000014: 5354 'ST' SUBQ.W #$1,(A4)
000016: 2020 ' ' MOVE.L -(A0),D0
000018: 2020 ' ' MOVE.L -(A0),D0
00001A: 0000 8000 '....' ORI.B #$00,D0
}