Home » Archimedes archive » Acorn User » AU 1996-12 B.adf » Regulars_2 » StarInfo/Clifford/!Macros/Documents/CodeFormat
StarInfo/Clifford/!Macros/Documents/CodeFormat
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1996-12 B.adf » Regulars_2 |
Filename: | StarInfo/Clifford/!Macros/Documents/CodeFormat |
Read OK: | ✔ |
File size: | 0949 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
Format of macro code ==================== +0 : A word containing &4544434D ("MCDE") +4 : Offset to name of code +8 : Offset to description, of same format as a module description +12: Offset to initialisation code (or 0 if none) +16: Offset to finalisation code (or 0 if none) +20: Offset to code for handling key presses (on entry r0 points to the parameters, or a null byte if none) All offsets are specified relative to first word. When the initialisation, finalisation, and key handling entry points are called, r10 is set up to point to a list of variables: +0 : Pointer to a 128 byte block containing one byte for each key. For instance, to check if key number 12 was pressed: ... ldr r0, [r10, #0] ; r0 = pointer to key block ldrb r1, [r0, #12] ; r1 = state of key 12 cmp r1, #1 bleq key_pressed blne key_not_pressed ... r11 is set up to point to a list of code entry points: +0 : Pointer to Find_Key_Name +4 : Pointer to Find_Key_Code +8 : Pointer to Call_MacroCode These can be called as follows: ... ; set up entry registers mov r14, pc ldr pc, [r11, #4] ; call Find_Key_Code ... ; rest of code Find_Key_Name ------------- This is used to translate a string containing a key name, such as "NumLock", into the corresponding internal key code. See PRM 1-156 for the Acorn keyboard layout (there are minor differences with the PC keyboards on the Risc PC). On entry: r0 : Pointer to key name, terminated by a character less than or equal to 32 (space) On exit: r0 : Pointer to character following the key name r1 : Internal key code, or -1 if not found all other registers are preserved Find_Key_Code ------------- This is used to translate an internal key code (see note above) into a key string. The string pointed to, if the code was found, is not terminated. On entry: r0 : Internal key code On exit: r0 : Pointer to non-terminated key string r1 : Length of key string (0 if key not found) all other registers preserved Call_MacroCode -------------- This can be used to call another code module to, for example, insert a string into the keyboard buffer. On entry: r0 : Pointer to name of macro code (terminated by a character less than or equal to 32) r1 : Pointer to parameters, or 0 if none On exit: all registers preserved v flag set if code not found
00000000 46 6f 72 6d 61 74 20 6f 66 20 6d 61 63 72 6f 20 |Format of macro | 00000010 63 6f 64 65 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d |code.===========| 00000020 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 09 2b 30 20 3a |=========...+0 :| 00000030 20 41 20 77 6f 72 64 20 63 6f 6e 74 61 69 6e 69 | A word containi| 00000040 6e 67 20 26 34 35 34 34 34 33 34 44 20 28 22 4d |ng &4544434D ("M| 00000050 43 44 45 22 29 0a 09 2b 34 20 3a 20 4f 66 66 73 |CDE")..+4 : Offs| 00000060 65 74 20 74 6f 20 6e 61 6d 65 20 6f 66 20 63 6f |et to name of co| 00000070 64 65 0a 09 2b 38 20 3a 20 4f 66 66 73 65 74 20 |de..+8 : Offset | 00000080 74 6f 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 |to description, | 00000090 6f 66 20 73 61 6d 65 20 66 6f 72 6d 61 74 20 61 |of same format a| 000000a0 73 20 61 20 6d 6f 64 75 6c 65 0a 09 20 20 20 20 |s a module.. | 000000b0 20 64 65 73 63 72 69 70 74 69 6f 6e 0a 09 2b 31 | description..+1| 000000c0 32 3a 20 4f 66 66 73 65 74 20 74 6f 20 69 6e 69 |2: Offset to ini| 000000d0 74 69 61 6c 69 73 61 74 69 6f 6e 20 63 6f 64 65 |tialisation code| 000000e0 20 28 6f 72 20 30 20 69 66 20 6e 6f 6e 65 29 0a | (or 0 if none).| 000000f0 09 2b 31 36 3a 20 4f 66 66 73 65 74 20 74 6f 20 |.+16: Offset to | 00000100 66 69 6e 61 6c 69 73 61 74 69 6f 6e 20 63 6f 64 |finalisation cod| 00000110 65 20 28 6f 72 20 30 20 69 66 20 6e 6f 6e 65 29 |e (or 0 if none)| 00000120 0a 09 2b 32 30 3a 20 4f 66 66 73 65 74 20 74 6f |..+20: Offset to| 00000130 20 63 6f 64 65 20 66 6f 72 20 68 61 6e 64 6c 69 | code for handli| 00000140 6e 67 20 6b 65 79 20 70 72 65 73 73 65 73 20 28 |ng key presses (| 00000150 6f 6e 20 65 6e 74 72 79 20 72 30 0a 09 20 20 20 |on entry r0.. | 00000160 20 20 70 6f 69 6e 74 73 20 74 6f 20 74 68 65 20 | points to the | 00000170 70 61 72 61 6d 65 74 65 72 73 2c 20 6f 72 20 61 |parameters, or a| 00000180 20 6e 75 6c 6c 20 62 79 74 65 20 69 66 20 6e 6f | null byte if no| 00000190 6e 65 29 0a 0a 41 6c 6c 20 6f 66 66 73 65 74 73 |ne)..All offsets| 000001a0 20 61 72 65 20 73 70 65 63 69 66 69 65 64 20 72 | are specified r| 000001b0 65 6c 61 74 69 76 65 20 74 6f 20 66 69 72 73 74 |elative to first| 000001c0 20 77 6f 72 64 2e 20 57 68 65 6e 20 74 68 65 0a | word. When the.| 000001d0 69 6e 69 74 69 61 6c 69 73 61 74 69 6f 6e 2c 20 |initialisation, | 000001e0 66 69 6e 61 6c 69 73 61 74 69 6f 6e 2c 20 61 6e |finalisation, an| 000001f0 64 20 6b 65 79 20 68 61 6e 64 6c 69 6e 67 20 65 |d key handling e| 00000200 6e 74 72 79 20 70 6f 69 6e 74 73 20 61 72 65 0a |ntry points are.| 00000210 63 61 6c 6c 65 64 2c 20 72 31 30 20 69 73 20 73 |called, r10 is s| 00000220 65 74 20 75 70 20 74 6f 20 70 6f 69 6e 74 20 74 |et up to point t| 00000230 6f 20 61 20 6c 69 73 74 20 6f 66 20 76 61 72 69 |o a list of vari| 00000240 61 62 6c 65 73 3a 0a 0a 09 2b 30 20 3a 20 50 6f |ables:...+0 : Po| 00000250 69 6e 74 65 72 20 74 6f 20 61 20 31 32 38 20 62 |inter to a 128 b| 00000260 79 74 65 20 62 6c 6f 63 6b 20 63 6f 6e 74 61 69 |yte block contai| 00000270 6e 69 6e 67 20 6f 6e 65 20 62 79 74 65 20 66 6f |ning one byte fo| 00000280 72 20 65 61 63 68 0a 09 20 20 20 20 20 6b 65 79 |r each.. key| 00000290 2e 20 46 6f 72 20 69 6e 73 74 61 6e 63 65 2c 20 |. For instance, | 000002a0 74 6f 20 63 68 65 63 6b 20 69 66 20 6b 65 79 20 |to check if key | 000002b0 6e 75 6d 62 65 72 20 31 32 20 77 61 73 0a 20 20 |number 12 was. | 000002c0 20 20 20 20 20 20 20 20 20 20 20 70 72 65 73 73 | press| 000002d0 65 64 3a 0a 0a 09 09 2e 2e 2e 0a 09 09 6c 64 72 |ed:..........ldr| 000002e0 09 72 30 2c 20 5b 72 31 30 2c 20 23 30 5d 09 3b |.r0, [r10, #0].;| 000002f0 20 72 30 20 3d 20 70 6f 69 6e 74 65 72 20 74 6f | r0 = pointer to| 00000300 20 6b 65 79 20 62 6c 6f 63 6b 0a 09 09 6c 64 72 | key block...ldr| 00000310 62 09 72 31 2c 20 5b 72 30 2c 20 23 31 32 5d 09 |b.r1, [r0, #12].| 00000320 3b 20 72 31 20 3d 20 73 74 61 74 65 20 6f 66 20 |; r1 = state of | 00000330 6b 65 79 20 31 32 0a 09 09 63 6d 70 09 72 31 2c |key 12...cmp.r1,| 00000340 20 23 31 0a 09 09 62 6c 65 71 09 6b 65 79 5f 70 | #1...bleq.key_p| 00000350 72 65 73 73 65 64 0a 09 09 62 6c 6e 65 09 6b 65 |ressed...blne.ke| 00000360 79 5f 6e 6f 74 5f 70 72 65 73 73 65 64 0a 09 09 |y_not_pressed...| 00000370 2e 2e 2e 0a 0a 72 31 31 20 69 73 20 73 65 74 20 |.....r11 is set | 00000380 75 70 20 74 6f 20 70 6f 69 6e 74 20 74 6f 20 61 |up to point to a| 00000390 20 6c 69 73 74 20 6f 66 20 63 6f 64 65 20 65 6e | list of code en| 000003a0 74 72 79 20 70 6f 69 6e 74 73 3a 0a 0a 09 2b 30 |try points:...+0| 000003b0 20 3a 20 50 6f 69 6e 74 65 72 20 74 6f 20 46 69 | : Pointer to Fi| 000003c0 6e 64 5f 4b 65 79 5f 4e 61 6d 65 0a 09 2b 34 20 |nd_Key_Name..+4 | 000003d0 3a 20 50 6f 69 6e 74 65 72 20 74 6f 20 46 69 6e |: Pointer to Fin| 000003e0 64 5f 4b 65 79 5f 43 6f 64 65 0a 09 2b 38 20 3a |d_Key_Code..+8 :| 000003f0 20 50 6f 69 6e 74 65 72 20 74 6f 20 43 61 6c 6c | Pointer to Call| 00000400 5f 4d 61 63 72 6f 43 6f 64 65 0a 0a 54 68 65 73 |_MacroCode..Thes| 00000410 65 20 63 61 6e 20 62 65 20 63 61 6c 6c 65 64 20 |e can be called | 00000420 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a 0a 09 09 2e |as follows:.....| 00000430 2e 2e 09 09 09 3b 20 73 65 74 20 75 70 20 65 6e |.....; set up en| 00000440 74 72 79 20 72 65 67 69 73 74 65 72 73 0a 09 09 |try registers...| 00000450 6d 6f 76 09 72 31 34 2c 20 70 63 0a 09 09 6c 64 |mov.r14, pc...ld| 00000460 72 09 70 63 2c 20 5b 72 31 31 2c 20 23 34 5d 09 |r.pc, [r11, #4].| 00000470 3b 20 63 61 6c 6c 20 46 69 6e 64 5f 4b 65 79 5f |; call Find_Key_| 00000480 43 6f 64 65 0a 09 09 2e 2e 2e 09 09 09 3b 20 72 |Code.........; r| 00000490 65 73 74 20 6f 66 20 63 6f 64 65 0a 0a 0a 46 69 |est of code...Fi| 000004a0 6e 64 5f 4b 65 79 5f 4e 61 6d 65 0a 2d 2d 2d 2d |nd_Key_Name.----| 000004b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 54 68 69 73 20 |---------..This | 000004c0 69 73 20 75 73 65 64 20 74 6f 20 74 72 61 6e 73 |is used to trans| 000004d0 6c 61 74 65 20 61 20 73 74 72 69 6e 67 20 63 6f |late a string co| 000004e0 6e 74 61 69 6e 69 6e 67 20 61 20 6b 65 79 20 6e |ntaining a key n| 000004f0 61 6d 65 2c 20 73 75 63 68 20 61 73 0a 22 4e 75 |ame, such as."Nu| 00000500 6d 4c 6f 63 6b 22 2c 20 69 6e 74 6f 20 74 68 65 |mLock", into the| 00000510 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 69 | corresponding i| 00000520 6e 74 65 72 6e 61 6c 20 6b 65 79 20 63 6f 64 65 |nternal key code| 00000530 2e 20 53 65 65 20 50 52 4d 20 31 2d 31 35 36 20 |. See PRM 1-156 | 00000540 66 6f 72 0a 74 68 65 20 41 63 6f 72 6e 20 6b 65 |for.the Acorn ke| 00000550 79 62 6f 61 72 64 20 6c 61 79 6f 75 74 20 28 74 |yboard layout (t| 00000560 68 65 72 65 20 61 72 65 20 6d 69 6e 6f 72 20 64 |here are minor d| 00000570 69 66 66 65 72 65 6e 63 65 73 20 77 69 74 68 20 |ifferences with | 00000580 74 68 65 20 50 43 0a 6b 65 79 62 6f 61 72 64 73 |the PC.keyboards| 00000590 20 6f 6e 20 74 68 65 20 52 69 73 63 20 50 43 29 | on the Risc PC)| 000005a0 2e 0a 0a 4f 6e 20 65 6e 74 72 79 3a 0a 09 72 30 |...On entry:..r0| 000005b0 20 3a 20 50 6f 69 6e 74 65 72 20 74 6f 20 6b 65 | : Pointer to ke| 000005c0 79 20 6e 61 6d 65 2c 20 74 65 72 6d 69 6e 61 74 |y name, terminat| 000005d0 65 64 20 62 79 20 61 20 63 68 61 72 61 63 74 65 |ed by a characte| 000005e0 72 20 6c 65 73 73 20 74 68 61 6e 0a 09 20 20 20 |r less than.. | 000005f0 20 20 6f 72 20 65 71 75 61 6c 20 74 6f 20 33 32 | or equal to 32| 00000600 20 28 73 70 61 63 65 29 0a 4f 6e 20 65 78 69 74 | (space).On exit| 00000610 3a 0a 09 72 30 20 3a 20 50 6f 69 6e 74 65 72 20 |:..r0 : Pointer | 00000620 74 6f 20 63 68 61 72 61 63 74 65 72 20 66 6f 6c |to character fol| 00000630 6c 6f 77 69 6e 67 20 74 68 65 20 6b 65 79 20 6e |lowing the key n| 00000640 61 6d 65 0a 09 72 31 20 3a 20 49 6e 74 65 72 6e |ame..r1 : Intern| 00000650 61 6c 20 6b 65 79 20 63 6f 64 65 2c 20 6f 72 20 |al key code, or | 00000660 2d 31 20 69 66 20 6e 6f 74 20 66 6f 75 6e 64 0a |-1 if not found.| 00000670 09 61 6c 6c 20 6f 74 68 65 72 20 72 65 67 69 73 |.all other regis| 00000680 74 65 72 73 20 61 72 65 20 70 72 65 73 65 72 76 |ters are preserv| 00000690 65 64 0a 0a 0a 46 69 6e 64 5f 4b 65 79 5f 43 6f |ed...Find_Key_Co| 000006a0 64 65 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |de.-------------| 000006b0 0a 0a 54 68 69 73 20 69 73 20 75 73 65 64 20 74 |..This is used t| 000006c0 6f 20 74 72 61 6e 73 6c 61 74 65 20 61 6e 20 69 |o translate an i| 000006d0 6e 74 65 72 6e 61 6c 20 6b 65 79 20 63 6f 64 65 |nternal key code| 000006e0 20 28 73 65 65 20 6e 6f 74 65 20 61 62 6f 76 65 | (see note above| 000006f0 29 20 69 6e 74 6f 20 61 0a 6b 65 79 20 73 74 72 |) into a.key str| 00000700 69 6e 67 2e 20 54 68 65 20 73 74 72 69 6e 67 20 |ing. The string | 00000710 70 6f 69 6e 74 65 64 20 74 6f 2c 20 69 66 20 74 |pointed to, if t| 00000720 68 65 20 63 6f 64 65 20 77 61 73 20 66 6f 75 6e |he code was foun| 00000730 64 2c 20 69 73 20 6e 6f 74 0a 74 65 72 6d 69 6e |d, is not.termin| 00000740 61 74 65 64 2e 0a 0a 4f 6e 20 65 6e 74 72 79 3a |ated...On entry:| 00000750 0a 09 72 30 20 3a 20 49 6e 74 65 72 6e 61 6c 20 |..r0 : Internal | 00000760 6b 65 79 20 63 6f 64 65 0a 4f 6e 20 65 78 69 74 |key code.On exit| 00000770 3a 0a 09 72 30 20 3a 20 50 6f 69 6e 74 65 72 20 |:..r0 : Pointer | 00000780 74 6f 20 6e 6f 6e 2d 74 65 72 6d 69 6e 61 74 65 |to non-terminate| 00000790 64 20 6b 65 79 20 73 74 72 69 6e 67 0a 09 72 31 |d key string..r1| 000007a0 20 3a 20 4c 65 6e 67 74 68 20 6f 66 20 6b 65 79 | : Length of key| 000007b0 20 73 74 72 69 6e 67 20 28 30 20 69 66 20 6b 65 | string (0 if ke| 000007c0 79 20 6e 6f 74 20 66 6f 75 6e 64 29 0a 09 61 6c |y not found)..al| 000007d0 6c 20 6f 74 68 65 72 20 72 65 67 69 73 74 65 72 |l other register| 000007e0 73 20 70 72 65 73 65 72 76 65 64 0a 0a 0a 43 61 |s preserved...Ca| 000007f0 6c 6c 5f 4d 61 63 72 6f 43 6f 64 65 0a 2d 2d 2d |ll_MacroCode.---| 00000800 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 54 68 69 |-----------..Thi| 00000810 73 20 63 61 6e 20 62 65 20 75 73 65 64 20 74 6f |s can be used to| 00000820 20 63 61 6c 6c 20 61 6e 6f 74 68 65 72 20 63 6f | call another co| 00000830 64 65 20 6d 6f 64 75 6c 65 20 74 6f 2c 20 66 6f |de module to, fo| 00000840 72 20 65 78 61 6d 70 6c 65 2c 20 69 6e 73 65 72 |r example, inser| 00000850 74 20 61 0a 73 74 72 69 6e 67 20 69 6e 74 6f 20 |t a.string into | 00000860 74 68 65 20 6b 65 79 62 6f 61 72 64 20 62 75 66 |the keyboard buf| 00000870 66 65 72 2e 0a 0a 4f 6e 20 65 6e 74 72 79 3a 0a |fer...On entry:.| 00000880 09 72 30 20 3a 20 50 6f 69 6e 74 65 72 20 74 6f |.r0 : Pointer to| 00000890 20 6e 61 6d 65 20 6f 66 20 6d 61 63 72 6f 20 63 | name of macro c| 000008a0 6f 64 65 20 28 74 65 72 6d 69 6e 61 74 65 64 20 |ode (terminated | 000008b0 62 79 20 61 20 63 68 61 72 61 63 74 65 72 0a 09 |by a character..| 000008c0 20 20 20 20 20 6c 65 73 73 20 74 68 61 6e 20 6f | less than o| 000008d0 72 20 65 71 75 61 6c 20 74 6f 20 33 32 29 0a 09 |r equal to 32)..| 000008e0 72 31 20 3a 20 50 6f 69 6e 74 65 72 20 74 6f 20 |r1 : Pointer to | 000008f0 70 61 72 61 6d 65 74 65 72 73 2c 20 6f 72 20 30 |parameters, or 0| 00000900 20 69 66 20 6e 6f 6e 65 0a 4f 6e 20 65 78 69 74 | if none.On exit| 00000910 3a 0a 09 61 6c 6c 20 72 65 67 69 73 74 65 72 73 |:..all registers| 00000920 20 70 72 65 73 65 72 76 65 64 0a 09 76 20 66 6c | preserved..v fl| 00000930 61 67 20 73 65 74 20 69 66 20 63 6f 64 65 20 6e |ag set if code n| 00000940 6f 74 20 66 6f 75 6e 64 0a |ot found.| 00000949