| MODULE Kernel; (*NW/PR 11.4.86 / 27.12.95 / 4.2.2014*) |
| .MODULE Kernel (KEY 97E012DD, VERSION 1, SIZE 000032C8) |
| .DATA 2034H |
| .FIXUP T 0H |
| IMPORT SYSTEM; |
| CONST SectorLength* = 1024; |
| timer = -64; spiData = -48; spiCtrl = -44; |
| CARD0 = 1; SPIFAST = 4; |
| FSoffset = 80000H; (*256MB in 512-byte blocks*) |
| mapsize = 10000H; (*1K sectors, 64MB*) |
| |
| TYPE Sector* = ARRAY SectorLength OF BYTE; |
| |
| VAR allocated*, NofSectors*: INTEGER; |
| heapOrg*, heapLim*: INTEGER; |
| stackOrg* , stackSize*, MemLim*: INTEGER; |
| clock: INTEGER; |
| list0, list1, list2, list3: INTEGER; (*lists of free blocks of size n*256, 128, 64, 32 bytes*) |
| data: INTEGER; (*SPI data in*) |
| sectorMap: ARRAY mapsize DIV 32 OF SET; |
| |
| (* ---------- New: heap allocation ----------*) |
| |
| PROCEDURE GetBlock(VAR p: LONGINT; len: LONGINT); |
| (*len is multiple of 256*) |
| VAR q0, q1, q2, size: LONGINT; done: BOOLEAN; |
| BEGINa q0 := 0;b q1 := list0;c done := FALSE;d |
0000 | a .PROC 1 |
0000 | a(4EE90020): SUB SP, SP, 20H |
0001 | a .PROC 2 |
0001 | a(AFE00000): STR LNK, SP, 0H |
0002 | a .PROC 3 |
0002 | a(A0E00004): STR R0, SP, 4H |
0003 | a .PROC 4 |
0003 | a(A1E00008): STR R1, SP, 8H |
0004 | b .PROC 5 |
0004 | b(40000000): MOV R0, R0, 0H |
0005 | b .PROC 6 |
0005 | b(A0E0000C): STR R0, SP, CH |
0006 | c .PROC 7 |
0006 | c .FIXUP D |
0006 | c(8D000006): LDR SB, MT, MOD0 [Kernel] |
0007 | c(80D00020): LDR R0, SB, 20H [data] |
0008 | c(A0E00010): STR R0, SP, 10H |
0009 | d(40000000): MOV R0, R0, 0H |
000A | d(B0E0001C): STR R0, SP, 1CH |
| WHILE ~done &e (fq1 # 0)g DOh |
000B | e(90E0001C): LDR R0, SP, 1CH |
000C | f(E9000047): BNE 71 [0054H] |
000D | g(80E00010): LDR R0, SP, 10H |
000E | h(E1000045): BEQ 69 [0054H] |
| SYSTEM.GET(q1, size);i SYSTEM.GET(q1+8,j q2);k |
000F | i(80E00010): LDR R0, SP, 10H |
0010 | i(80000000): LDR R0, R0, 0H |
0011 | i(A0E00018): STR R0, SP, 18H |
0012 | j(80E00010): LDR R0, SP, 10H |
0013 | j(40080008): ADD R0, R0, 8H |
0014 | k(80000000): LDR R0, R0, 0H |
0015 | k(A0E00014): STR R0, SP, 14H |
| IF size < len THENl (*no fit*) q0 := q1;m q1 := q2 |
0016 | l(80E00018): LDR R0, SP, 18H |
0017 | l(81E00008): LDR R1, SP, 8H |
0018 | l(00090001): SUB R0, R0, R1 |
0019 | l(ED000005): BGE 5 [001FH] |
001A | m(80E00010): LDR R0, SP, 10H |
001B | m(A0E0000C): STR R0, SP, CH |
| ELSIFn sizeo = len THENp (*extract -> p*) |
001C | n(80E00014): LDR R0, SP, 14H |
001D | n(A0E00010): STR R0, SP, 10H |
001E | o(E7000034): B 52 [0053H] |
001F | p(80E00018): LDR R0, SP, 18H |
0020 | p(81E00008): LDR R1, SP, 8H |
0021 | p(00090001): SUB R0, R0, R1 |
0022 | p(E9000010): BNE 16 [0033H] |
| done := TRUE;q p := q1;r |
0023 | q(40000001): MOV R0, R0, 1H |
0024 | q(B0E0001C): STR R0, SP, 1CH |
0025 | r(80E00010): LDR R0, SP, 10H |
0026 | r(81E00004): LDR R1, SP, 4H |
0027 | r(A0100000): STR R0, R1, 0H |
| IF q0 # 0 THENs SYSTEM.PUT(q0+8,t q2) ELSEu list0v := q2 ENDw |
0028 | s(80E0000C): LDR R0, SP, CH |
0029 | s(E1000005): BEQ 5 [002FH] |
002A | t(80E0000C): LDR R0, SP, CH |
002B | t(40080008): ADD R0, R0, 8H |
002C | u(81E00014): LDR R1, SP, 14H |
002D | u(A1000000): STR R1, R0, 0H |
002E | v(E7000003): B 3 [0032H] |
002F | w(80E00014): LDR R0, SP, 14H |
0030 | w .FIXUP D |
0030 | w(8D00002A): LDR SB, MT, MOD0 [Kernel] |
0031 | w(A0D00020): STR R0, SB, 20H [data] |
| ELSE (*reduce size*) |
| donex := TRUE;y p := q1;z q1 := q1 + len;a |
0032 | x(E7000020): B 32 [0053H] |
0033 | y(40000001): MOV R0, R0, 1H |
0034 | y(B0E0001C): STR R0, SP, 1CH |
0035 | z(80E00010): LDR R0, SP, 10H |
0036 | z(81E00004): LDR R1, SP, 4H |
0037 | z(A0100000): STR R0, R1, 0H |
0038 | a(80E00010): LDR R0, SP, 10H |
0039 | a(81E00008): LDR R1, SP, 8H |
003A | a(00080001): ADD R0, R0, R1 |
003B | a(A0E00010): STR R0, SP, 10H |
| SYSTEM.PUT(q1, size-len)b;c SYSTEM.PUT(q1+4,d -1);e SYSTEM.PUT(q1+8,f q2);g |
003C | b(80E00018): LDR R0, SP, 18H |
003D | b(81E00008): LDR R1, SP, 8H |
003E | b(00090001): SUB R0, R0, R1 |
003F | c(81E00010): LDR R1, SP, 10H |
0040 | c(A0100000): STR R0, R1, 0H |
0041 | d(80E00010): LDR R0, SP, 10H |
0042 | d(40080004): ADD R0, R0, 4H |
0043 | e(5100FFFF): MOV R1, R0, FFFFFFFFH |
0044 | e(A1000000): STR R1, R0, 0H |
0045 | f(80E00010): LDR R0, SP, 10H |
0046 | f(40080008): ADD R0, R0, 8H |
0047 | g(81E00014): LDR R1, SP, 14H |
0048 | g(A1000000): STR R1, R0, 0H |
| IF q0 # 0 THENh SYSTEM.PUT(q0+8,i q1) ELSEj list0k := q1 ENDl |
0049 | h(80E0000C): LDR R0, SP, CH |
004A | h(E1000005): BEQ 5 [0050H] |
004B | i(80E0000C): LDR R0, SP, CH |
004C | i(40080008): ADD R0, R0, 8H |
004D | j(81E00010): LDR R1, SP, 10H |
004E | j(A1000000): STR R1, R0, 0H |
004F | k(E7000003): B 3 [0053H] |
0050 | l(80E00010): LDR R0, SP, 10H |
0051 | l .FIXUP D |
0051 | l(8D000021): LDR SB, MT, MOD0 [Kernel] |
0052 | l(A0D00020): STR R0, SB, 20H [data] |
| END |
| ENDm ; |
0053 | m(E7FFFFB7): B -73 [000BH] |
| IF ~done THENn p := 0 ENDo |
0054 | n(90E0001C): LDR R0, SP, 1CH |
0055 | n(E9000003): BNE 3 [0059H] |
0056 | o(40000000): MOV R0, R0, 0H |
0057 | o(81E00004): LDR R1, SP, 4H |
0058 | o(A0100000): STR R0, R1, 0H |
| ENDp GetBlock; |
0059 | p(8FE00000): LDR LNK, SP, 0H |
005A | p(4EE80020): ADD SP, SP, 20H |
005B | p(C700000F): B LNK |
| |
| PROCEDURE GetBlock128(VAR p: LONGINT); |
| VAR q: LONGINT; |
| BEGINq |
005C | q(4EE9000C): SUB SP, SP, CH |
005D | q(AFE00000): STR LNK, SP, 0H |
005E | q(A0E00004): STR R0, SP, 4H |
| IF list1 # 0 THENr p := list1;s SYSTEM.GET(list1+8,t list1) |
005F | r .FIXUP D |
005F | r(8D00000E): LDR SB, MT, MOD0 [Kernel] |
0060 | r(80D00024): LDR R0, SB, 24H [data] |
0061 | r(E1000009): BEQ 9 [006BH] |
0062 | s .FIXUP D |
0062 | s(8D000003): LDR SB, MT, MOD0 [Kernel] |
0063 | s(80D00024): LDR R0, SB, 24H [data] |
0064 | s(81E00004): LDR R1, SP, 4H |
0065 | s(A0100000): STR R0, R1, 0H |
0066 | t(80D00024): LDR R0, SB, 24H |
0067 | t(40080008): ADD R0, R0, 8H |
| ELSEu GetBlockv(q,w 256)x;y SYSTEM.PUT(q+128,z 128);a SYSTEM.PUT(q+132,b -1);c SYSTEM.PUT(q+136,d list1);e |
0068 | u(80000000): LDR R0, R0, 0H |
0069 | u(A0D00024): STR R0, SB, 24H |
006A | v(E7000016): B 22 [0081H] |
006B | w(40E80008): ADD R0, SP, 8H |
006C | x(41000100): MOV R1, R0, 100H |
006D | y(F7FFFF92): BL -110 [0000H] |
006E | z(80E00008): LDR R0, SP, 8H |
006F | z(40080080): ADD R0, R0, 80H |
0070 | a(41000080): MOV R1, R0, 80H |
0071 | a(A1000000): STR R1, R0, 0H |
0072 | b(80E00008): LDR R0, SP, 8H |
0073 | b(40080084): ADD R0, R0, 84H |
0074 | c(5100FFFF): MOV R1, R0, FFFFFFFFH |
0075 | c(A1000000): STR R1, R0, 0H |
0076 | d(80E00008): LDR R0, SP, 8H |
0077 | d(40080088): ADD R0, R0, 88H |
0078 | e .FIXUP D |
0078 | e(8D000016): LDR SB, MT, MOD0 [Kernel] |
0079 | e(81D00024): LDR R1, SB, 24H [data] |
007A | e(A1000000): STR R1, R0, 0H |
| list1 := q + 128;f p := q |
007B | f(80E00008): LDR R0, SP, 8H |
007C | f(40080080): ADD R0, R0, 80H |
007D | f(A0D00024): STR R0, SB, 24H |
| ENDg |
007E | g(80E00008): LDR R0, SP, 8H |
007F | g(81E00004): LDR R1, SP, 4H |
0080 | g(A0100000): STR R0, R1, 0H |
| ENDh GetBlock128; |
0081 | h(8FE00000): LDR LNK, SP, 0H |
0082 | h(4EE8000C): ADD SP, SP, CH |
0083 | h(C700000F): B LNK |
| |
| PROCEDURE GetBlock64(VAR p: LONGINT); |
| VAR q: LONGINT; |
| BEGINi |
0084 | i(4EE9000C): SUB SP, SP, CH |
0085 | i(AFE00000): STR LNK, SP, 0H |
0086 | i(A0E00004): STR R0, SP, 4H |
| IF list2 # 0 THENj p := list2;k SYSTEM.GET(list2+8,l list2) |
0087 | j .FIXUP D |
0087 | j(8D00000F): LDR SB, MT, MOD0 [Kernel] |
0088 | j(80D00028): LDR R0, SB, 28H [data] |
0089 | j(E1000009): BEQ 9 [0093H] |
008A | k .FIXUP D |
008A | k(8D000003): LDR SB, MT, MOD0 [Kernel] |
008B | k(80D00028): LDR R0, SB, 28H [data] |
008C | k(81E00004): LDR R1, SP, 4H |
008D | k(A0100000): STR R0, R1, 0H |
008E | l(80D00028): LDR R0, SB, 28H |
008F | l(40080008): ADD R0, R0, 8H |
| ELSEm GetBlock128n(q)o;p SYSTEM.PUT(q+64,q 64);r SYSTEM.PUT(q+68,s -1);t SYSTEM.PUT(q+72,u list2);v |
0090 | m(80000000): LDR R0, R0, 0H |
0091 | m(A0D00028): STR R0, SB, 28H |
0092 | n(E7000015): B 21 [00A8H] |
0093 | o(40E80008): ADD R0, SP, 8H |
0094 | p(F7FFFFC7): BL -57 [005CH] |
0095 | q(80E00008): LDR R0, SP, 8H |
0096 | q(40080040): ADD R0, R0, 40H |
0097 | r(41000040): MOV R1, R0, 40H |
0098 | r(A1000000): STR R1, R0, 0H |
0099 | s(80E00008): LDR R0, SP, 8H |
009A | s(40080044): ADD R0, R0, 44H |
009B | t(5100FFFF): MOV R1, R0, FFFFFFFFH |
009C | t(A1000000): STR R1, R0, 0H |
009D | u(80E00008): LDR R0, SP, 8H |
009E | u(40080048): ADD R0, R0, 48H |
009F | v .FIXUP D |
009F | v(8D000015): LDR SB, MT, MOD0 [Kernel] |
00A0 | v(81D00028): LDR R1, SB, 28H [data] |
00A1 | v(A1000000): STR R1, R0, 0H |
| list2 := q + 64;w p := q |
00A2 | w(80E00008): LDR R0, SP, 8H |
00A3 | w(40080040): ADD R0, R0, 40H |
00A4 | w(A0D00028): STR R0, SB, 28H |
| ENDx |
00A5 | x(80E00008): LDR R0, SP, 8H |
00A6 | x(81E00004): LDR R1, SP, 4H |
00A7 | x(A0100000): STR R0, R1, 0H |
| ENDy GetBlock64; |
00A8 | y(8FE00000): LDR LNK, SP, 0H |
00A9 | y(4EE8000C): ADD SP, SP, CH |
00AA | y(C700000F): B LNK |
| |
| PROCEDURE GetBlock32(VAR p: LONGINT); |
| VAR q: LONGINT; |
| BEGINz |
00AB | z(4EE9000C): SUB SP, SP, CH |
00AC | z(AFE00000): STR LNK, SP, 0H |
00AD | z(A0E00004): STR R0, SP, 4H |
| IF list3 # 0 THENa p := list3;b SYSTEM.GET(list3+8,c list3) |
00AE | a .FIXUP D |
00AE | a(8D00000F): LDR SB, MT, MOD0 [Kernel] |
00AF | a(80D0002C): LDR R0, SB, 2CH [data] |
00B0 | a(E1000009): BEQ 9 [00BAH] |
00B1 | b .FIXUP D |
00B1 | b(8D000003): LDR SB, MT, MOD0 [Kernel] |
00B2 | b(80D0002C): LDR R0, SB, 2CH [data] |
00B3 | b(81E00004): LDR R1, SP, 4H |
00B4 | b(A0100000): STR R0, R1, 0H |
00B5 | c(80D0002C): LDR R0, SB, 2CH |
00B6 | c(40080008): ADD R0, R0, 8H |
| ELSEd GetBlock64e(q)f;g SYSTEM.PUT(q+32,h 32);i SYSTEM.PUT(q+36,j -1);k SYSTEM.PUT(q+40,l list3);m |
00B7 | d(80000000): LDR R0, R0, 0H |
00B8 | d(A0D0002C): STR R0, SB, 2CH |
00B9 | e(E7000015): B 21 [00CFH] |
00BA | f(40E80008): ADD R0, SP, 8H |
00BB | g(F7FFFFC8): BL -56 [0084H] |
00BC | h(80E00008): LDR R0, SP, 8H |
00BD | h(40080020): ADD R0, R0, 20H |
00BE | i(41000020): MOV R1, R0, 20H |
00BF | i(A1000000): STR R1, R0, 0H |
00C0 | j(80E00008): LDR R0, SP, 8H |
00C1 | j(40080024): ADD R0, R0, 24H |
00C2 | k(5100FFFF): MOV R1, R0, FFFFFFFFH |
00C3 | k(A1000000): STR R1, R0, 0H |
00C4 | l(80E00008): LDR R0, SP, 8H |
00C5 | l(40080028): ADD R0, R0, 28H |
00C6 | m .FIXUP D |
00C6 | m(8D000015): LDR SB, MT, MOD0 [Kernel] |
00C7 | m(81D0002C): LDR R1, SB, 2CH [data] |
00C8 | m(A1000000): STR R1, R0, 0H |
| list3 := q + 32;n p := q |
00C9 | n(80E00008): LDR R0, SP, 8H |
00CA | n(40080020): ADD R0, R0, 20H |
00CB | n(A0D0002C): STR R0, SB, 2CH |
| ENDo |
00CC | o(80E00008): LDR R0, SP, 8H |
00CD | o(81E00004): LDR R1, SP, 4H |
00CE | o(A0100000): STR R0, R1, 0H |
| ENDp GetBlock32; |
00CF | p(8FE00000): LDR LNK, SP, 0H |
00D0 | p(4EE8000C): ADD SP, SP, CH |
00D1 | p(C700000F): B LNK |
| |
| PROCEDURE New*(VAR ptr: LONGINT; tag: LONGINT); |
| (*called by NEW via MT[0]; ptr and tag are pointers*) |
| VAR p, size, lim: LONGINT; |
| BEGINq SYSTEM.GET(tag, size);r |
00D2 | q .PROC 8 |
00D2 | q(4EE90018): SUB SP, SP, 18H |
00D3 | q(AFE00000): STR LNK, SP, 0H |
00D4 | q(A0E00004): STR R0, SP, 4H |
00D5 | q(A1E00008): STR R1, SP, 8H |
00D6 | r(80E00008): LDR R0, SP, 8H |
00D7 | r(80000000): LDR R0, R0, 0H |
00D8 | r(A0E00010): STR R0, SP, 10H |
| IF size = 32 THENs GetBlock32(p)t |
00D9 | s(80E00010): LDR R0, SP, 10H |
00DA | s(40090020): SUB R0, R0, 20H |
00DB | s(E9000003): BNE 3 [00DFH] |
00DC | t(40E8000C): ADD R0, SP, CH |
| ELSIFu sizev = 64 THENw GetBlock64(p)x |
00DD | u(F7FFFFCD): BL -51 [00ABH] |
00DE | v(E7000012): B 18 [00F1H] |
00DF | w(80E00010): LDR R0, SP, 10H |
00E0 | w(40090040): SUB R0, R0, 40H |
00E1 | w(E9000003): BNE 3 [00E5H] |
00E2 | x(40E8000C): ADD R0, SP, CH |
| ELSIFy sizez = 128 THENa GetBlock128(p)b |
00E3 | y(F7FFFFA0): BL -96 [0084H] |
00E4 | z(E700000C): B 12 [00F1H] |
00E5 | a(80E00010): LDR R0, SP, 10H |
00E6 | a(40090080): SUB R0, R0, 80H |
00E7 | a(E9000003): BNE 3 [00EBH] |
00E8 | b(40E8000C): ADD R0, SP, CH |
| ELSEc GetBlockd(p,e (size+255)f DIV 256 *g 256)h |
00E9 | c(F7FFFF72): BL -142 [005CH] |
00EA | d(E7000006): B 6 [00F1H] |
00EB | e(40E8000C): ADD R0, SP, CH |
00EC | f(81E00010): LDR R1, SP, 10H |
00ED | f(411800FF): ADD R1, R1, FFH |
00EE | g(41120008): ASR R1, R1, 8H |
00EF | h(41110008): LSL R1, R1, 8H |
| ENDi ; |
00F0 | i(F7FFFF0F): BL -241 [0000H] |
| IF p = 0 THENj ptr := 0 |
00F1 | j(80E0000C): LDR R0, SP, CH |
00F2 | j(E9000004): BNE 4 [00F7H] |
| ELSEk ptrl := p+8;m SYSTEM.PUT(p, tag);n lim := p + size;o INC(p, 4);p INC(allocated, size);q |
00F3 | k(40000000): MOV R0, R0, 0H |
00F4 | k(81E00004): LDR R1, SP, 4H |
00F5 | k(A0100000): STR R0, R1, 0H |
00F6 | l(E700001F): B 31 [0116H] |
00F7 | m(80E0000C): LDR R0, SP, CH |
00F8 | m(40080008): ADD R0, R0, 8H |
00F9 | m(81E00004): LDR R1, SP, 4H |
00FA | m(A0100000): STR R0, R1, 0H |
00FB | n(80E0000C): LDR R0, SP, CH |
00FC | n(81E00008): LDR R1, SP, 8H |
00FD | n(A1000000): STR R1, R0, 0H |
00FE | o(80E0000C): LDR R0, SP, CH |
00FF | o(81E00010): LDR R1, SP, 10H |
0100 | o(00080001): ADD R0, R0, R1 |
0101 | o(A0E00014): STR R0, SP, 14H |
0102 | p(80E0000C): LDR R0, SP, CH |
0103 | p(40080004): ADD R0, R0, 4H |
0104 | p(A0E0000C): STR R0, SP, CH |
0105 | q .FIXUP D |
0105 | q(8D00003F): LDR SB, MT, MOD0 [Kernel] |
0106 | q(40D80000): ADD R0, SB, 0H [data] |
0107 | q(81000000): LDR R1, R0, 0H |
0108 | q(82E00010): LDR R2, SP, 10H |
0109 | q(01180002): ADD R1, R1, R2 |
010A | q(A1000000): STR R1, R0, 0H |
| WHILE p < lim DOr SYSTEM.PUT(p, 0);s INC(p, 4) ENDt |
010B | r(80E0000C): LDR R0, SP, CH |
010C | r(81E00014): LDR R1, SP, 14H |
010D | r(00090001): SUB R0, R0, R1 |
010E | r(ED000007): BGE 7 [0116H] |
010F | s(80E0000C): LDR R0, SP, CH |
0110 | s(41000000): MOV R1, R0, 0H |
0111 | s(A1000000): STR R1, R0, 0H |
0112 | t(80E0000C): LDR R0, SP, CH |
0113 | t(40080004): ADD R0, R0, 4H |
0114 | t(A0E0000C): STR R0, SP, CH |
0115 | t(E7FFFFF5): B -11 [010BH] |
| END |
| ENDu New; |
0116 | u(8FE00000): LDR LNK, SP, 0H |
0117 | u(4EE80018): ADD SP, SP, 18H |
0118 | u(C700000F): B LNK |
| |
| (* ---------- Garbage collector ----------*) |
| |
| PROCEDURE Mark*(pref: LONGINT); |
| VAR pvadr, offadr, offset, tag, p, q, r: LONGINT; |
| BEGINv SYSTEM.GET(pref, pvadr);w (*pointers < heapOrg considered NIL*) |
0119 | v .PROC 9 |
0119 | v(4EE90024): SUB SP, SP, 24H |
011A | v(AFE00000): STR LNK, SP, 0H |
011B | v(A0E00004): STR R0, SP, 4H |
011C | w(80E00004): LDR R0, SP, 4H |
011D | w(80000000): LDR R0, R0, 0H |
011E | w(A0E00008): STR R0, SP, 8H |
| WHILE pvadr # 0 DOx |
011F | x(80E00008): LDR R0, SP, 8H |
0120 | x(E100006C): BEQ 108 [018DH] |
| SYSTEM.GET(pvadr, p);y SYSTEM.GET(p-4,z offadr);a |
0121 | y(80E00008): LDR R0, SP, 8H |
0122 | y(80000000): LDR R0, R0, 0H |
0123 | y(A0E00018): STR R0, SP, 18H |
0124 | z(80E00018): LDR R0, SP, 18H |
0125 | z(40090004): SUB R0, R0, 4H |
0126 | a(80000000): LDR R0, R0, 0H |
0127 | a(A0E0000C): STR R0, SP, CH |
| IF (p >= heapOrg)b & (coffadr = 0)d THENe q := p;f (*mark elements in data structure with root p*) |
0128 | b(80E00018): LDR R0, SP, 18H |
0129 | b .FIXUP D |
0129 | b(8D000024): LDR SB, MT, MOD0 [Kernel] |
012A | b(81D00008): LDR R1, SB, 8H [data] |
012B | b(00090001): SUB R0, R0, R1 |
012C | c(E5000059): BLT 89 [0186H] |
012D | d(80E0000C): LDR R0, SP, CH |
012E | e(E9000057): BNE 87 [0186H] |
012F | f(80E00018): LDR R0, SP, 18H |
0130 | f(A0E0001C): STR R0, SP, 1CH |
| REPEAT SYSTEM.GET(p-4,g offadr);h |
0131 | g(80E00018): LDR R0, SP, 18H |
0132 | g(40090004): SUB R0, R0, 4H |
0133 | h(80000000): LDR R0, R0, 0H |
0134 | h(A0E0000C): STR R0, SP, CH |
| IF offadr = 0 THENi SYSTEM.GET(p-8,j tag);k offadr := tag + 16 ELSEl INCm(offadr, 4) ENDn ; |
0135 | i(80E0000C): LDR R0, SP, CH |
0136 | i(E9000008): BNE 8 [013FH] |
0137 | j(80E00018): LDR R0, SP, 18H |
0138 | j(40090008): SUB R0, R0, 8H |
0139 | k(80000000): LDR R0, R0, 0H |
013A | k(A0E00014): STR R0, SP, 14H |
013B | l(80E00014): LDR R0, SP, 14H |
013C | l(40080010): ADD R0, R0, 10H |
013D | l(A0E0000C): STR R0, SP, CH |
013E | m(E7000003): B 3 [0142H] |
013F | n(80E0000C): LDR R0, SP, CH |
0140 | n(40080004): ADD R0, R0, 4H |
0141 | n(A0E0000C): STR R0, SP, CH |
| SYSTEM.PUT(p-4,o offadr);p SYSTEM.GET(offadr, offset);q |
0142 | o(80E00018): LDR R0, SP, 18H |
0143 | o(40090004): SUB R0, R0, 4H |
0144 | p(81E0000C): LDR R1, SP, CH |
0145 | p(A1000000): STR R1, R0, 0H |
0146 | q(80E0000C): LDR R0, SP, CH |
0147 | q(80000000): LDR R0, R0, 0H |
0148 | q(A0E00010): STR R0, SP, 10H |
| IF offset # -1 THENr (*down*) |
0149 | r(80E00010): LDR R0, SP, 10H |
014A | r(5009FFFF): SUB R0, R0, FFFFFFFFH |
014B | r(E100001A): BEQ 26 [0166H] |
| SYSTEM.GET(p+offset,s r);t SYSTEM.GET(r-4,u offadr);v |
014C | s(80E00018): LDR R0, SP, 18H |
014D | s(81E00010): LDR R1, SP, 10H |
014E | s(00080001): ADD R0, R0, R1 |
014F | t(80000000): LDR R0, R0, 0H |
0150 | t(A0E00020): STR R0, SP, 20H |
0151 | u(80E00020): LDR R0, SP, 20H |
0152 | u(40090004): SUB R0, R0, 4H |
0153 | v(80000000): LDR R0, R0, 0H |
0154 | v(A0E0000C): STR R0, SP, CH |
| IF (r >= heapOrg)w & (xoffadr = 0)y THENz SYSTEM.PUT(p+offset,a q);b q := p;c p := r ENDd |
0155 | w(80E00020): LDR R0, SP, 20H |
0156 | w .FIXUP D |
0156 | w(8D00002D): LDR SB, MT, MOD0 [Kernel] |
0157 | w(81D00008): LDR R1, SB, 8H [data] |
0158 | w(00090001): SUB R0, R0, R1 |
0159 | x(E500000B): BLT 11 [0165H] |
015A | y(80E0000C): LDR R0, SP, CH |
015B | z(E9000009): BNE 9 [0165H] |
015C | a(80E00018): LDR R0, SP, 18H |
015D | a(81E00010): LDR R1, SP, 10H |
015E | a(00080001): ADD R0, R0, R1 |
015F | b(81E0001C): LDR R1, SP, 1CH |
0160 | b(A1000000): STR R1, R0, 0H |
0161 | c(80E00018): LDR R0, SP, 18H |
0162 | c(A0E0001C): STR R0, SP, 1CH |
0163 | d(80E00020): LDR R0, SP, 20H |
0164 | d(A0E00018): STR R0, SP, 18H |
| ELSE (*up*) SYSTEMe.GET(q-4,f offadr);g SYSTEM.GET(offadr, offset);h |
0165 | e(E7000019): B 25 [017FH] |
0166 | f(80E0001C): LDR R0, SP, 1CH |
0167 | f(40090004): SUB R0, R0, 4H |
0168 | g(80000000): LDR R0, R0, 0H |
0169 | g(A0E0000C): STR R0, SP, CH |
016A | h(80E0000C): LDR R0, SP, CH |
016B | h(80000000): LDR R0, R0, 0H |
016C | h(A0E00010): STR R0, SP, 10H |
| IF p # q THENi SYSTEM.GET(q+offset,j r);k SYSTEM.PUT(q+offset,l p);m p := q;n q := r ENDo |
016D | i(80E00018): LDR R0, SP, 18H |
016E | i(81E0001C): LDR R1, SP, 1CH |
016F | i(00090001): SUB R0, R0, R1 |
0170 | i(E100000E): BEQ 14 [017FH] |
0171 | j(80E0001C): LDR R0, SP, 1CH |
0172 | j(81E00010): LDR R1, SP, 10H |
0173 | j(00080001): ADD R0, R0, R1 |
0174 | k(80000000): LDR R0, R0, 0H |
0175 | k(A0E00020): STR R0, SP, 20H |
0176 | l(80E0001C): LDR R0, SP, 1CH |
0177 | l(81E00010): LDR R1, SP, 10H |
0178 | l(00080001): ADD R0, R0, R1 |
0179 | m(81E00018): LDR R1, SP, 18H |
017A | m(A1000000): STR R1, R0, 0H |
017B | n(80E0001C): LDR R0, SP, 1CH |
017C | n(A0E00018): STR R0, SP, 18H |
017D | o(80E00020): LDR R0, SP, 20H |
017E | o(A0E0001C): STR R0, SP, 1CH |
| END |
| UNTIL (p = q)p & (qoffset = -1)r |
017F | p(80E00018): LDR R0, SP, 18H |
0180 | p(81E0001C): LDR R1, SP, 1CH |
0181 | p(00090001): SUB R0, R0, R1 |
0182 | q(E9FFFFAE): BNE -82 [0131H] |
0183 | r(80E00010): LDR R0, SP, 10H |
0184 | r(5009FFFF): SUB R0, R0, FFFFFFFFH |
| ENDs ; |
0185 | s(E9FFFFAB): BNE -85 [0131H] |
| INC(pref, 4);t SYSTEM.GET(pref, pvadr) |
0186 | t(80E00004): LDR R0, SP, 4H |
0187 | t(40080004): ADD R0, R0, 4H |
0188 | t(A0E00004): STR R0, SP, 4H |
| ENDu |
0189 | u(80E00004): LDR R0, SP, 4H |
018A | u(80000000): LDR R0, R0, 0H |
018B | u(A0E00008): STR R0, SP, 8H |
018C | u(E7FFFF92): B -110 [011FH] |
| ENDv Mark; |
018D | v(8FE00000): LDR LNK, SP, 0H |
018E | v(4EE80024): ADD SP, SP, 24H |
018F | v(C700000F): B LNK |
| |
| PROCEDURE Scan*; |
| VAR p, q, mark, tag, size: LONGINT; |
| BEGINw p := heapOrg;x |
0190 | w .PROC 10 |
0190 | w .COMMAND Scan |
0190 | w(4EE90018): SUB SP, SP, 18H |
0191 | w(AFE00000): STR LNK, SP, 0H |
0192 | x .FIXUP D |
0192 | x(8D00003C): LDR SB, MT, MOD0 [Kernel] |
0193 | x(80D00008): LDR R0, SB, 8H [data] |
0194 | x(A0E00004): STR R0, SP, 4H |
| REPEAT SYSTEM.GET(p+4,y mark);z q := p;a |
0195 | y(80E00004): LDR R0, SP, 4H |
0196 | y(40080004): ADD R0, R0, 4H |
0197 | z(80000000): LDR R0, R0, 0H |
0198 | z(A0E0000C): STR R0, SP, CH |
0199 | a(80E00004): LDR R0, SP, 4H |
019A | a(A0E00008): STR R0, SP, 8H |
| WHILE mark = 0 DOb |
019B | b(80E0000C): LDR R0, SP, CH |
019C | b(E900000F): BNE 15 [01ACH] |
| SYSTEM.GET(p, tag);c SYSTEM.GET(tag, size);d INC(p, size);e SYSTEM.GET(p+4,f mark) |
019D | c(80E00004): LDR R0, SP, 4H |
019E | c(80000000): LDR R0, R0, 0H |
019F | c(A0E00010): STR R0, SP, 10H |
01A0 | d(80E00010): LDR R0, SP, 10H |
01A1 | d(80000000): LDR R0, R0, 0H |
01A2 | d(A0E00014): STR R0, SP, 14H |
01A3 | e(80E00004): LDR R0, SP, 4H |
01A4 | e(81E00014): LDR R1, SP, 14H |
01A5 | e(00080001): ADD R0, R0, R1 |
01A6 | e(A0E00004): STR R0, SP, 4H |
01A7 | f(80E00004): LDR R0, SP, 4H |
01A8 | f(40080004): ADD R0, R0, 4H |
| ENDg ; |
01A9 | g(80000000): LDR R0, R0, 0H |
01AA | g(A0E0000C): STR R0, SP, CH |
01AB | g(E7FFFFEF): B -17 [019BH] |
| size := p - q;h DEC(allocated, size);i (*size of free block*) |
01AC | h(80E00004): LDR R0, SP, 4H |
01AD | h(81E00008): LDR R1, SP, 8H |
01AE | h(00090001): SUB R0, R0, R1 |
01AF | h(A0E00014): STR R0, SP, 14H |
01B0 | i .FIXUP D |
01B0 | i(8D00001E): LDR SB, MT, MOD0 [Kernel] |
01B1 | i(40D80000): ADD R0, SB, 0H [data] |
01B2 | i(81000000): LDR R1, R0, 0H |
01B3 | i(82E00014): LDR R2, SP, 14H |
01B4 | i(01190002): SUB R1, R1, R2 |
01B5 | i(A1000000): STR R1, R0, 0H |
| IF size > 0 THENj |
01B6 | j(80E00014): LDR R0, SP, 14H |
01B7 | j(40090000): SUB R0, R0, 0H |
01B8 | j(E600005D): BLE 93 [0216H] |
| IF size MOD 64 #k 0 THENl |
01B9 | k(80E00014): LDR R0, SP, 14H |
01BA | k(4004003F): AND R0, R0, 3FH |
01BB | l(40090000): SUB R0, R0, 0H |
01BC | l(E1000014): BEQ 20 [01D1H] |
| SYSTEM.PUT(q, 32);m SYSTEM.PUT(q+4,n -1);o SYSTEM.PUT(q+8,p list3);q list3 := q;r INC(q, 32);s DEC(size, 32) |
01BD | m(80E00008): LDR R0, SP, 8H |
01BE | m(41000020): MOV R1, R0, 20H |
01BF | m(A1000000): STR R1, R0, 0H |
01C0 | n(80E00008): LDR R0, SP, 8H |
01C1 | n(40080004): ADD R0, R0, 4H |
01C2 | o(5100FFFF): MOV R1, R0, FFFFFFFFH |
01C3 | o(A1000000): STR R1, R0, 0H |
01C4 | p(80E00008): LDR R0, SP, 8H |
01C5 | p(40080008): ADD R0, R0, 8H |
01C6 | q .FIXUP D |
01C6 | q(8D000016): LDR SB, MT, MOD0 [Kernel] |
01C7 | q(81D0002C): LDR R1, SB, 2CH [data] |
01C8 | q(A1000000): STR R1, R0, 0H |
01C9 | r(80E00008): LDR R0, SP, 8H |
01CA | r(A0D0002C): STR R0, SB, 2CH |
01CB | s(80E00008): LDR R0, SP, 8H |
01CC | s(40080020): ADD R0, R0, 20H |
01CD | s(A0E00008): STR R0, SP, 8H |
| ENDt ; |
01CE | t(80E00014): LDR R0, SP, 14H |
01CF | t(40090020): SUB R0, R0, 20H |
01D0 | t(A0E00014): STR R0, SP, 14H |
| IF size MOD 128 #u 0 THENv |
01D1 | u(80E00014): LDR R0, SP, 14H |
01D2 | u(4004007F): AND R0, R0, 7FH |
01D3 | v(40090000): SUB R0, R0, 0H |
01D4 | v(E1000014): BEQ 20 [01E9H] |
| SYSTEM.PUT(q, 64);w SYSTEM.PUT(q+4,x -1);y SYSTEM.PUT(q+8,z list2);a list2 := q;b INC(q, 64);c DEC(size, 64) |
01D5 | w(80E00008): LDR R0, SP, 8H |
01D6 | w(41000040): MOV R1, R0, 40H |
01D7 | w(A1000000): STR R1, R0, 0H |
01D8 | x(80E00008): LDR R0, SP, 8H |
01D9 | x(40080004): ADD R0, R0, 4H |
01DA | y(5100FFFF): MOV R1, R0, FFFFFFFFH |
01DB | y(A1000000): STR R1, R0, 0H |
01DC | z(80E00008): LDR R0, SP, 8H |
01DD | z(40080008): ADD R0, R0, 8H |
01DE | a .FIXUP D |
01DE | a(8D000018): LDR SB, MT, MOD0 [Kernel] |
01DF | a(81D00028): LDR R1, SB, 28H [data] |
01E0 | a(A1000000): STR R1, R0, 0H |
01E1 | b(80E00008): LDR R0, SP, 8H |
01E2 | b(A0D00028): STR R0, SB, 28H |
01E3 | c(80E00008): LDR R0, SP, 8H |
01E4 | c(40080040): ADD R0, R0, 40H |
01E5 | c(A0E00008): STR R0, SP, 8H |
| ENDd ; |
01E6 | d(80E00014): LDR R0, SP, 14H |
01E7 | d(40090040): SUB R0, R0, 40H |
01E8 | d(A0E00014): STR R0, SP, 14H |
| IF size MOD 256 #e 0 THENf |
01E9 | e(80E00014): LDR R0, SP, 14H |
01EA | e(400400FF): AND R0, R0, FFH |
01EB | f(40090000): SUB R0, R0, 0H |
01EC | f(E1000014): BEQ 20 [0201H] |
| SYSTEM.PUT(q, 128);g SYSTEM.PUT(q+4,h -1);i SYSTEM.PUT(q+8,j list1);k list1 := q;l INC(q, 128);m DEC(size, 128) |
01ED | g(80E00008): LDR R0, SP, 8H |
01EE | g(41000080): MOV R1, R0, 80H |
01EF | g(A1000000): STR R1, R0, 0H |
01F0 | h(80E00008): LDR R0, SP, 8H |
01F1 | h(40080004): ADD R0, R0, 4H |
01F2 | i(5100FFFF): MOV R1, R0, FFFFFFFFH |
01F3 | i(A1000000): STR R1, R0, 0H |
01F4 | j(80E00008): LDR R0, SP, 8H |
01F5 | j(40080008): ADD R0, R0, 8H |
01F6 | k .FIXUP D |
01F6 | k(8D000018): LDR SB, MT, MOD0 [Kernel] |
01F7 | k(81D00024): LDR R1, SB, 24H [data] |
01F8 | k(A1000000): STR R1, R0, 0H |
01F9 | l(80E00008): LDR R0, SP, 8H |
01FA | l(A0D00024): STR R0, SB, 24H |
01FB | m(80E00008): LDR R0, SP, 8H |
01FC | m(40080080): ADD R0, R0, 80H |
01FD | m(A0E00008): STR R0, SP, 8H |
| ENDn ; |
01FE | n(80E00014): LDR R0, SP, 14H |
01FF | n(40090080): SUB R0, R0, 80H |
0200 | n(A0E00014): STR R0, SP, 14H |
| IF size > 0 THENo |
0201 | o(80E00014): LDR R0, SP, 14H |
0202 | o(40090000): SUB R0, R0, 0H |
0203 | o(E6000012): BLE 18 [0216H] |
| SYSTEM.PUT(q, size);p SYSTEM.PUT(q+4,q -1);r SYSTEM.PUT(q+8,s list0);t list0 := q;u INC(q, size) |
0204 | p(80E00008): LDR R0, SP, 8H |
0205 | p(81E00014): LDR R1, SP, 14H |
0206 | p(A1000000): STR R1, R0, 0H |
0207 | q(80E00008): LDR R0, SP, 8H |
0208 | q(40080004): ADD R0, R0, 4H |
0209 | r(5100FFFF): MOV R1, R0, FFFFFFFFH |
020A | r(A1000000): STR R1, R0, 0H |
020B | s(80E00008): LDR R0, SP, 8H |
020C | s(40080008): ADD R0, R0, 8H |
020D | t .FIXUP D |
020D | t(8D000017): LDR SB, MT, MOD0 [Kernel] |
020E | t(81D00020): LDR R1, SB, 20H [data] |
020F | t(A1000000): STR R1, R0, 0H |
0210 | u(80E00008): LDR R0, SP, 8H |
0211 | u(A0D00020): STR R0, SB, 20H |
| ENDv |
0212 | v(80E00008): LDR R0, SP, 8H |
0213 | v(81E00014): LDR R1, SP, 14H |
0214 | v(00080001): ADD R0, R0, R1 |
0215 | v(A0E00008): STR R0, SP, 8H |
| END ; |
| IF mark > 0 THENw SYSTEM.GET(p, tag);x SYSTEM.GET(tag, size);y SYSTEM.PUT(p+4,z 0);a INC(p, size) |
0216 | w(80E0000C): LDR R0, SP, CH |
0217 | w(40090000): SUB R0, R0, 0H |
0218 | w(E600000F): BLE 15 [0228H] |
0219 | x(80E00004): LDR R0, SP, 4H |
021A | x(80000000): LDR R0, R0, 0H |
021B | x(A0E00010): STR R0, SP, 10H |
021C | y(80E00010): LDR R0, SP, 10H |
021D | y(80000000): LDR R0, R0, 0H |
021E | y(A0E00014): STR R0, SP, 14H |
021F | z(80E00004): LDR R0, SP, 4H |
0220 | z(40080004): ADD R0, R0, 4H |
0221 | a(41000000): MOV R1, R0, 0H |
0222 | a(A1000000): STR R1, R0, 0H |
| ELSEb (*free*) SYSTEMc.GET(p, size);d INC(p, size) |
0223 | b(80E00004): LDR R0, SP, 4H |
0224 | b(81E00014): LDR R1, SP, 14H |
0225 | b(00080001): ADD R0, R0, R1 |
0226 | b(A0E00004): STR R0, SP, 4H |
0227 | c(E7000007): B 7 [022FH] |
0228 | d(80E00004): LDR R0, SP, 4H |
0229 | d(80000000): LDR R0, R0, 0H |
022A | d(A0E00014): STR R0, SP, 14H |
| ENDe |
022B | e(80E00004): LDR R0, SP, 4H |
022C | e(81E00014): LDR R1, SP, 14H |
022D | e(00080001): ADD R0, R0, R1 |
022E | e(A0E00004): STR R0, SP, 4H |
| UNTIL p >= heapLim |
| ENDf Scan; |
022F | f(80E00004): LDR R0, SP, 4H |
0230 | f .FIXUP D |
0230 | f(8D000023): LDR SB, MT, MOD0 [Kernel] |
0231 | f(81D0000C): LDR R1, SB, CH [data] |
0232 | f(00090001): SUB R0, R0, R1 |
0233 | f(E5FFFF61): BLT -159 [0195H] |
0234 | f(8FE00000): LDR LNK, SP, 0H |
0235 | f(4EE80018): ADD SP, SP, 18H |
0236 | f(C700000F): B LNK |
| |
| (* ---------- Disk storage management ----------*) |
| |
| PROCEDURE SPIIdle(n: INTEGER); (*send n FFs slowly with no card selected*) |
| BEGINg SYSTEM.PUT(spiCtrl, 0);h |
0237 | g(4EE90008): SUB SP, SP, 8H |
0238 | g(AFE00000): STR LNK, SP, 0H |
0239 | g(A0E00004): STR R0, SP, 4H |
023A | h(5000FFD4): MOV R0, R0, FFFFFFD4H |
023B | h(41000000): MOV R1, R0, 0H |
023C | h(A1000000): STR R1, R0, 0H |
| WHILE n > 0 DOi DEC(n);j SYSTEM.PUT(spiData, -1);k |
023D | i(80E00004): LDR R0, SP, 4H |
023E | i(40090000): SUB R0, R0, 0H |
023F | i(E600000F): BLE 15 [024FH] |
0240 | j(80E00004): LDR R0, SP, 4H |
0241 | j(40090001): SUB R0, R0, 1H |
0242 | j(A0E00004): STR R0, SP, 4H |
0243 | k(5000FFD0): MOV R0, R0, FFFFFFD0H |
0244 | k(5100FFFF): MOV R1, R0, FFFFFFFFH |
0245 | k(A1000000): STR R1, R0, 0H |
| REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0);l |
0246 | l(5000FFD4): MOV R0, R0, FFFFFFD4H |
0247 | l(80000000): LDR R0, R0, 0H |
0248 | l(40030001): ROR R0, R0, 1H |
0249 | l(E8FFFFFC): BPL -4 [0246H] |
| SYSTEM.GET(spiData, data) |
| ENDm |
024A | m(5000FFD0): MOV R0, R0, FFFFFFD0H |
024B | m(80000000): LDR R0, R0, 0H |
024C | m .FIXUP D |
024C | m(8D00001C): LDR SB, MT, MOD0 [Kernel] |
024D | m(A0D00030): STR R0, SB, 30H [data] |
024E | m(E7FFFFEE): B -18 [023DH] |
| ENDn SPIIdle; |
024F | n(8FE00000): LDR LNK, SP, 0H |
0250 | n(4EE80008): ADD SP, SP, 8H |
0251 | n(C700000F): B LNK |
| |
| PROCEDURE SPI(n: INTEGER); (*send&rcv byte slowly with card selected*) |
| BEGINo SYSTEM.PUT(spiCtrl, CARD0);p SYSTEM.PUT(spiData, n);q |
0252 | o(4EE90008): SUB SP, SP, 8H |
0253 | o(AFE00000): STR LNK, SP, 0H |
0254 | o(A0E00004): STR R0, SP, 4H |
0255 | p(5000FFD4): MOV R0, R0, FFFFFFD4H |
0256 | p(41000001): MOV R1, R0, 1H |
0257 | p(A1000000): STR R1, R0, 0H |
0258 | q(5000FFD0): MOV R0, R0, FFFFFFD0H |
0259 | q(81E00004): LDR R1, SP, 4H |
025A | q(A1000000): STR R1, R0, 0H |
| REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0);r |
025B | r(5000FFD4): MOV R0, R0, FFFFFFD4H |
025C | r(80000000): LDR R0, R0, 0H |
025D | r(40030001): ROR R0, R0, 1H |
025E | r(E8FFFFFC): BPL -4 [025BH] |
| SYSTEM.GET(spiData, data) |
| ENDs SPI; |
025F | s(5000FFD0): MOV R0, R0, FFFFFFD0H |
0260 | s(80000000): LDR R0, R0, 0H |
0261 | s .FIXUP D |
0261 | s(8D000015): LDR SB, MT, MOD0 [Kernel] |
0262 | s(A0D00030): STR R0, SB, 30H [data] |
0263 | s(8FE00000): LDR LNK, SP, 0H |
0264 | s(4EE80008): ADD SP, SP, 8H |
0265 | s(C700000F): B LNK |
| |
| PROCEDURE SPICmd(n, arg: INTEGER); |
| VAR i, crc: INTEGER; |
| BEGINt (*send cmd*) |
0266 | t(4EE90014): SUB SP, SP, 14H |
0267 | t(AFE00000): STR LNK, SP, 0H |
0268 | t(A0E00004): STR R0, SP, 4H |
0269 | t(A1E00008): STR R1, SP, 8H |
| REPEAT SPIIdle(1)u UNTILv data = 255;w (*flush while unselected*) |
026A | u(40000001): MOV R0, R0, 1H |
026B | v(F7FFFFCB): BL -53 [0237H] |
026C | w .FIXUP D |
026C | w(8D00000B): LDR SB, MT, MOD0 [Kernel] |
026D | w(80D00030): LDR R0, SB, 30H [data] |
026E | w(400900FF): SUB R0, R0, FFH |
026F | w(E9FFFFFA): BNE -6 [026AH] |
| REPEAT SPI(255)x UNTILy data = 255;z (*flush while selected*) |
0270 | x(400000FF): MOV R0, R0, FFH |
0271 | y(F7FFFFE0): BL -32 [0252H] |
0272 | z .FIXUP D |
0272 | z(8D000006): LDR SB, MT, MOD0 [Kernel] |
0273 | z(80D00030): LDR R0, SB, 30H [data] |
0274 | z(400900FF): SUB R0, R0, FFH |
0275 | z(E9FFFFFA): BNE -6 [0270H] |
| IF n = 8 THENa crc := 135 ELSIFb nc = 0 THENd crc := 149 ELSEe crcf := 255 ENDg; |
0276 | a(80E00004): LDR R0, SP, 4H |
0277 | a(40090008): SUB R0, R0, 8H |
0278 | a(E9000003): BNE 3 [027CH] |
0279 | b(40000087): MOV R0, R0, 87H |
027A | b(A0E00010): STR R0, SP, 10H |
027B | c(E7000007): B 7 [0283H] |
027C | d(80E00004): LDR R0, SP, 4H |
027D | d(E9000003): BNE 3 [0281H] |
027E | e(40000095): MOV R0, R0, 95H |
027F | e(A0E00010): STR R0, SP, 10H |
0280 | f(E7000002): B 2 [0283H] |
0281 | g(400000FF): MOV R0, R0, FFH |
0282 | g(A0E00010): STR R0, SP, 10H |
| SPI(n MOD 64 +h 64)i;j (*send command*) |
0283 | h(80E00004): LDR R0, SP, 4H |
0284 | h(4004003F): AND R0, R0, 3FH |
0285 | i(40080040): ADD R0, R0, 40H |
0286 | j(F7FFFFCB): BL -53 [0252H] |
| FOR i := 24 TOk 0 BY -8 DO SPIl(ROR(arg, i))m ENDn;o (*send arg*) |
0287 | k(40000018): MOV R0, R0, 18H |
0288 | l(41090000): SUB R1, R0, 0H |
0289 | l(E5000008): BLT 8 [0292H] |
028A | l(A0E0000C): STR R0, SP, CH |
028B | m(80E00008): LDR R0, SP, 8H |
028C | m(81E0000C): LDR R1, SP, CH |
028D | m(00030001): ROR R0, R0, R1 |
028E | n(F7FFFFC3): BL -61 [0252H] |
028F | o(80E0000C): LDR R0, SP, CH |
0290 | o(5008FFF8): ADD R0, R0, FFFFFFF8H |
0291 | o(E7FFFFF6): B -10 [0288H] |
| SPI(crc)p;q i := 32;r |
0292 | p(80E00010): LDR R0, SP, 10H |
0293 | q(F7FFFFBE): BL -66 [0252H] |
0294 | r(40000020): MOV R0, R0, 20H |
0295 | r(A0E0000C): STR R0, SP, CH |
| REPEAT SPI(255)s;t DEC(i) UNTILu (data < 80H)v OR (wi = 0)x |
0296 | s(400000FF): MOV R0, R0, FFH |
0297 | t(F7FFFFBA): BL -70 [0252H] |
0298 | u(80E0000C): LDR R0, SP, CH |
0299 | u(40090001): SUB R0, R0, 1H |
029A | u(A0E0000C): STR R0, SP, CH |
029B | v .FIXUP D |
029B | v(8D000029): LDR SB, MT, MOD0 [Kernel] |
029C | v(80D00030): LDR R0, SB, 30H [data] |
029D | v(40090080): SUB R0, R0, 80H |
029E | w(E5000002): BLT 2 [02A1H] |
029F | x(80E0000C): LDR R0, SP, CH |
| ENDy SPICmd; |
02A0 | y(E9FFFFF5): BNE -11 [0296H] |
02A1 | y(8FE00000): LDR LNK, SP, 0H |
02A2 | y(4EE80014): ADD SP, SP, 14H |
02A3 | y(C700000F): B LNK |
| |
| PROCEDURE SDShift(VAR n: INTEGER); |
| VAR data: INTEGER; |
| BEGINz SPICmd(58,a 0)b;c (*CMD58 get card capacity bit*) |
02A4 | z(4EE9000C): SUB SP, SP, CH |
02A5 | z(AFE00000): STR LNK, SP, 0H |
02A6 | z(A0E00004): STR R0, SP, 4H |
02A7 | a(4000003A): MOV R0, R0, 3AH |
02A8 | b(41000000): MOV R1, R0, 0H |
02A9 | c(F7FFFFBC): BL -68 [0266H] |
| SYSTEM.GET(spiData, data);d SPI(-1)e;f |
02AA | d(5000FFD0): MOV R0, R0, FFFFFFD0H |
02AB | d(80000000): LDR R0, R0, 0H |
02AC | d(A0E00008): STR R0, SP, 8H |
02AD | e(5000FFFF): MOV R0, R0, FFFFFFFFH |
02AE | f(F7FFFFA3): BL -93 [0252H] |
| IF (data # 0)g OR ~hSYSTEM.BIT(spiData, 6) THENi n := n * 512 ENDj ; (*non-SDHC card*) |
02AF | g(80E00008): LDR R0, SP, 8H |
02B0 | h(E9000004): BNE 4 [02B5H] |
02B1 | i(5000FFD0): MOV R0, R0, FFFFFFD0H |
02B2 | i(80000000): LDR R0, R0, 0H |
02B3 | i(40030007): ROR R0, R0, 7H |
02B4 | i(E0000005): BMI 5 [02BAH] |
02B5 | j(80E00004): LDR R0, SP, 4H |
02B6 | j(80000000): LDR R0, R0, 0H |
02B7 | j(40010009): LSL R0, R0, 9H |
02B8 | j(81E00004): LDR R1, SP, 4H |
02B9 | j(A0100000): STR R0, R1, 0H |
| SPI(-1)k;l SPI(-1)m;n SPIIdle(1)o (*flush response*) |
02BA | k(5000FFFF): MOV R0, R0, FFFFFFFFH |
02BB | l(F7FFFF96): BL -106 [0252H] |
02BC | m(5000FFFF): MOV R0, R0, FFFFFFFFH |
02BD | n(F7FFFF94): BL -108 [0252H] |
02BE | o(40000001): MOV R0, R0, 1H |
| ENDp SDShift; |
02BF | p(F7FFFF77): BL -137 [0237H] |
02C0 | p(8FE00000): LDR LNK, SP, 0H |
02C1 | p(4EE8000C): ADD SP, SP, CH |
02C2 | p(C700000F): B LNK |
| |
| PROCEDURE ReadSD(src, dst: INTEGER); |
| VAR i: INTEGER; |
| BEGINq SDShift(src)r;s SPICmd(17,t src)u;v ASSERT(data = 0)w;x (*CMD17 read one block*) |
02C3 | q(4EE90010): SUB SP, SP, 10H |
02C4 | q(AFE00000): STR LNK, SP, 0H |
02C5 | q(A0E00004): STR R0, SP, 4H |
02C6 | q(A1E00008): STR R1, SP, 8H |
02C7 | r(40E80004): ADD R0, SP, 4H |
02C8 | s(F7FFFFDB): BL -37 [02A4H] |
02C9 | t(40000011): MOV R0, R0, 11H |
02CA | u(81E00004): LDR R1, SP, 4H |
02CB | v(F7FFFF9A): BL -102 [0266H] |
02CC | w .FIXUP D |
02CC | w(8D000031): LDR SB, MT, MOD0 [Kernel] |
02CD | w(80D00030): LDR R0, SB, 30H [data] |
02CE | x(D9196B7C): BLNE MT [trap=7, pos=6507] |
| i := 0;y (*wait for start data marker*) |
02CF | y(40000000): MOV R0, R0, 0H |
02D0 | y(A0E0000C): STR R0, SP, CH |
| REPEAT SPI(-1)z;a INC(i) UNTILb data = 254;c |
02D1 | z(5000FFFF): MOV R0, R0, FFFFFFFFH |
02D2 | a(F7FFFF7F): BL -129 [0252H] |
02D3 | b(80E0000C): LDR R0, SP, CH |
02D4 | b(40080001): ADD R0, R0, 1H |
02D5 | b(A0E0000C): STR R0, SP, CH |
02D6 | c .FIXUP D |
02D6 | c(8D00000A): LDR SB, MT, MOD0 [Kernel] |
02D7 | c(80D00030): LDR R0, SB, 30H [data] |
02D8 | c(400900FE): SUB R0, R0, FEH |
02D9 | c(E9FFFFF7): BNE -9 [02D1H] |
| SYSTEM.PUT(spiCtrl, SPIFAST + CARD0);d |
02DA | d(5000FFD4): MOV R0, R0, FFFFFFD4H |
02DB | d(41000005): MOV R1, R0, 5H |
02DC | d(A1000000): STR R1, R0, 0H |
| FOR i := 0 TOe 508 BY 4 DO |
02DD | e(40000000): MOV R0, R0, 0H |
| SYSTEMf.PUT(spiData, -1);g |
02DE | f(410901FC): SUB R1, R0, 1FCH |
02DF | f(EE000015): BGT 21 [02F5H] |
02E0 | f(A0E0000C): STR R0, SP, CH |
02E1 | g(5000FFD0): MOV R0, R0, FFFFFFD0H |
02E2 | g(5100FFFF): MOV R1, R0, FFFFFFFFH |
02E3 | g(A1000000): STR R1, R0, 0H |
| REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0);h |
02E4 | h(5000FFD4): MOV R0, R0, FFFFFFD4H |
02E5 | h(80000000): LDR R0, R0, 0H |
02E6 | h(40030001): ROR R0, R0, 1H |
02E7 | h(E8FFFFFC): BPL -4 [02E4H] |
| SYSTEM.GET(spiData, data);i SYSTEM.PUT(dst, data);j INC(dst, 4) |
02E8 | i(5000FFD0): MOV R0, R0, FFFFFFD0H |
02E9 | i(80000000): LDR R0, R0, 0H |
02EA | i .FIXUP D |
02EA | i(8D000014): LDR SB, MT, MOD0 [Kernel] |
02EB | i(A0D00030): STR R0, SB, 30H [data] |
02EC | j(80E00008): LDR R0, SP, 8H |
02ED | j(81D00030): LDR R1, SB, 30H |
02EE | j(A1000000): STR R1, R0, 0H |
| ENDk;l |
02EF | k(80E00008): LDR R0, SP, 8H |
02F0 | k(40080004): ADD R0, R0, 4H |
02F1 | k(A0E00008): STR R0, SP, 8H |
02F2 | l(80E0000C): LDR R0, SP, CH |
02F3 | l(40080004): ADD R0, R0, 4H |
02F4 | l(E7FFFFE9): B -23 [02DEH] |
| SPI(255)m;n SPI(255)o;p SPIIdle(1)q (*may be a checksum; deselect card*) |
02F5 | m(400000FF): MOV R0, R0, FFH |
02F6 | n(F7FFFF5B): BL -165 [0252H] |
02F7 | o(400000FF): MOV R0, R0, FFH |
02F8 | p(F7FFFF59): BL -167 [0252H] |
02F9 | q(40000001): MOV R0, R0, 1H |
| ENDr ReadSD; |
02FA | r(F7FFFF3C): BL -196 [0237H] |
02FB | r(8FE00000): LDR LNK, SP, 0H |
02FC | r(4EE80010): ADD SP, SP, 10H |
02FD | r(C700000F): B LNK |
| |
| PROCEDURE WriteSD(dst, src: INTEGER); |
| VAR i, n: INTEGER; x: BYTE; |
| BEGINs SDShift(dst)t;u SPICmd(24,v dst)w;x ASSERT(data = 0)y;z (*CMD24 write one block*) |
02FE | s(4EE90018): SUB SP, SP, 18H |
02FF | s(AFE00000): STR LNK, SP, 0H |
0300 | s(A0E00004): STR R0, SP, 4H |
0301 | s(A1E00008): STR R1, SP, 8H |
0302 | t(40E80004): ADD R0, SP, 4H |
0303 | u(F7FFFFA0): BL -96 [02A4H] |
0304 | v(40000018): MOV R0, R0, 18H |
0305 | w(81E00004): LDR R1, SP, 4H |
0306 | x(F7FFFF5F): BL -161 [0266H] |
0307 | y .FIXUP D |
0307 | y(8D00001D): LDR SB, MT, MOD0 [Kernel] |
0308 | y(80D00030): LDR R0, SB, 30H [data] |
0309 | z(D91B937C): BLNE MT [trap=7, pos=7059] |
| SPI(254)a;b (*write start data marker*) |
030A | a(400000FE): MOV R0, R0, FEH |
030B | b(F7FFFF46): BL -186 [0252H] |
| SYSTEM.PUT(spiCtrl, SPIFAST + CARD0);c |
030C | c(5000FFD4): MOV R0, R0, FFFFFFD4H |
030D | c(41000005): MOV R1, R0, 5H |
030E | c(A1000000): STR R1, R0, 0H |
| FOR i := 0 TOd 508 BY 4 DO |
030F | d(40000000): MOV R0, R0, 0H |
| SYSTEMe.GET(src, n);f INC(src, 4);g SYSTEM.PUT(spiData, n);h |
0310 | e(410901FC): SUB R1, R0, 1FCH |
0311 | e(EE000011): BGT 17 [0323H] |
0312 | e(A0E0000C): STR R0, SP, CH |
0313 | f(80E00008): LDR R0, SP, 8H |
0314 | f(80000000): LDR R0, R0, 0H |
0315 | f(A0E00010): STR R0, SP, 10H |
0316 | g(80E00008): LDR R0, SP, 8H |
0317 | g(40080004): ADD R0, R0, 4H |
0318 | g(A0E00008): STR R0, SP, 8H |
0319 | h(5000FFD0): MOV R0, R0, FFFFFFD0H |
031A | h(81E00010): LDR R1, SP, 10H |
031B | h(A1000000): STR R1, R0, 0H |
| REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0) |
| ENDi;j |
031C | i(5000FFD4): MOV R0, R0, FFFFFFD4H |
031D | i(80000000): LDR R0, R0, 0H |
031E | i(40030001): ROR R0, R0, 1H |
031F | i(E8FFFFFC): BPL -4 [031CH] |
0320 | j(80E0000C): LDR R0, SP, CH |
0321 | j(40080004): ADD R0, R0, 4H |
0322 | j(E7FFFFED): B -19 [0310H] |
| SPI(255)k;l SPI(255)m;n (*dummy checksum*) i := 0;o |
0323 | k(400000FF): MOV R0, R0, FFH |
0324 | l(F7FFFF2D): BL -211 [0252H] |
0325 | m(400000FF): MOV R0, R0, FFH |
0326 | n(F7FFFF2B): BL -213 [0252H] |
0327 | o(40000000): MOV R0, R0, 0H |
0328 | o(A0E0000C): STR R0, SP, CH |
| REPEAT SPI(-1)p;q INC(i);r UNTIL (data MOD 32 =s 5)t OR (ui = 10000)v;w |
0329 | p(5000FFFF): MOV R0, R0, FFFFFFFFH |
032A | q(F7FFFF27): BL -217 [0252H] |
032B | r(80E0000C): LDR R0, SP, CH |
032C | r(40080001): ADD R0, R0, 1H |
032D | r(A0E0000C): STR R0, SP, CH |
032E | s .FIXUP D |
032E | s(8D000027): LDR SB, MT, MOD0 [Kernel] |
032F | s(80D00030): LDR R0, SB, 30H [data] |
0330 | s(4004001F): AND R0, R0, 1FH |
0331 | t(40090005): SUB R0, R0, 5H |
0332 | u(E1000003): BEQ 3 [0336H] |
0333 | v(80E0000C): LDR R0, SP, CH |
0334 | v(40092710): SUB R0, R0, 2710H |
0335 | w(E9FFFFF3): BNE -13 [0329H] |
| ASSERT(data MOD 32 =x 5)y;z SPIIdle(1)a (*deselect card*) |
0336 | x .FIXUP D |
0336 | x(8D000008): LDR SB, MT, MOD0 [Kernel] |
0337 | x(80D00030): LDR R0, SB, 30H [data] |
0338 | x(4004001F): AND R0, R0, 1FH |
0339 | y(40090005): SUB R0, R0, 5H |
033A | z(D91D257C): BLNE MT [trap=7, pos=7461] |
033B | a(40000001): MOV R0, R0, 1H |
| ENDb WriteSD; |
033C | b(F7FFFEFA): BL -262 [0237H] |
033D | b(8FE00000): LDR LNK, SP, 0H |
033E | b(4EE80018): ADD SP, SP, 18H |
033F | b(C700000F): B LNK |
| |
| PROCEDURE InitSecMap*; |
| VAR i: INTEGER; |
| BEGINc NofSectors := 0;d sectorMap[0] := {0 .. 31};e sectorMap[1] := {0 .. 31};f |
0340 | c .PROC 11 |
0340 | c .COMMAND InitSecMap |
0340 | c(4EE90008): SUB SP, SP, 8H |
0341 | c(AFE00000): STR LNK, SP, 0H |
0342 | d(40000000): MOV R0, R0, 0H |
0343 | d .FIXUP D |
0343 | d(8D00000D): LDR SB, MT, MOD0 [Kernel] |
0344 | d(A0D00004): STR R0, SB, 4H [data] |
0345 | e(5000FFFF): MOV R0, R0, FFFFFFFFH |
0346 | e(A0D00034): STR R0, SB, 34H |
0347 | f(5000FFFF): MOV R0, R0, FFFFFFFFH |
0348 | f(A0D00038): STR R0, SB, 38H |
| FOR i := 2 TOg mapsize DIV 32 - 1 DO sectorMaph[i]i := {} ENDj |
0349 | g(40000002): MOV R0, R0, 2H |
034A | h(410907FF): SUB R1, R0, 7FFH |
034B | h(EE00000C): BGT 12 [0358H] |
034C | h(A0E00004): STR R0, SP, 4H |
034D | i(80E00004): LDR R0, SP, 4H |
034E | i(41090800): SUB R1, R0, 800H |
034F | i(DA1E031C): BLCC MT [trap=1, pos=7683] |
0350 | i(40010002): LSL R0, R0, 2H |
0351 | i .FIXUP D |
0351 | i(8D00000E): LDR SB, MT, MOD0 [Kernel] |
0352 | i(00D80000): ADD R0, SB, R0 [global array] |
0353 | j(41000000): MOV R1, R0, 0H |
0354 | j(A1000034): STR R1, R0, 34H |
| ENDk InitSecMap; |
0355 | k(80E00004): LDR R0, SP, 4H |
0356 | k(40080001): ADD R0, R0, 1H |
0357 | k(E7FFFFF2): B -14 [034AH] |
0358 | k(8FE00000): LDR LNK, SP, 0H |
0359 | k(4EE80008): ADD SP, SP, 8H |
035A | k(C700000F): B LNK |
| |
| PROCEDURE MarkSector*(sec: INTEGER); |
| BEGINl sec := sec DIV 29;m ASSERT(SYSTEM.H(0) =n 0)o;p |
035B | l .PROC 12 |
035B | l(4EE90008): SUB SP, SP, 8H |
035C | l(AFE00000): STR LNK, SP, 0H |
035D | l(A0E00004): STR R0, SP, 4H |
035E | m(80E00004): LDR R0, SP, 4H |
035F | m(400B001D): DIV R0, R0, 1DH |
0360 | m(A0E00004): STR R0, SP, 4H |
0361 | n(20000000): MOV' R0, R0, R0 |
0362 | o(40090000): SUB R0, R0, 0H |
0363 | p(D91E7B7C): BLNE MT [trap=7, pos=7803] |
| INCL(sectorMap[sec DIV 32]q, sec MOD 32)r;s INC(NofSectors) |
0364 | q(80E00004): LDR R0, SP, 4H |
0365 | q(40020005): ASR R0, R0, 5H |
0366 | q(41090800): SUB R1, R0, 800H |
0367 | q(DA1E9A1C): BLCC MT [trap=1, pos=7834] |
0368 | q(40010002): LSL R0, R0, 2H |
0369 | q .FIXUP D |
0369 | q(8D000018): LDR SB, MT, MOD0 [Kernel] |
036A | q(00D80000): ADD R0, SB, R0 [global array] |
036B | r(81E00004): LDR R1, SP, 4H |
036C | r(4114001F): AND R1, R1, 1FH |
036D | s(40080034): ADD R0, R0, 34H |
036E | s(82000000): LDR R2, R0, 0H |
036F | s(43000001): MOV R3, R0, 1H |
0370 | s(01310001): LSL R1, R3, R1 |
0371 | s(02260001): IOR R2, R2, R1 |
0372 | s(A2000000): STR R2, R0, 0H |
| ENDt MarkSector; |
0373 | t(40D80004): ADD R0, SB, 4H |
0374 | t(81000000): LDR R1, R0, 0H |
0375 | t(41180001): ADD R1, R1, 1H |
0376 | t(A1000000): STR R1, R0, 0H |
0377 | t(8FE00000): LDR LNK, SP, 0H |
0378 | t(4EE80008): ADD SP, SP, 8H |
0379 | t(C700000F): B LNK |
| |
| PROCEDURE FreeSector*(sec: INTEGER); |
| BEGINu sec := sec DIV 29;v ASSERT(SYSTEM.H(0) =w 0)x;y |
037A | u .PROC 13 |
037A | u(4EE90008): SUB SP, SP, 8H |
037B | u(AFE00000): STR LNK, SP, 0H |
037C | u(A0E00004): STR R0, SP, 4H |
037D | v(80E00004): LDR R0, SP, 4H |
037E | v(400B001D): DIV R0, R0, 1DH |
037F | v(A0E00004): STR R0, SP, 4H |
0380 | w(20000000): MOV' R0, R0, R0 |
0381 | x(40090000): SUB R0, R0, 0H |
0382 | y(D91F267C): BLNE MT [trap=7, pos=7974] |
| EXCL(sectorMap[sec DIV 32]z, sec MOD 32)a;b DEC(NofSectors) |
0383 | z(80E00004): LDR R0, SP, 4H |
0384 | z(40020005): ASR R0, R0, 5H |
0385 | z(41090800): SUB R1, R0, 800H |
0386 | z(DA1F451C): BLCC MT [trap=1, pos=8005] |
0387 | z(40010002): LSL R0, R0, 2H |
0388 | z .FIXUP D |
0388 | z(8D00001F): LDR SB, MT, MOD0 [Kernel] |
0389 | z(00D80000): ADD R0, SB, R0 [global array] |
038A | a(81E00004): LDR R1, SP, 4H |
038B | a(4114001F): AND R1, R1, 1FH |
038C | b(40080034): ADD R0, R0, 34H |
038D | b(82000000): LDR R2, R0, 0H |
038E | b(43000001): MOV R3, R0, 1H |
038F | b(01310001): LSL R1, R3, R1 |
0390 | b(02250001): ANN R2, R2, R1 |
0391 | b(A2000000): STR R2, R0, 0H |
| ENDc FreeSector; |
0392 | c(40D80004): ADD R0, SB, 4H |
0393 | c(81000000): LDR R1, R0, 0H |
0394 | c(41190001): SUB R1, R1, 1H |
0395 | c(A1000000): STR R1, R0, 0H |
0396 | c(8FE00000): LDR LNK, SP, 0H |
0397 | c(4EE80008): ADD SP, SP, 8H |
0398 | c(C700000F): B LNK |
| |
| PROCEDURE AllocSector*(hint: INTEGER; VAR sec: INTEGER); |
| VAR s: INTEGER; |
| BEGINd (*find free sector, starting after hint*) |
0399 | d .PROC 14 |
0399 | d(4EE90010): SUB SP, SP, 10H |
039A | d(AFE00000): STR LNK, SP, 0H |
039B | d(A0E00004): STR R0, SP, 4H |
039C | d(A1E00008): STR R1, SP, 8H |
| hint := hint DIV 29;e ASSERT(SYSTEM.H(0) =f 0)g;h s := hint;i |
039D | e(80E00004): LDR R0, SP, 4H |
039E | e(400B001D): DIV R0, R0, 1DH |
039F | e(A0E00004): STR R0, SP, 4H |
03A0 | f(20000000): MOV' R0, R0, R0 |
03A1 | g(40090000): SUB R0, R0, 0H |
03A2 | h(D920297C): BLNE MT [trap=7, pos=8233] |
03A3 | i(80E00004): LDR R0, SP, 4H |
03A4 | i(A0E0000C): STR R0, SP, CH |
| REPEAT INC(s);j |
03A5 | j(80E0000C): LDR R0, SP, CH |
03A6 | j(40080001): ADD R0, R0, 1H |
03A7 | j(A0E0000C): STR R0, SP, CH |
| IF s = mapsize THENk s := 1 ENDl ; |
03A8 | k(80E0000C): LDR R0, SP, CH |
03A9 | k(61000001): MOV' R1, R0, 1H |
03AA | k(00090001): SUB R0, R0, R1 |
03AB | k(E9000002): BNE 2 [03AEH] |
03AC | l(40000001): MOV R0, R0, 1H |
03AD | l(A0E0000C): STR R0, SP, CH |
| UNTIL ~(s MOD 32 INm sectorMap[s DIV 32]n)o;p |
03AE | m(80E0000C): LDR R0, SP, CH |
03AF | m(4004001F): AND R0, R0, 1FH |
03B0 | n(81E0000C): LDR R1, SP, CH |
03B1 | n(41120005): ASR R1, R1, 5H |
03B2 | n(42190800): SUB R2, R1, 800H |
03B3 | n(DA209A1C): BLCC MT [trap=1, pos=8346] |
03B4 | n(41110002): LSL R1, R1, 2H |
03B5 | n .FIXUP D |
03B5 | n(8D00002D): LDR SB, MT, MOD0 [Kernel] |
03B6 | n(01D80001): ADD R1, SB, R1 [global array] |
03B7 | o(81100034): LDR R1, R1, 34H |
03B8 | o(40080001): ADD R0, R0, 1H |
03B9 | o(01130000): ROR R1, R1, R0 |
03BA | p(E0FFFFEA): BMI -22 [03A5H] |
| INCL(sectorMap[s DIV 32]q, s MOD 32)r;s INC(NofSectors);t sec := s * 29 |
03BB | q(80E0000C): LDR R0, SP, CH |
03BC | q(40020005): ASR R0, R0, 5H |
03BD | q(41090800): SUB R1, R0, 800H |
03BE | q(DA20B91C): BLCC MT [trap=1, pos=8377] |
03BF | q(40010002): LSL R0, R0, 2H |
03C0 | q .FIXUP D |
03C0 | q(8D00000B): LDR SB, MT, MOD0 [Kernel] |
03C1 | q(00D80000): ADD R0, SB, R0 [global array] |
03C2 | r(81E0000C): LDR R1, SP, CH |
03C3 | r(4114001F): AND R1, R1, 1FH |
03C4 | s(40080034): ADD R0, R0, 34H |
03C5 | s(82000000): LDR R2, R0, 0H |
03C6 | s(43000001): MOV R3, R0, 1H |
03C7 | s(01310001): LSL R1, R3, R1 |
03C8 | s(02260001): IOR R2, R2, R1 |
03C9 | s(A2000000): STR R2, R0, 0H |
03CA | t(40D80004): ADD R0, SB, 4H |
03CB | t(81000000): LDR R1, R0, 0H |
03CC | t(41180001): ADD R1, R1, 1H |
03CD | t(A1000000): STR R1, R0, 0H |
| ENDu AllocSector; |
03CE | u(80E0000C): LDR R0, SP, CH |
03CF | u(400A001D): MUL R0, R0, 1DH |
03D0 | u(81E00008): LDR R1, SP, 8H |
03D1 | u(A0100000): STR R0, R1, 0H |
03D2 | u(8FE00000): LDR LNK, SP, 0H |
03D3 | u(4EE80010): ADD SP, SP, 10H |
03D4 | u(C700000F): B LNK |
| |
| PROCEDURE GetSector*(src: INTEGER; VAR dst: Sector); |
| BEGINv src := src DIV 29;w ASSERT(SYSTEM.H(0) =x 0)y;z |
03D5 | v .PROC 15 |
03D5 | v(4EE9000C): SUB SP, SP, CH |
03D6 | v(AFE00000): STR LNK, SP, 0H |
03D7 | v(A0E00004): STR R0, SP, 4H |
03D8 | v(A1E00008): STR R1, SP, 8H |
03D9 | w(80E00004): LDR R0, SP, 4H |
03DA | w(400B001D): DIV R0, R0, 1DH |
03DB | w(A0E00004): STR R0, SP, 4H |
03DC | x(20000000): MOV' R0, R0, R0 |
03DD | y(40090000): SUB R0, R0, 0H |
03DE | z(D921637C): BLNE MT [trap=7, pos=8547] |
| src := src * 2 +a FSoffset;b |
03DF | a(80E00004): LDR R0, SP, 4H |
03E0 | a(40010001): LSL R0, R0, 1H |
03E1 | b(61000008): MOV' R1, R0, 8H |
03E2 | b(00080001): ADD R0, R0, R1 |
03E3 | b(A0E00004): STR R0, SP, 4H |
| ReadSD(src,c SYSTEM.ADR(dst))d;e ReadSD(src+1,f SYSTEM.ADR(dst)+g512)h |
03E4 | c(80E00004): LDR R0, SP, 4H |
03E5 | d(81E00008): LDR R1, SP, 8H |
03E6 | e(F7FFFEDC): BL -292 [02C3H] |
03E7 | f(80E00004): LDR R0, SP, 4H |
03E8 | f(40080001): ADD R0, R0, 1H |
03E9 | g(81E00008): LDR R1, SP, 8H |
03EA | h(41180200): ADD R1, R1, 200H |
| ENDi GetSector; |
03EB | i(F7FFFED7): BL -297 [02C3H] |
03EC | i(8FE00000): LDR LNK, SP, 0H |
03ED | i(4EE8000C): ADD SP, SP, CH |
03EE | i(C700000F): B LNK |
| |
| PROCEDURE PutSector*(dst: INTEGER; VAR src: Sector); |
| BEGINj dst := dst DIV 29;k ASSERT(SYSTEM.H(0) =l 0)m;n |
03EF | j .PROC 16 |
03EF | j(4EE9000C): SUB SP, SP, CH |
03F0 | j(AFE00000): STR LNK, SP, 0H |
03F1 | j(A0E00004): STR R0, SP, 4H |
03F2 | j(A1E00008): STR R1, SP, 8H |
03F3 | k(80E00004): LDR R0, SP, 4H |
03F4 | k(400B001D): DIV R0, R0, 1DH |
03F5 | k(A0E00004): STR R0, SP, 4H |
03F6 | l(20000000): MOV' R0, R0, R0 |
03F7 | m(40090000): SUB R0, R0, 0H |
03F8 | n(D922487C): BLNE MT [trap=7, pos=8776] |
| dst := dst * 2 +o FSoffset;p |
03F9 | o(80E00004): LDR R0, SP, 4H |
03FA | o(40010001): LSL R0, R0, 1H |
03FB | p(61000008): MOV' R1, R0, 8H |
03FC | p(00080001): ADD R0, R0, R1 |
03FD | p(A0E00004): STR R0, SP, 4H |
| WriteSD(dst,q SYSTEM.ADR(src))r;s WriteSD(dst+1,t SYSTEM.ADR(src)+u512)v |
03FE | q(80E00004): LDR R0, SP, 4H |
03FF | r(81E00008): LDR R1, SP, 8H |
0400 | s(F7FFFEFD): BL -259 [02FEH] |
0401 | t(80E00004): LDR R0, SP, 4H |
0402 | t(40080001): ADD R0, R0, 1H |
0403 | u(81E00008): LDR R1, SP, 8H |
0404 | v(41180200): ADD R1, R1, 200H |
| ENDw PutSector; |
0405 | w(F7FFFEF8): BL -264 [02FEH] |
0406 | w(8FE00000): LDR LNK, SP, 0H |
0407 | w(4EE8000C): ADD SP, SP, CH |
0408 | w(C700000F): B LNK |
| |
| (*-------- Miscellaneous procedures----------*) |
| |
| PROCEDURE Time*(): INTEGER; |
| VAR t: INTEGER; |
| BEGINx SYSTEM.GET(timer, t);y RETURN t |
0409 | x .PROC 17 |
0409 | x(4EE90008): SUB SP, SP, 8H |
040A | x(AFE00000): STR LNK, SP, 0H |
040B | y(5000FFC0): MOV R0, R0, FFFFFFC0H |
040C | y(80000000): LDR R0, R0, 0H |
040D | y(A0E00004): STR R0, SP, 4H |
| ENDz Time; |
040E | z(80E00004): LDR R0, SP, 4H |
040F | z(8FE00000): LDR LNK, SP, 0H |
0410 | z(4EE80008): ADD SP, SP, 8H |
0411 | z(C700000F): B LNK |
| |
| PROCEDURE Clock*(): INTEGER; |
| BEGINa RETURN clock |
0412 | a .PROC 18 |
0412 | a(4EE90004): SUB SP, SP, 4H |
0413 | a(AFE00000): STR LNK, SP, 0H |
| ENDb Clock; |
0414 | b .FIXUP D |
0414 | b(8D000054): LDR SB, MT, MOD0 [Kernel] |
0415 | b(80D0001C): LDR R0, SB, 1CH [data] |
0416 | b(8FE00000): LDR LNK, SP, 0H |
0417 | b(4EE80004): ADD SP, SP, 4H |
0418 | b(C700000F): B LNK |
| |
| PROCEDURE SetClock*(dt: INTEGER); |
| BEGINc clock := dt |
0419 | c .PROC 19 |
0419 | c(4EE90008): SUB SP, SP, 8H |
041A | c(AFE00000): STR LNK, SP, 0H |
041B | c(A0E00004): STR R0, SP, 4H |
| ENDd SetClock; |
041C | d(80E00004): LDR R0, SP, 4H |
041D | d .FIXUP D |
041D | d(8D000009): LDR SB, MT, MOD0 [Kernel] |
041E | d(A0D0001C): STR R0, SB, 1CH [data] |
041F | d(8FE00000): LDR LNK, SP, 0H |
0420 | d(4EE80008): ADD SP, SP, 8H |
0421 | d(C700000F): B LNK |
| |
| PROCEDURE Install*(Padr, at: INTEGER); |
| BEGINe SYSTEM.PUT(at, 0E7000000H + (Padr - at)f DIV 4 -g1)h |
0422 | e .PROC 20 |
0422 | e(4EE9000C): SUB SP, SP, CH |
0423 | e(AFE00000): STR LNK, SP, 0H |
0424 | e(A0E00004): STR R0, SP, 4H |
0425 | e(A1E00008): STR R1, SP, 8H |
0426 | f(80E00004): LDR R0, SP, 4H |
0427 | f(81E00008): LDR R1, SP, 8H |
0428 | f(00090001): SUB R0, R0, R1 |
0429 | g(40020002): ASR R0, R0, 2H |
042A | g(6100E700): MOV' R1, R0, FFFFE700H |
042B | g(00180000): ADD R0, R1, R0 |
042C | h(40090001): SUB R0, R0, 1H |
| ENDi Install; |
042D | i(81E00008): LDR R1, SP, 8H |
042E | i(A0100000): STR R0, R1, 0H |
042F | i(8FE00000): LDR LNK, SP, 0H |
0430 | i(4EE8000C): ADD SP, SP, CH |
0431 | i(C700000F): B LNK |
| |
| PROCEDURE Trap(VAR a: INTEGER; b: INTEGER); |
| VAR u, v, w: INTEGER; |
| BEGINj u := SYSTEM.REG(15);k SYSTEM.GET(u - 4,l v);m w := v DIV 10H MODn 10H;o (*trap number*) |
0432 | j(4EE90018): SUB SP, SP, 18H |
0433 | j(AFE00000): STR LNK, SP, 0H |
0434 | j(A0E00004): STR R0, SP, 4H |
0435 | j(A1E00008): STR R1, SP, 8H |
0436 | k(0000000F): MOV R0, R0, LNK |
0437 | k(A0E0000C): STR R0, SP, CH |
0438 | l(80E0000C): LDR R0, SP, CH |
0439 | l(40090004): SUB R0, R0, 4H |
043A | m(80000000): LDR R0, R0, 0H |
043B | m(A0E00010): STR R0, SP, 10H |
043C | n(80E00010): LDR R0, SP, 10H |
043D | n(40020004): ASR R0, R0, 4H |
043E | o(4004000F): AND R0, R0, FH |
043F | o(A0E00014): STR R0, SP, 14H |
| IF w = 0 THENp New(a,q b)r |
0440 | p(80E00014): LDR R0, SP, 14H |
0441 | p(E9000004): BNE 4 [0446H] |
0442 | q(80E00004): LDR R0, SP, 4H |
0443 | r(81E00008): LDR R1, SP, 8H |
| ELSEs (*stop*) LEDt(w + 192)u;v REPEAT UNTIL FALSE |
0444 | s(F7FFFC8D): BL -883 [00D2H] |
0445 | t(E7000005): B 5 [044BH] |
0446 | u(80E00014): LDR R0, SP, 14H |
0447 | u(400800C0): ADD R0, R0, C0H |
0448 | v(5100FFC4): MOV R1, R0, FFFFFFC4H |
0449 | v(A0100000): STR R0, R1, 0H |
| ENDw |
044A | w(E7FFFFFF): B -1 [044AH] |
| ENDx Trap; |
044B | x(8FE00000): LDR LNK, SP, 0H |
044C | x(4EE80018): ADD SP, SP, 18H |
044D | x(C700000F): B LNK |
| |
| PROCEDURE Init*; |
| BEGINy Install(SYSTEM.ADR(Trap),z 20H)a;b (*install temporary trap*) |
044E | y .PROC 21 |
044E | y .COMMAND Init |
044E | y(4EE90004): SUB SP, SP, 4H |
044F | y(AFE00000): STR LNK, SP, 0H |
0450 | z(F7000000): BL 0 [0451H] |
0451 | z(40F9007C): SUB R0, LNK, 7CH |
0452 | a(41000020): MOV R1, R0, 20H |
0453 | b(F7FFFFCE): BL -50 [0422H] |
| SYSTEM.GET(12, MemLim);c SYSTEM.GET(24, heapOrg);d |
0454 | c(4000000C): MOV R0, R0, CH |
0455 | c(80000000): LDR R0, R0, 0H |
0456 | c .FIXUP D |
0456 | c(8D000039): LDR SB, MT, MOD0 [Kernel] |
0457 | c(A0D00018): STR R0, SB, 18H [data] |
0458 | d(40000018): MOV R0, R0, 18H |
0459 | d(80000000): LDR R0, R0, 0H |
045A | d(A0D00008): STR R0, SB, 8H |
| stackOrg := heapOrg;e stackSize := 8000H;f heapLim := MemLim;g |
045B | e(80D00008): LDR R0, SB, 8H |
045C | e(A0D00010): STR R0, SB, 10H |
045D | f(40008000): MOV R0, R0, FFFF8000H |
045E | f(A0D00014): STR R0, SB, 14H |
045F | g(80D00018): LDR R0, SB, 18H |
0460 | g(A0D0000C): STR R0, SB, CH |
| list1 := 0;h list2 := 0;i list3 := 0;j list0 := heapOrg;k |
0461 | h(40000000): MOV R0, R0, 0H |
0462 | h(A0D00024): STR R0, SB, 24H |
0463 | i(40000000): MOV R0, R0, 0H |
0464 | i(A0D00028): STR R0, SB, 28H |
0465 | j(40000000): MOV R0, R0, 0H |
0466 | j(A0D0002C): STR R0, SB, 2CH |
0467 | k(80D00008): LDR R0, SB, 8H |
0468 | k(A0D00020): STR R0, SB, 20H |
| SYSTEM.PUT(list0, heapLim - heapOrg)l;m SYSTEM.PUT(list0+4,n -1);o SYSTEM.PUT(list0+8,p 0);q |
0469 | l(80D0000C): LDR R0, SB, CH |
046A | l(81D00008): LDR R1, SB, 8H |
046B | l(00090001): SUB R0, R0, R1 |
046C | m(81D00020): LDR R1, SB, 20H |
046D | m(A0100000): STR R0, R1, 0H |
046E | n(80D00020): LDR R0, SB, 20H |
046F | n(40080004): ADD R0, R0, 4H |
0470 | o(5100FFFF): MOV R1, R0, FFFFFFFFH |
0471 | o(A1000000): STR R1, R0, 0H |
0472 | p(80D00020): LDR R0, SB, 20H |
0473 | p(40080008): ADD R0, R0, 8H |
0474 | q(41000000): MOV R1, R0, 0H |
0475 | q(A1000000): STR R1, R0, 0H |
| allocated := 0;r clock := 0;s InitSecMap |
0476 | r(40000000): MOV R0, R0, 0H |
0477 | r(A0D00000): STR R0, SB, 0H |
0478 | s(40000000): MOV R0, R0, 0H |
0479 | s(A0D0001C): STR R0, SB, 1CH |
| ENDt Init; |
047A | t(F7FFFEC5): BL -315 [0340H] |
047B | t(8FE00000): LDR LNK, SP, 0H |
047C | t(4EE80004): ADD SP, SP, 4H |
047D | t(C700000F): B LNK |
| |
| ENDu Kernel.v |
047E | u .PROC 0 |
047E | u .ENTRYPOINT |
047E | u(4EE90004): SUB SP, SP, 4H |
047F | u(AFE00000): STR LNK, SP, 0H |
0480 | v(8FE00000): LDR LNK, SP, 0H |
0481 | v(4EE80004): ADD SP, SP, 4H |
0482 | v(C700000F): B LNK |