Home » Archimedes archive » Archimedes World » AW_Vol15_Issue7 CD ROM Index Disc.adf » coders » vsn2/s/macros1
vsn2/s/macros1
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 » Archimedes World » AW_Vol15_Issue7 CD ROM Index Disc.adf » coders |
Filename: | vsn2/s/macros1 |
Read OK: | ✔ |
File size: | 2376 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
; ; W A R N I N G ; ============= ; ; Macros mul16 and mul16c must only be assembled within code run in USER mode, ; otherwise they will corrupt the processor mode when their code is executed. ; This occurs because they use a TEQP instruction to force storage of the sign ; of the result within the PSR (V bit) - when run in non-user mode this will also ; affect the I, F & mode flags, in addition to the desired change to the condition flags. ; ; rbbc ; Reverse Bit Binary Counter. ; A macro to increment a register according to a reverse bit binary count. ; It takes four parameters, each of which should be a register name. ; ; $r: holds value to be rbbc incremented. Will be modified ; $k: k is st k-1=bit # (1 to 31) of msb in register (lsb in rbbc) (thence old w=3*(32-k)). ; $e: scratch register used to hold an address in the code ; MACRO $label rbbc $r, $k, $e ASSERT $r <> $k ASSERT $r <> $e ASSERT $k <> $e LCLA counter counter SETA 31 $label RSB $k, $k, #32 RSB $k, $k, $k, ASL #2 ADD $e, pc, $k, ASL #2 ;this relys on there being exactly one instruction between here & TST MOV pc, $e WHILE counter > 1 TST $r, #1<<counter EOR $r, $r, #1<<counter BEQ %ft0 counter SETA counter-1 WEND TST $r, #1<<1 EOR $r, $r, #1<<1 EORNE $r, $r, #1<<0 ;nb an rbbc carry will automatically cause a wrap around back to zero 0 MEND ; div16 ; assumes abs number < 65536 * abs divisor. ; calculates integer part of 65536*number/divisor, as a signed 32 bit number. ; used in matrix inversion routine where it is necessary to divide two fixed point numbers (16 bit fraction). ; if range check on above assumption is required, the caller must perform it. ; It takes 5 parameters - all register names. ; ; $number: number ; $divisor: divisor - sign of divisor may be corrupted ; $num: scratch & result - may be the same as $number ; $sign: scratch ; $rem: scratch ; MACRO $label div16 $number, $divisor, $num, $sign, $rem ASSERT $num <> $divisor ASSERT $num <> $sign ASSERT $num <> $rem ASSERT $number <> $divisor ASSERT $number <> $sign ASSERT $number <> $rem ASSERT $divisor <> $sign ASSERT $divisor <> $rem ASSERT $sign <> $rem LCLA counter counter SETA 32 $label MOVS $rem, $divisor, LSL #1 RSBCS $divisor, $divisor, #0 ADC $sign, $sign, $sign ;1st 3 instructions allow setting of low bit sign as either 0 ;or 1 according to sign of divisor, in only 1 instruction. TEQ $number, #0 RSBMI $num, $number, #0 [ $num <> $number MOVPL $num, $number ;only assemble this case if regs different, as is otherwise a nop. ] EORMI $sign, $sign, #1 MOV $rem, $num, LSR #16 MOV $num, $num, LSL #16 WHILE counter > 0 ;unwound loop uses about 600 bytes extra memory MOVS $num, $num, ASL #1 ;speed increase (ARM3) from about 1.27e-5 to .75e-5 seconds ADC $rem, $rem, $rem CMP $rem, $divisor SUBHS $rem, $rem, $divisor ORRHS $num, $num, #1 counter SETA counter-1 WEND CMP $rem, $divisor, ASR #1 ADDGE $num, $num, #1 TST $sign, #1 RSBNE $num, $num, #0 MEND ; mul16 ; multiplication of an integer x by a 16-bit fixed point number a, with no restrictions on x or a ; other than that x*a/65536 must fit into a signed 32-bit representation. ; calculates r=x*a/65536 ; It takes 6 parameters - all register names. ; ; $x: x ; $a: a - a will be corrupted ; $r: result - may be the same as $x ; $u: scratch ; $v: scratch ; $w: scratch ; MACRO $label mul16 $x, $a, $r, $u, $v, $w ASSERT $r <> $a ASSERT $r <> $u ASSERT $r <> $v ASSERT $r <> $w ASSERT $x <> $a ASSERT $x <> $u ASSERT $x <> $v ASSERT $x <> $w ASSERT $a <> $u ASSERT $a <> $v ASSERT $a <> $w ASSERT $u <> $v ASSERT $u <> $w ASSERT $v <> $w $label MOVS $w, $a, LSL #1 RSBCS $a, $a, #0 TEQ $x, #0 RSBMI $r, $x, #0 [ $r <> $x MOVPL $r, $x ] ;now have C bit set iff a<0, N bit set iff x<0 MOV $w, pc, LSR #31 MOV $w, $w, LSL #28 ;get w=(2^28)*N {N is b31, V is b28, C is b29 in pc/psr} TEQP $w, pc, LSR #1 ;EOR w into pc/psr {ie N EOR C is put into V} - this is a way of storing ;sign of result in overflow flag, saving on a register MOV $w, $r, LSR #16 BIC $r, $r, $w, LSL #16 MOV $v, $a, LSR #16 BIC $a, $a, $v, LSL #16 MUL $u, $a, $r TST $u, #1<<15 ;notice this is the only operation altering psr & that it will not corrupt V ;note it will corrupt C, as immediate operand 32768 requires a shift MOV $u, $u, LSR #16 ADDNE $u, $u, #1 MLA $u, $r, $v, $u ;6/9/94 - reverse v & r to optimise for argument a small MLA $u, $a, $w, $u MUL $r, $w, $v ;6/9/94 - reverse v & w to optimise for argument a small ADD $r, $u, $r, LSL #16 RSBVS $r, $r, #0 MEND ; mul16c ; multiplication of an integer x by a 16-bit fixed point number a, where a is a contraction ; ie calculates r=x*a/65536, assuming: abs a < 65536 ; if the possibility exists that a>=65536, caller should check this & either not call routine, or set a=65535 ; It takes 4 parameters - all register names. ; ; $x: x ; $a: a - require abs a <65536, a will be corrupted ; $r: result - may be the same as $x ; $w: scratch ; MACRO $label mul16c $x, $a, $r, $w ASSERT $r <> $a ASSERT $r <> $w ASSERT $x <> $a ASSERT $x <> $w ASSERT $a <> $w $label MOVS $w, $a, LSL #1 RSBCS $a, $a, #0 TEQ $x, #0 RSBMI $r, $x, #0 [ $r <> $x MOVPL $r, $x ] MOV $w, pc, LSR #31 ;see mul16 above, for comments re this part MOV $w, $w, LSL #28 TEQP $w, pc, LSR #1 TST $a, #1<<16 ;bodge to allow code to function if $a is upto 2*65536-1 MOVNE $r, $r, LSL #1 ;can occur in a contractive fn due to change of coordinates to handle 1x2 pixel aspect ratio MOVNE $a, $a, LSR #1 ;change made 3/4/94 - estimate overhead to ria of upto 3% MOV $w, $r, LSR #16 BIC $r, $r, $w, LSL #16 MUL $r, $a, $r TST $r, #1<<15 ;remember, can't use movs r,r,lsr #16, as this would corrupt V, which is storing sign of result MOV $r, $r, LSR #16 ADDNE $r, $r, #1 MLA $r, $a, $w, $r RSBVS $r, $r, #0 MEND ; sqrt16 ; integer square root returning 16-bit fixed point number, assuming x is 16-bit fixed point ; ie returns sqrt(x<<16) ; It takes 6 parameters - all register names ; ; $x: x ; $r: result - may be the same as x ; $n: copy of x used during calculation ; $t: transient scratch ; $d: remainder ; $o: constant value of 1 ; MACRO $label sqrt16 $x, $r, $n, $t, $d, $o ASSERT $x <> $n ASSERT $x <> $t ASSERT $x <> $d ASSERT $x <> $o ASSERT $n <> $t ASSERT $n <> $d ASSERT $n <> $o ASSERT $t <> $d ASSERT $t <> $o ASSERT $d <> $o LCLA counter $label MOV $n, $x MOV $o, #1 MOV $x, #0 MOV $d, #0 AND $t, $n, #(3<<30) MOV $t, $t, LSR #30 ORR $d, $d, $t ADD $t, $o, $x, LSL #1 CMP $d, $t SUBGE $d, $d, $t ADDGE $x, $x, #1 counter SETA 28 WHILE counter < 32 ;want >= 0, however counter is unsigned, so after 0 it goes high, thus < 32 will catch it! MOV $x, $x, LSL #1 MOV $d, $d, LSL #2 AND $t, $n, #(3<<counter) [ counter <> 0 MOV $t, $t, LSR #counter ] ORR $d, $d, $t ADD $t, $o, $x, LSL #1 CMP $d, $t SUBGE $d, $d, $t ADDGE $x, $x, #1 counter SETA counter-2 WEND counter SETA 14 WHILE counter < 32 MOV $x, $x, LSL #1 MOV $d, $d, LSL #2 ADD $t, $o, $x, LSL #1 CMP $d, $t SUBGE $d, $d, $t ADDGE $x, $x, #1 counter SETA counter-2 WEND [ $r <> $x MOV $r, $x ] MEND END
00000000 3b 0a 3b 20 57 20 41 20 52 20 4e 20 49 20 4e 20 |;.; W A R N I N | 00000010 47 0a 3b 20 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d |G.; ============| 00000020 3d 0a 3b 0a 3b 20 4d 61 63 72 6f 73 20 6d 75 6c |=.;.; Macros mul| 00000030 31 36 20 61 6e 64 20 6d 75 6c 31 36 63 20 6d 75 |16 and mul16c mu| 00000040 73 74 20 6f 6e 6c 79 20 62 65 20 61 73 73 65 6d |st only be assem| 00000050 62 6c 65 64 20 77 69 74 68 69 6e 20 63 6f 64 65 |bled within code| 00000060 20 72 75 6e 20 69 6e 20 55 53 45 52 20 6d 6f 64 | run in USER mod| 00000070 65 2c 0a 3b 20 6f 74 68 65 72 77 69 73 65 20 74 |e,.; otherwise t| 00000080 68 65 79 20 77 69 6c 6c 20 63 6f 72 72 75 70 74 |hey will corrupt| 00000090 20 74 68 65 20 70 72 6f 63 65 73 73 6f 72 20 6d | the processor m| 000000a0 6f 64 65 20 77 68 65 6e 20 74 68 65 69 72 20 63 |ode when their c| 000000b0 6f 64 65 20 69 73 20 65 78 65 63 75 74 65 64 2e |ode is executed.| 000000c0 0a 3b 20 54 68 69 73 20 6f 63 63 75 72 73 20 62 |.; This occurs b| 000000d0 65 63 61 75 73 65 20 74 68 65 79 20 75 73 65 20 |ecause they use | 000000e0 61 20 54 45 51 50 20 69 6e 73 74 72 75 63 74 69 |a TEQP instructi| 000000f0 6f 6e 20 74 6f 20 66 6f 72 63 65 20 73 74 6f 72 |on to force stor| 00000100 61 67 65 20 6f 66 20 74 68 65 20 73 69 67 6e 0a |age of the sign.| 00000110 3b 20 6f 66 20 74 68 65 20 72 65 73 75 6c 74 20 |; of the result | 00000120 77 69 74 68 69 6e 20 74 68 65 20 50 53 52 20 28 |within the PSR (| 00000130 56 20 62 69 74 29 20 2d 20 77 68 65 6e 20 72 75 |V bit) - when ru| 00000140 6e 20 69 6e 20 6e 6f 6e 2d 75 73 65 72 20 6d 6f |n in non-user mo| 00000150 64 65 20 74 68 69 73 20 77 69 6c 6c 20 61 6c 73 |de this will als| 00000160 6f 0a 3b 20 61 66 66 65 63 74 20 74 68 65 20 49 |o.; affect the I| 00000170 2c 20 46 20 26 20 6d 6f 64 65 20 66 6c 61 67 73 |, F & mode flags| 00000180 2c 20 69 6e 20 61 64 64 69 74 69 6f 6e 20 74 6f |, in addition to| 00000190 20 74 68 65 20 64 65 73 69 72 65 64 20 63 68 61 | the desired cha| 000001a0 6e 67 65 20 74 6f 20 74 68 65 20 63 6f 6e 64 69 |nge to the condi| 000001b0 74 69 6f 6e 20 66 6c 61 67 73 2e 0a 3b 0a 0a 3b |tion flags..;..;| 000001c0 20 72 62 62 63 0a 3b 20 52 65 76 65 72 73 65 20 | rbbc.; Reverse | 000001d0 42 69 74 20 42 69 6e 61 72 79 20 43 6f 75 6e 74 |Bit Binary Count| 000001e0 65 72 2e 0a 3b 20 41 20 6d 61 63 72 6f 20 74 6f |er..; A macro to| 000001f0 20 69 6e 63 72 65 6d 65 6e 74 20 61 20 72 65 67 | increment a reg| 00000200 69 73 74 65 72 20 61 63 63 6f 72 64 69 6e 67 20 |ister according | 00000210 74 6f 20 61 20 72 65 76 65 72 73 65 20 62 69 74 |to a reverse bit| 00000220 20 62 69 6e 61 72 79 20 63 6f 75 6e 74 2e 0a 3b | binary count..;| 00000230 20 49 74 20 74 61 6b 65 73 20 66 6f 75 72 20 70 | It takes four p| 00000240 61 72 61 6d 65 74 65 72 73 2c 20 65 61 63 68 20 |arameters, each | 00000250 6f 66 20 77 68 69 63 68 20 73 68 6f 75 6c 64 20 |of which should | 00000260 62 65 20 61 20 72 65 67 69 73 74 65 72 20 6e 61 |be a register na| 00000270 6d 65 2e 0a 3b 0a 3b 20 24 72 3a 20 20 20 68 6f |me..;.; $r: ho| 00000280 6c 64 73 20 76 61 6c 75 65 20 74 6f 20 62 65 20 |lds value to be | 00000290 72 62 62 63 20 69 6e 63 72 65 6d 65 6e 74 65 64 |rbbc incremented| 000002a0 2e 20 57 69 6c 6c 20 62 65 20 6d 6f 64 69 66 69 |. Will be modifi| 000002b0 65 64 0a 3b 20 24 6b 3a 20 20 20 6b 20 69 73 20 |ed.; $k: k is | 000002c0 73 74 20 6b 2d 31 3d 62 69 74 20 23 20 28 31 20 |st k-1=bit # (1 | 000002d0 74 6f 20 33 31 29 20 6f 66 20 6d 73 62 20 69 6e |to 31) of msb in| 000002e0 20 72 65 67 69 73 74 65 72 20 28 6c 73 62 20 69 | register (lsb i| 000002f0 6e 20 72 62 62 63 29 20 28 74 68 65 6e 63 65 20 |n rbbc) (thence | 00000300 6f 6c 64 20 77 3d 33 2a 28 33 32 2d 6b 29 29 2e |old w=3*(32-k)).| 00000310 0a 3b 20 24 65 3a 20 20 20 73 63 72 61 74 63 68 |.; $e: scratch| 00000320 20 72 65 67 69 73 74 65 72 20 75 73 65 64 20 74 | register used t| 00000330 6f 20 68 6f 6c 64 20 61 6e 20 61 64 64 72 65 73 |o hold an addres| 00000340 73 20 69 6e 20 74 68 65 20 63 6f 64 65 0a 3b 0a |s in the code.;.| 00000350 20 20 20 20 20 20 20 20 4d 41 43 52 4f 0a 24 6c | MACRO.$l| 00000360 61 62 65 6c 20 20 72 62 62 63 20 20 20 20 24 72 |abel rbbc $r| 00000370 2c 20 24 6b 2c 20 24 65 0a 0a 20 20 20 20 20 20 |, $k, $e.. | 00000380 20 20 41 53 53 45 52 54 20 20 24 72 20 3c 3e 20 | ASSERT $r <> | 00000390 24 6b 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 |$k. ASSER| 000003a0 54 20 20 24 72 20 3c 3e 20 24 65 0a 20 20 20 20 |T $r <> $e. | 000003b0 20 20 20 20 41 53 53 45 52 54 20 20 24 6b 20 3c | ASSERT $k <| 000003c0 3e 20 24 65 0a 0a 20 20 20 20 20 20 20 20 4c 43 |> $e.. LC| 000003d0 4c 41 20 20 20 20 63 6f 75 6e 74 65 72 0a 63 6f |LA counter.co| 000003e0 75 6e 74 65 72 20 53 45 54 41 20 20 20 20 33 31 |unter SETA 31| 000003f0 0a 0a 24 6c 61 62 65 6c 09 52 53 42 09 24 6b 2c |..$label.RSB.$k,| 00000400 20 24 6b 2c 20 23 33 32 0a 09 52 53 42 09 24 6b | $k, #32..RSB.$k| 00000410 2c 20 24 6b 2c 20 24 6b 2c 20 41 53 4c 20 23 32 |, $k, $k, ASL #2| 00000420 0a 09 41 44 44 20 20 20 20 20 24 65 2c 20 70 63 |..ADD $e, pc| 00000430 2c 20 24 6b 2c 20 41 53 4c 20 23 32 20 20 20 20 |, $k, ASL #2 | 00000440 20 20 3b 74 68 69 73 20 72 65 6c 79 73 20 6f 6e | ;this relys on| 00000450 20 74 68 65 72 65 20 62 65 69 6e 67 20 65 78 61 | there being exa| 00000460 63 74 6c 79 20 6f 6e 65 20 69 6e 73 74 72 75 63 |ctly one instruc| 00000470 74 69 6f 6e 20 62 65 74 77 65 65 6e 20 68 65 72 |tion between her| 00000480 65 20 26 20 54 53 54 0a 20 20 20 20 20 20 20 20 |e & TST. | 00000490 4d 4f 56 20 20 20 20 20 70 63 2c 20 24 65 0a 0a |MOV pc, $e..| 000004a0 20 20 20 20 20 20 20 20 57 48 49 4c 45 20 20 20 | WHILE | 000004b0 63 6f 75 6e 74 65 72 20 3e 20 31 0a 20 20 20 20 |counter > 1. | 000004c0 20 20 20 20 54 53 54 20 20 20 20 20 24 72 2c 20 | TST $r, | 000004d0 23 31 3c 3c 63 6f 75 6e 74 65 72 0a 20 20 20 20 |#1<<counter. | 000004e0 20 20 20 20 45 4f 52 20 20 20 20 20 24 72 2c 20 | EOR $r, | 000004f0 24 72 2c 20 23 31 3c 3c 63 6f 75 6e 74 65 72 0a |$r, #1<<counter.| 00000500 20 20 20 20 20 20 20 20 42 45 51 20 20 20 20 20 | BEQ | 00000510 25 66 74 30 0a 63 6f 75 6e 74 65 72 20 53 45 54 |%ft0.counter SET| 00000520 41 20 20 20 20 63 6f 75 6e 74 65 72 2d 31 0a 20 |A counter-1. | 00000530 20 20 20 20 20 20 20 57 45 4e 44 0a 0a 20 20 20 | WEND.. | 00000540 20 20 20 20 20 54 53 54 20 20 20 20 20 24 72 2c | TST $r,| 00000550 20 23 31 3c 3c 31 0a 20 20 20 20 20 20 20 20 45 | #1<<1. E| 00000560 4f 52 20 20 20 20 20 24 72 2c 20 24 72 2c 20 23 |OR $r, $r, #| 00000570 31 3c 3c 31 0a 20 20 20 20 20 20 20 20 45 4f 52 |1<<1. EOR| 00000580 4e 45 20 20 20 24 72 2c 20 24 72 2c 20 23 31 3c |NE $r, $r, #1<| 00000590 3c 30 20 20 20 20 20 20 20 20 20 20 20 3b 6e 62 |<0 ;nb| 000005a0 20 61 6e 20 72 62 62 63 20 63 61 72 72 79 20 77 | an rbbc carry w| 000005b0 69 6c 6c 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c |ill automaticall| 000005c0 79 20 63 61 75 73 65 20 61 20 77 72 61 70 20 61 |y cause a wrap a| 000005d0 72 6f 75 6e 64 20 62 61 63 6b 20 74 6f 20 7a 65 |round back to ze| 000005e0 72 6f 0a 0a 30 0a 0a 20 20 20 20 20 20 20 20 4d |ro..0.. M| 000005f0 45 4e 44 0a 0a 0a 0a 3b 20 64 69 76 31 36 0a 3b |END....; div16.;| 00000600 20 61 73 73 75 6d 65 73 20 61 62 73 20 6e 75 6d | assumes abs num| 00000610 62 65 72 20 3c 20 36 35 35 33 36 20 2a 20 61 62 |ber < 65536 * ab| 00000620 73 20 64 69 76 69 73 6f 72 2e 0a 3b 20 63 61 6c |s divisor..; cal| 00000630 63 75 6c 61 74 65 73 20 69 6e 74 65 67 65 72 20 |culates integer | 00000640 70 61 72 74 20 6f 66 20 36 35 35 33 36 2a 6e 75 |part of 65536*nu| 00000650 6d 62 65 72 2f 64 69 76 69 73 6f 72 2c 20 61 73 |mber/divisor, as| 00000660 20 61 20 73 69 67 6e 65 64 20 33 32 20 62 69 74 | a signed 32 bit| 00000670 20 6e 75 6d 62 65 72 2e 0a 3b 20 75 73 65 64 20 | number..; used | 00000680 69 6e 20 6d 61 74 72 69 78 20 69 6e 76 65 72 73 |in matrix invers| 00000690 69 6f 6e 20 72 6f 75 74 69 6e 65 20 77 68 65 72 |ion routine wher| 000006a0 65 20 69 74 20 69 73 20 6e 65 63 65 73 73 61 72 |e it is necessar| 000006b0 79 20 74 6f 20 64 69 76 69 64 65 20 74 77 6f 20 |y to divide two | 000006c0 66 69 78 65 64 20 70 6f 69 6e 74 20 6e 75 6d 62 |fixed point numb| 000006d0 65 72 73 20 28 31 36 20 62 69 74 20 66 72 61 63 |ers (16 bit frac| 000006e0 74 69 6f 6e 29 2e 0a 3b 20 69 66 20 72 61 6e 67 |tion)..; if rang| 000006f0 65 20 63 68 65 63 6b 20 6f 6e 20 61 62 6f 76 65 |e check on above| 00000700 20 61 73 73 75 6d 70 74 69 6f 6e 20 69 73 20 72 | assumption is r| 00000710 65 71 75 69 72 65 64 2c 20 74 68 65 20 63 61 6c |equired, the cal| 00000720 6c 65 72 20 6d 75 73 74 20 70 65 72 66 6f 72 6d |ler must perform| 00000730 20 69 74 2e 0a 3b 20 49 74 20 74 61 6b 65 73 20 | it..; It takes | 00000740 35 20 70 61 72 61 6d 65 74 65 72 73 20 2d 20 61 |5 parameters - a| 00000750 6c 6c 20 72 65 67 69 73 74 65 72 20 6e 61 6d 65 |ll register name| 00000760 73 2e 0a 3b 0a 3b 20 24 6e 75 6d 62 65 72 3a 20 |s..;.; $number: | 00000770 20 20 20 20 20 6e 75 6d 62 65 72 0a 3b 20 24 64 | number.; $d| 00000780 69 76 69 73 6f 72 3a 20 20 20 20 20 64 69 76 69 |ivisor: divi| 00000790 73 6f 72 20 2d 20 73 69 67 6e 20 6f 66 20 64 69 |sor - sign of di| 000007a0 76 69 73 6f 72 20 6d 61 79 20 62 65 20 63 6f 72 |visor may be cor| 000007b0 72 75 70 74 65 64 0a 3b 20 24 6e 75 6d 3a 20 20 |rupted.; $num: | 000007c0 20 20 20 20 20 20 20 73 63 72 61 74 63 68 20 26 | scratch &| 000007d0 20 72 65 73 75 6c 74 20 2d 20 6d 61 79 20 62 65 | result - may be| 000007e0 20 74 68 65 20 73 61 6d 65 20 61 73 20 24 6e 75 | the same as $nu| 000007f0 6d 62 65 72 0a 3b 20 24 73 69 67 6e 3a 20 20 20 |mber.; $sign: | 00000800 20 20 20 20 20 73 63 72 61 74 63 68 0a 3b 20 24 | scratch.; $| 00000810 72 65 6d 3a 20 20 20 20 20 20 20 20 20 73 63 72 |rem: scr| 00000820 61 74 63 68 0a 3b 0a 20 20 20 20 20 20 20 20 4d |atch.;. M| 00000830 41 43 52 4f 0a 24 6c 61 62 65 6c 20 20 64 69 76 |ACRO.$label div| 00000840 31 36 20 20 20 24 6e 75 6d 62 65 72 2c 20 24 64 |16 $number, $d| 00000850 69 76 69 73 6f 72 2c 20 24 6e 75 6d 2c 20 24 73 |ivisor, $num, $s| 00000860 69 67 6e 2c 20 24 72 65 6d 0a 0a 20 20 20 20 20 |ign, $rem.. | 00000870 20 20 20 41 53 53 45 52 54 20 20 24 6e 75 6d 20 | ASSERT $num | 00000880 3c 3e 20 24 64 69 76 69 73 6f 72 0a 20 20 20 20 |<> $divisor. | 00000890 20 20 20 20 41 53 53 45 52 54 20 20 24 6e 75 6d | ASSERT $num| 000008a0 20 3c 3e 20 24 73 69 67 6e 0a 20 20 20 20 20 20 | <> $sign. | 000008b0 20 20 41 53 53 45 52 54 20 20 24 6e 75 6d 20 3c | ASSERT $num <| 000008c0 3e 20 24 72 65 6d 0a 20 20 20 20 20 20 20 20 41 |> $rem. A| 000008d0 53 53 45 52 54 20 20 24 6e 75 6d 62 65 72 20 3c |SSERT $number <| 000008e0 3e 20 24 64 69 76 69 73 6f 72 0a 20 20 20 20 20 |> $divisor. | 000008f0 20 20 20 41 53 53 45 52 54 20 20 24 6e 75 6d 62 | ASSERT $numb| 00000900 65 72 20 3c 3e 20 24 73 69 67 6e 0a 20 20 20 20 |er <> $sign. | 00000910 20 20 20 20 41 53 53 45 52 54 20 20 24 6e 75 6d | ASSERT $num| 00000920 62 65 72 20 3c 3e 20 24 72 65 6d 0a 20 20 20 20 |ber <> $rem. | 00000930 20 20 20 20 41 53 53 45 52 54 20 20 24 64 69 76 | ASSERT $div| 00000940 69 73 6f 72 20 3c 3e 20 24 73 69 67 6e 0a 20 20 |isor <> $sign. | 00000950 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 64 | ASSERT $d| 00000960 69 76 69 73 6f 72 20 3c 3e 20 24 72 65 6d 0a 20 |ivisor <> $rem. | 00000970 20 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 | ASSERT $| 00000980 73 69 67 6e 20 3c 3e 20 24 72 65 6d 0a 0a 20 20 |sign <> $rem.. | 00000990 20 20 20 20 20 20 4c 43 4c 41 20 20 20 20 63 6f | LCLA co| 000009a0 75 6e 74 65 72 0a 63 6f 75 6e 74 65 72 20 53 45 |unter.counter SE| 000009b0 54 41 20 20 20 20 33 32 0a 0a 24 6c 61 62 65 6c |TA 32..$label| 000009c0 20 20 4d 4f 56 53 20 20 20 20 24 72 65 6d 2c 20 | MOVS $rem, | 000009d0 24 64 69 76 69 73 6f 72 2c 20 4c 53 4c 20 23 31 |$divisor, LSL #1| 000009e0 0a 20 20 20 20 20 20 20 20 52 53 42 43 53 20 20 |. RSBCS | 000009f0 20 24 64 69 76 69 73 6f 72 2c 20 24 64 69 76 69 | $divisor, $divi| 00000a00 73 6f 72 2c 20 23 30 0a 20 20 20 20 20 20 20 20 |sor, #0. | 00000a10 41 44 43 20 20 20 20 20 24 73 69 67 6e 2c 20 24 |ADC $sign, $| 00000a20 73 69 67 6e 2c 20 24 73 69 67 6e 20 20 20 20 20 |sign, $sign | 00000a30 20 20 20 20 20 20 20 20 3b 31 73 74 20 33 20 69 | ;1st 3 i| 00000a40 6e 73 74 72 75 63 74 69 6f 6e 73 20 61 6c 6c 6f |nstructions allo| 00000a50 77 20 73 65 74 74 69 6e 67 20 6f 66 20 6c 6f 77 |w setting of low| 00000a60 20 62 69 74 20 73 69 67 6e 20 61 73 20 65 69 74 | bit sign as eit| 00000a70 68 65 72 20 30 0a 20 20 20 20 20 20 20 20 20 20 |her 0. | 00000a80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000aa0 20 20 20 20 20 20 3b 6f 72 20 31 20 61 63 63 6f | ;or 1 acco| 00000ab0 72 64 69 6e 67 20 74 6f 20 73 69 67 6e 20 6f 66 |rding to sign of| 00000ac0 20 64 69 76 69 73 6f 72 2c 20 69 6e 20 6f 6e 6c | divisor, in onl| 00000ad0 79 20 31 20 69 6e 73 74 72 75 63 74 69 6f 6e 2e |y 1 instruction.| 00000ae0 0a 20 20 20 20 20 20 20 20 54 45 51 20 20 20 20 |. TEQ | 00000af0 20 24 6e 75 6d 62 65 72 2c 20 23 30 0a 20 20 20 | $number, #0. | 00000b00 20 20 20 20 20 52 53 42 4d 49 20 20 20 24 6e 75 | RSBMI $nu| 00000b10 6d 2c 20 24 6e 75 6d 62 65 72 2c 20 23 30 0a 20 |m, $number, #0. | 00000b20 20 20 20 20 20 20 20 5b 20 20 20 20 20 20 20 24 | [ $| 00000b30 6e 75 6d 20 3c 3e 20 24 6e 75 6d 62 65 72 0a 20 |num <> $number. | 00000b40 20 20 20 20 20 20 20 4d 4f 56 50 4c 20 20 20 24 | MOVPL $| 00000b50 6e 75 6d 2c 20 24 6e 75 6d 62 65 72 20 20 20 20 |num, $number | 00000b60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00000b70 6f 6e 6c 79 20 61 73 73 65 6d 62 6c 65 20 74 68 |only assemble th| 00000b80 69 73 20 63 61 73 65 20 69 66 20 72 65 67 73 20 |is case if regs | 00000b90 64 69 66 66 65 72 65 6e 74 2c 20 61 73 20 69 73 |different, as is| 00000ba0 20 6f 74 68 65 72 77 69 73 65 20 61 20 6e 6f 70 | otherwise a nop| 00000bb0 2e 0a 20 20 20 20 20 20 20 20 5d 0a 20 20 20 20 |.. ]. | 00000bc0 20 20 20 20 45 4f 52 4d 49 20 20 20 24 73 69 67 | EORMI $sig| 00000bd0 6e 2c 20 24 73 69 67 6e 2c 20 23 31 0a 0a 20 20 |n, $sign, #1.. | 00000be0 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 24 72 | MOV $r| 00000bf0 65 6d 2c 20 24 6e 75 6d 2c 20 4c 53 52 20 23 31 |em, $num, LSR #1| 00000c00 36 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 |6. MOV | 00000c10 20 20 24 6e 75 6d 2c 20 24 6e 75 6d 2c 20 4c 53 | $num, $num, LS| 00000c20 4c 20 23 31 36 0a 0a 20 20 20 20 20 20 20 20 57 |L #16.. W| 00000c30 48 49 4c 45 20 20 20 63 6f 75 6e 74 65 72 20 3e |HILE counter >| 00000c40 20 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | 0 | 00000c50 20 20 20 20 20 20 20 3b 75 6e 77 6f 75 6e 64 20 | ;unwound | 00000c60 6c 6f 6f 70 20 75 73 65 73 20 61 62 6f 75 74 20 |loop uses about | 00000c70 36 30 30 20 62 79 74 65 73 20 65 78 74 72 61 20 |600 bytes extra | 00000c80 6d 65 6d 6f 72 79 0a 20 20 20 20 20 20 20 20 4d |memory. M| 00000c90 4f 56 53 20 20 20 20 24 6e 75 6d 2c 20 24 6e 75 |OVS $num, $nu| 00000ca0 6d 2c 20 41 53 4c 20 23 31 20 20 20 20 20 20 20 |m, ASL #1 | 00000cb0 20 20 20 20 20 20 20 3b 73 70 65 65 64 20 69 6e | ;speed in| 00000cc0 63 72 65 61 73 65 20 28 41 52 4d 33 29 20 66 72 |crease (ARM3) fr| 00000cd0 6f 6d 20 61 62 6f 75 74 20 31 2e 32 37 65 2d 35 |om about 1.27e-5| 00000ce0 20 74 6f 20 2e 37 35 65 2d 35 20 73 65 63 6f 6e | to .75e-5 secon| 00000cf0 64 73 0a 20 20 20 20 20 20 20 20 41 44 43 20 20 |ds. ADC | 00000d00 20 20 20 24 72 65 6d 2c 20 24 72 65 6d 2c 20 24 | $rem, $rem, $| 00000d10 72 65 6d 0a 20 20 20 20 20 20 20 20 43 4d 50 20 |rem. CMP | 00000d20 20 20 20 20 24 72 65 6d 2c 20 24 64 69 76 69 73 | $rem, $divis| 00000d30 6f 72 0a 20 20 20 20 20 20 20 20 53 55 42 48 53 |or. SUBHS| 00000d40 20 20 20 24 72 65 6d 2c 20 24 72 65 6d 2c 20 24 | $rem, $rem, $| 00000d50 64 69 76 69 73 6f 72 0a 20 20 20 20 20 20 20 20 |divisor. | 00000d60 4f 52 52 48 53 20 20 20 24 6e 75 6d 2c 20 24 6e |ORRHS $num, $n| 00000d70 75 6d 2c 20 23 31 0a 63 6f 75 6e 74 65 72 20 53 |um, #1.counter S| 00000d80 45 54 41 20 20 20 20 63 6f 75 6e 74 65 72 2d 31 |ETA counter-1| 00000d90 0a 20 20 20 20 20 20 20 20 57 45 4e 44 0a 0a 20 |. WEND.. | 00000da0 20 20 20 20 20 20 20 43 4d 50 20 20 20 20 20 24 | CMP $| 00000db0 72 65 6d 2c 20 24 64 69 76 69 73 6f 72 2c 20 41 |rem, $divisor, A| 00000dc0 53 52 20 23 31 0a 20 20 20 20 20 20 20 20 41 44 |SR #1. AD| 00000dd0 44 47 45 20 20 20 24 6e 75 6d 2c 20 24 6e 75 6d |DGE $num, $num| 00000de0 2c 20 23 31 0a 20 20 20 20 20 20 20 20 54 53 54 |, #1. TST| 00000df0 20 20 20 20 20 24 73 69 67 6e 2c 20 23 31 0a 20 | $sign, #1. | 00000e00 20 20 20 20 20 20 20 52 53 42 4e 45 20 20 20 24 | RSBNE $| 00000e10 6e 75 6d 2c 20 24 6e 75 6d 2c 20 23 30 0a 0a 20 |num, $num, #0.. | 00000e20 20 20 20 20 20 20 20 4d 45 4e 44 0a 0a 0a 0a 3b | MEND....;| 00000e30 20 6d 75 6c 31 36 0a 3b 20 6d 75 6c 74 69 70 6c | mul16.; multipl| 00000e40 69 63 61 74 69 6f 6e 20 6f 66 20 61 6e 20 69 6e |ication of an in| 00000e50 74 65 67 65 72 20 78 20 62 79 20 61 20 31 36 2d |teger x by a 16-| 00000e60 62 69 74 20 66 69 78 65 64 20 70 6f 69 6e 74 20 |bit fixed point | 00000e70 6e 75 6d 62 65 72 20 61 2c 20 77 69 74 68 20 6e |number a, with n| 00000e80 6f 20 72 65 73 74 72 69 63 74 69 6f 6e 73 20 6f |o restrictions o| 00000e90 6e 20 78 20 6f 72 20 61 0a 3b 20 6f 74 68 65 72 |n x or a.; other| 00000ea0 20 74 68 61 6e 20 74 68 61 74 20 78 2a 61 2f 36 | than that x*a/6| 00000eb0 35 35 33 36 20 6d 75 73 74 20 66 69 74 20 69 6e |5536 must fit in| 00000ec0 74 6f 20 61 20 73 69 67 6e 65 64 20 33 32 2d 62 |to a signed 32-b| 00000ed0 69 74 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f |it representatio| 00000ee0 6e 2e 0a 3b 20 63 61 6c 63 75 6c 61 74 65 73 20 |n..; calculates | 00000ef0 72 3d 78 2a 61 2f 36 35 35 33 36 0a 3b 20 49 74 |r=x*a/65536.; It| 00000f00 20 74 61 6b 65 73 20 36 20 70 61 72 61 6d 65 74 | takes 6 paramet| 00000f10 65 72 73 20 2d 20 61 6c 6c 20 72 65 67 69 73 74 |ers - all regist| 00000f20 65 72 20 6e 61 6d 65 73 2e 0a 3b 0a 3b 20 24 78 |er names..;.; $x| 00000f30 3a 20 20 20 78 0a 3b 20 24 61 3a 20 20 20 61 20 |: x.; $a: a | 00000f40 2d 20 61 20 77 69 6c 6c 20 62 65 20 63 6f 72 72 |- a will be corr| 00000f50 75 70 74 65 64 0a 3b 20 24 72 3a 20 20 20 72 65 |upted.; $r: re| 00000f60 73 75 6c 74 20 2d 20 6d 61 79 20 62 65 20 74 68 |sult - may be th| 00000f70 65 20 73 61 6d 65 20 61 73 20 24 78 0a 3b 20 24 |e same as $x.; $| 00000f80 75 3a 20 20 20 73 63 72 61 74 63 68 0a 3b 20 24 |u: scratch.; $| 00000f90 76 3a 20 20 20 73 63 72 61 74 63 68 0a 3b 20 24 |v: scratch.; $| 00000fa0 77 3a 20 20 20 73 63 72 61 74 63 68 0a 3b 0a 20 |w: scratch.;. | 00000fb0 20 20 20 20 20 20 20 4d 41 43 52 4f 0a 24 6c 61 | MACRO.$la| 00000fc0 62 65 6c 20 20 6d 75 6c 31 36 20 20 20 24 78 2c |bel mul16 $x,| 00000fd0 20 24 61 2c 20 24 72 2c 20 24 75 2c 20 24 76 2c | $a, $r, $u, $v,| 00000fe0 20 24 77 0a 0a 20 20 20 20 20 20 20 20 41 53 53 | $w.. ASS| 00000ff0 45 52 54 20 20 24 72 20 3c 3e 20 24 61 0a 20 20 |ERT $r <> $a. | 00001000 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 72 | ASSERT $r| 00001010 20 3c 3e 20 24 75 0a 20 20 20 20 20 20 20 20 41 | <> $u. A| 00001020 53 53 45 52 54 20 20 24 72 20 3c 3e 20 24 76 0a |SSERT $r <> $v.| 00001030 20 20 20 20 20 20 20 20 41 53 53 45 52 54 20 20 | ASSERT | 00001040 24 72 20 3c 3e 20 24 77 0a 20 20 20 20 20 20 20 |$r <> $w. | 00001050 20 41 53 53 45 52 54 20 20 24 78 20 3c 3e 20 24 | ASSERT $x <> $| 00001060 61 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 54 |a. ASSERT| 00001070 20 20 24 78 20 3c 3e 20 24 75 0a 20 20 20 20 20 | $x <> $u. | 00001080 20 20 20 41 53 53 45 52 54 20 20 24 78 20 3c 3e | ASSERT $x <>| 00001090 20 24 76 0a 20 20 20 20 20 20 20 20 41 53 53 45 | $v. ASSE| 000010a0 52 54 20 20 24 78 20 3c 3e 20 24 77 0a 20 20 20 |RT $x <> $w. | 000010b0 20 20 20 20 20 41 53 53 45 52 54 20 20 24 61 20 | ASSERT $a | 000010c0 3c 3e 20 24 75 0a 20 20 20 20 20 20 20 20 41 53 |<> $u. AS| 000010d0 53 45 52 54 20 20 24 61 20 3c 3e 20 24 76 0a 20 |SERT $a <> $v. | 000010e0 20 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 | ASSERT $| 000010f0 61 20 3c 3e 20 24 77 0a 20 20 20 20 20 20 20 20 |a <> $w. | 00001100 41 53 53 45 52 54 20 20 24 75 20 3c 3e 20 24 76 |ASSERT $u <> $v| 00001110 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 54 20 |. ASSERT | 00001120 20 24 75 20 3c 3e 20 24 77 0a 20 20 20 20 20 20 | $u <> $w. | 00001130 20 20 41 53 53 45 52 54 20 20 24 76 20 3c 3e 20 | ASSERT $v <> | 00001140 24 77 0a 0a 24 6c 61 62 65 6c 20 20 4d 4f 56 53 |$w..$label MOVS| 00001150 20 20 20 20 24 77 2c 20 24 61 2c 20 4c 53 4c 20 | $w, $a, LSL | 00001160 23 31 0a 20 20 20 20 20 20 20 20 52 53 42 43 53 |#1. RSBCS| 00001170 20 20 20 24 61 2c 20 24 61 2c 20 23 30 0a 20 20 | $a, $a, #0. | 00001180 20 20 20 20 20 20 54 45 51 20 20 20 20 20 24 78 | TEQ $x| 00001190 2c 20 23 30 0a 20 20 20 20 20 20 20 20 52 53 42 |, #0. RSB| 000011a0 4d 49 20 20 20 24 72 2c 20 24 78 2c 20 23 30 0a |MI $r, $x, #0.| 000011b0 20 20 20 20 20 20 20 20 5b 20 20 20 20 20 20 20 | [ | 000011c0 24 72 20 3c 3e 20 24 78 0a 20 20 20 20 20 20 20 |$r <> $x. | 000011d0 20 4d 4f 56 50 4c 20 20 20 24 72 2c 20 24 78 0a | MOVPL $r, $x.| 000011e0 20 20 20 20 20 20 20 20 5d 20 20 20 20 20 20 20 | ] | 000011f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001200 3b 6e 6f 77 20 68 61 76 65 20 43 20 62 69 74 20 |;now have C bit | 00001210 73 65 74 20 69 66 66 20 61 3c 30 2c 20 4e 20 62 |set iff a<0, N b| 00001220 69 74 20 73 65 74 20 69 66 66 20 78 3c 30 0a 20 |it set iff x<0. | 00001230 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 24 | MOV $| 00001240 77 2c 20 70 63 2c 20 4c 53 52 20 23 33 31 0a 20 |w, pc, LSR #31. | 00001250 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 24 | MOV $| 00001260 77 2c 20 24 77 2c 20 4c 53 4c 20 23 32 38 20 3b |w, $w, LSL #28 ;| 00001270 67 65 74 20 77 3d 28 32 5e 32 38 29 2a 4e 20 7b |get w=(2^28)*N {| 00001280 4e 20 69 73 20 62 33 31 2c 20 56 20 69 73 20 62 |N is b31, V is b| 00001290 32 38 2c 20 43 20 69 73 20 62 32 39 20 69 6e 20 |28, C is b29 in | 000012a0 70 63 2f 70 73 72 7d 0a 20 20 20 20 20 20 20 20 |pc/psr}. | 000012b0 54 45 51 50 20 20 20 20 24 77 2c 20 70 63 2c 20 |TEQP $w, pc, | 000012c0 4c 53 52 20 23 31 20 20 3b 45 4f 52 20 77 20 69 |LSR #1 ;EOR w i| 000012d0 6e 74 6f 20 70 63 2f 70 73 72 20 7b 69 65 20 4e |nto pc/psr {ie N| 000012e0 20 45 4f 52 20 43 20 69 73 20 70 75 74 20 69 6e | EOR C is put in| 000012f0 74 6f 20 56 7d 20 20 2d 20 74 68 69 73 20 69 73 |to V} - this is| 00001300 20 61 20 77 61 79 20 6f 66 20 73 74 6f 72 69 6e | a way of storin| 00001310 67 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |g. | 00001320 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001330 20 20 3b 73 69 67 6e 20 6f 66 20 72 65 73 75 6c | ;sign of resul| 00001340 74 20 69 6e 20 6f 76 65 72 66 6c 6f 77 20 66 6c |t in overflow fl| 00001350 61 67 2c 20 73 61 76 69 6e 67 20 6f 6e 20 61 20 |ag, saving on a | 00001360 72 65 67 69 73 74 65 72 0a 20 20 20 20 20 20 20 |register. | 00001370 20 4d 4f 56 20 20 20 20 20 24 77 2c 20 24 72 2c | MOV $w, $r,| 00001380 20 4c 53 52 20 23 31 36 0a 20 20 20 20 20 20 20 | LSR #16. | 00001390 20 42 49 43 20 20 20 20 20 24 72 2c 20 24 72 2c | BIC $r, $r,| 000013a0 20 24 77 2c 20 4c 53 4c 20 23 31 36 0a 20 20 20 | $w, LSL #16. | 000013b0 20 20 20 20 20 4d 4f 56 20 20 20 20 20 24 76 2c | MOV $v,| 000013c0 20 24 61 2c 20 4c 53 52 20 23 31 36 0a 20 20 20 | $a, LSR #16. | 000013d0 20 20 20 20 20 42 49 43 20 20 20 20 20 24 61 2c | BIC $a,| 000013e0 20 24 61 2c 20 24 76 2c 20 4c 53 4c 20 23 31 36 | $a, $v, LSL #16| 000013f0 0a 20 20 20 20 20 20 20 20 4d 55 4c 20 20 20 20 |. MUL | 00001400 20 24 75 2c 20 24 61 2c 20 24 72 0a 20 20 20 20 | $u, $a, $r. | 00001410 20 20 20 20 54 53 54 20 20 20 20 20 24 75 2c 20 | TST $u, | 00001420 23 31 3c 3c 31 35 20 20 20 20 20 20 3b 6e 6f 74 |#1<<15 ;not| 00001430 69 63 65 20 74 68 69 73 20 69 73 20 74 68 65 20 |ice this is the | 00001440 6f 6e 6c 79 20 6f 70 65 72 61 74 69 6f 6e 20 61 |only operation a| 00001450 6c 74 65 72 69 6e 67 20 70 73 72 20 26 20 74 68 |ltering psr & th| 00001460 61 74 20 69 74 20 77 69 6c 6c 20 6e 6f 74 20 63 |at it will not c| 00001470 6f 72 72 75 70 74 20 56 0a 20 20 20 20 20 20 20 |orrupt V. | 00001480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001490 20 20 20 20 20 20 20 20 20 3b 6e 6f 74 65 20 69 | ;note i| 000014a0 74 20 77 69 6c 6c 20 63 6f 72 72 75 70 74 20 43 |t will corrupt C| 000014b0 2c 20 61 73 20 69 6d 6d 65 64 69 61 74 65 20 6f |, as immediate o| 000014c0 70 65 72 61 6e 64 20 33 32 37 36 38 20 72 65 71 |perand 32768 req| 000014d0 75 69 72 65 73 20 61 20 73 68 69 66 74 0a 20 20 |uires a shift. | 000014e0 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 24 75 | MOV $u| 000014f0 2c 20 24 75 2c 20 4c 53 52 20 23 31 36 0a 20 20 |, $u, LSR #16. | 00001500 20 20 20 20 20 20 41 44 44 4e 45 20 20 20 24 75 | ADDNE $u| 00001510 2c 20 24 75 2c 20 23 31 0a 20 20 20 20 20 20 20 |, $u, #1. | 00001520 20 4d 4c 41 20 20 20 20 20 24 75 2c 20 24 72 2c | MLA $u, $r,| 00001530 20 24 76 2c 20 24 75 09 3b 36 2f 39 2f 39 34 20 | $v, $u.;6/9/94 | 00001540 2d 20 72 65 76 65 72 73 65 20 76 20 26 20 72 20 |- reverse v & r | 00001550 74 6f 20 6f 70 74 69 6d 69 73 65 20 66 6f 72 20 |to optimise for | 00001560 61 72 67 75 6d 65 6e 74 20 61 20 73 6d 61 6c 6c |argument a small| 00001570 0a 20 20 20 20 20 20 20 20 4d 4c 41 20 20 20 20 |. MLA | 00001580 20 24 75 2c 20 24 61 2c 20 24 77 2c 20 24 75 0a | $u, $a, $w, $u.| 00001590 20 20 20 20 20 20 20 20 4d 55 4c 20 20 20 20 20 | MUL | 000015a0 24 72 2c 20 24 77 2c 20 24 76 09 3b 36 2f 39 2f |$r, $w, $v.;6/9/| 000015b0 39 34 20 2d 20 72 65 76 65 72 73 65 20 76 20 26 |94 - reverse v &| 000015c0 20 77 20 74 6f 20 6f 70 74 69 6d 69 73 65 20 66 | w to optimise f| 000015d0 6f 72 20 61 72 67 75 6d 65 6e 74 20 61 20 73 6d |or argument a sm| 000015e0 61 6c 6c 0a 20 20 20 20 20 20 20 20 41 44 44 20 |all. ADD | 000015f0 20 20 20 20 24 72 2c 20 24 75 2c 20 24 72 2c 20 | $r, $u, $r, | 00001600 4c 53 4c 20 23 31 36 0a 20 20 20 20 20 20 20 20 |LSL #16. | 00001610 52 53 42 56 53 20 20 20 24 72 2c 20 24 72 2c 20 |RSBVS $r, $r, | 00001620 23 30 0a 0a 20 20 20 20 20 20 20 20 4d 45 4e 44 |#0.. MEND| 00001630 0a 0a 0a 0a 3b 20 6d 75 6c 31 36 63 0a 3b 20 6d |....; mul16c.; m| 00001640 75 6c 74 69 70 6c 69 63 61 74 69 6f 6e 20 6f 66 |ultiplication of| 00001650 20 61 6e 20 69 6e 74 65 67 65 72 20 78 20 62 79 | an integer x by| 00001660 20 61 20 31 36 2d 62 69 74 20 66 69 78 65 64 20 | a 16-bit fixed | 00001670 70 6f 69 6e 74 20 6e 75 6d 62 65 72 20 61 2c 20 |point number a, | 00001680 77 68 65 72 65 20 61 20 69 73 20 61 20 63 6f 6e |where a is a con| 00001690 74 72 61 63 74 69 6f 6e 0a 3b 20 69 65 20 63 61 |traction.; ie ca| 000016a0 6c 63 75 6c 61 74 65 73 20 72 3d 78 2a 61 2f 36 |lculates r=x*a/6| 000016b0 35 35 33 36 2c 20 61 73 73 75 6d 69 6e 67 3a 20 |5536, assuming: | 000016c0 61 62 73 20 61 20 3c 20 36 35 35 33 36 0a 3b 20 |abs a < 65536.; | 000016d0 69 66 20 74 68 65 20 70 6f 73 73 69 62 69 6c 69 |if the possibili| 000016e0 74 79 20 65 78 69 73 74 73 20 74 68 61 74 20 61 |ty exists that a| 000016f0 3e 3d 36 35 35 33 36 2c 20 63 61 6c 6c 65 72 20 |>=65536, caller | 00001700 73 68 6f 75 6c 64 20 63 68 65 63 6b 20 74 68 69 |should check thi| 00001710 73 20 26 20 65 69 74 68 65 72 20 6e 6f 74 20 63 |s & either not c| 00001720 61 6c 6c 20 72 6f 75 74 69 6e 65 2c 20 6f 72 20 |all routine, or | 00001730 73 65 74 20 61 3d 36 35 35 33 35 0a 3b 20 49 74 |set a=65535.; It| 00001740 20 74 61 6b 65 73 20 34 20 70 61 72 61 6d 65 74 | takes 4 paramet| 00001750 65 72 73 20 2d 20 61 6c 6c 20 72 65 67 69 73 74 |ers - all regist| 00001760 65 72 20 6e 61 6d 65 73 2e 0a 3b 0a 3b 20 24 78 |er names..;.; $x| 00001770 3a 20 20 20 78 0a 3b 20 24 61 3a 20 20 20 61 20 |: x.; $a: a | 00001780 2d 20 72 65 71 75 69 72 65 20 61 62 73 20 61 20 |- require abs a | 00001790 3c 36 35 35 33 36 2c 20 61 20 77 69 6c 6c 20 62 |<65536, a will b| 000017a0 65 20 63 6f 72 72 75 70 74 65 64 0a 3b 20 24 72 |e corrupted.; $r| 000017b0 3a 20 20 20 72 65 73 75 6c 74 20 2d 20 6d 61 79 |: result - may| 000017c0 20 62 65 20 74 68 65 20 73 61 6d 65 20 61 73 20 | be the same as | 000017d0 24 78 0a 3b 20 24 77 3a 20 20 20 73 63 72 61 74 |$x.; $w: scrat| 000017e0 63 68 0a 3b 0a 20 20 20 20 20 20 20 20 4d 41 43 |ch.;. MAC| 000017f0 52 4f 0a 24 6c 61 62 65 6c 20 20 6d 75 6c 31 36 |RO.$label mul16| 00001800 63 20 20 24 78 2c 20 24 61 2c 20 24 72 2c 20 24 |c $x, $a, $r, $| 00001810 77 0a 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 |w.. ASSER| 00001820 54 20 20 24 72 20 3c 3e 20 24 61 0a 20 20 20 20 |T $r <> $a. | 00001830 20 20 20 20 41 53 53 45 52 54 20 20 24 72 20 3c | ASSERT $r <| 00001840 3e 20 24 77 0a 20 20 20 20 20 20 20 20 41 53 53 |> $w. ASS| 00001850 45 52 54 20 20 24 78 20 3c 3e 20 24 61 0a 20 20 |ERT $x <> $a. | 00001860 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 78 | ASSERT $x| 00001870 20 3c 3e 20 24 77 0a 20 20 20 20 20 20 20 20 41 | <> $w. A| 00001880 53 53 45 52 54 20 20 24 61 20 3c 3e 20 24 77 0a |SSERT $a <> $w.| 00001890 0a 24 6c 61 62 65 6c 20 20 4d 4f 56 53 20 20 20 |.$label MOVS | 000018a0 20 24 77 2c 20 24 61 2c 20 4c 53 4c 20 23 31 0a | $w, $a, LSL #1.| 000018b0 20 20 20 20 20 20 20 20 52 53 42 43 53 20 20 20 | RSBCS | 000018c0 24 61 2c 20 24 61 2c 20 23 30 0a 20 20 20 20 20 |$a, $a, #0. | 000018d0 20 20 20 54 45 51 20 20 20 20 20 24 78 2c 20 23 | TEQ $x, #| 000018e0 30 0a 20 20 20 20 20 20 20 20 52 53 42 4d 49 20 |0. RSBMI | 000018f0 20 20 24 72 2c 20 24 78 2c 20 23 30 0a 20 20 20 | $r, $x, #0. | 00001900 20 20 20 20 20 5b 20 20 20 20 20 20 20 24 72 20 | [ $r | 00001910 3c 3e 20 24 78 0a 20 20 20 20 20 20 20 20 4d 4f |<> $x. MO| 00001920 56 50 4c 20 20 20 24 72 2c 20 24 78 0a 20 20 20 |VPL $r, $x. | 00001930 20 20 20 20 20 5d 0a 20 20 20 20 20 20 20 20 4d | ]. M| 00001940 4f 56 20 20 20 20 20 24 77 2c 20 70 63 2c 20 4c |OV $w, pc, L| 00001950 53 52 20 23 33 31 20 3b 73 65 65 20 6d 75 6c 31 |SR #31 ;see mul1| 00001960 36 20 61 62 6f 76 65 2c 20 66 6f 72 20 63 6f 6d |6 above, for com| 00001970 6d 65 6e 74 73 20 72 65 20 74 68 69 73 20 70 61 |ments re this pa| 00001980 72 74 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |rt. MOV | 00001990 20 20 20 24 77 2c 20 24 77 2c 20 4c 53 4c 20 23 | $w, $w, LSL #| 000019a0 32 38 0a 20 20 20 20 20 20 20 20 54 45 51 50 20 |28. TEQP | 000019b0 20 20 20 24 77 2c 20 70 63 2c 20 4c 53 52 20 23 | $w, pc, LSR #| 000019c0 31 0a 0a 20 20 20 20 20 20 20 20 54 53 54 20 20 |1.. TST | 000019d0 20 20 20 24 61 2c 20 23 31 3c 3c 31 36 20 20 20 | $a, #1<<16 | 000019e0 20 20 20 3b 62 6f 64 67 65 20 74 6f 20 61 6c 6c | ;bodge to all| 000019f0 6f 77 20 63 6f 64 65 20 74 6f 20 66 75 6e 63 74 |ow code to funct| 00001a00 69 6f 6e 20 69 66 20 24 61 20 69 73 20 75 70 74 |ion if $a is upt| 00001a10 6f 20 32 2a 36 35 35 33 36 2d 31 0a 20 20 20 20 |o 2*65536-1. | 00001a20 20 20 20 20 4d 4f 56 4e 45 20 20 20 24 72 2c 20 | MOVNE $r, | 00001a30 24 72 2c 20 4c 53 4c 20 23 31 20 20 3b 63 61 6e |$r, LSL #1 ;can| 00001a40 20 6f 63 63 75 72 20 69 6e 20 61 20 63 6f 6e 74 | occur in a cont| 00001a50 72 61 63 74 69 76 65 20 66 6e 20 64 75 65 20 74 |ractive fn due t| 00001a60 6f 20 63 68 61 6e 67 65 20 6f 66 20 63 6f 6f 72 |o change of coor| 00001a70 64 69 6e 61 74 65 73 20 74 6f 20 68 61 6e 64 6c |dinates to handl| 00001a80 65 20 31 78 32 20 70 69 78 65 6c 20 61 73 70 65 |e 1x2 pixel aspe| 00001a90 63 74 20 72 61 74 69 6f 0a 20 20 20 20 20 20 20 |ct ratio. | 00001aa0 20 4d 4f 56 4e 45 20 20 20 24 61 2c 20 24 61 2c | MOVNE $a, $a,| 00001ab0 20 4c 53 52 20 23 31 20 20 3b 63 68 61 6e 67 65 | LSR #1 ;change| 00001ac0 20 6d 61 64 65 20 33 2f 34 2f 39 34 20 2d 20 65 | made 3/4/94 - e| 00001ad0 73 74 69 6d 61 74 65 20 6f 76 65 72 68 65 61 64 |stimate overhead| 00001ae0 20 74 6f 20 72 69 61 20 6f 66 20 75 70 74 6f 20 | to ria of upto | 00001af0 33 25 0a 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 |3%.. MOV | 00001b00 20 20 20 20 24 77 2c 20 24 72 2c 20 4c 53 52 20 | $w, $r, LSR | 00001b10 23 31 36 0a 20 20 20 20 20 20 20 20 42 49 43 20 |#16. BIC | 00001b20 20 20 20 20 24 72 2c 20 24 72 2c 20 24 77 2c 20 | $r, $r, $w, | 00001b30 4c 53 4c 20 23 31 36 0a 20 20 20 20 20 20 20 20 |LSL #16. | 00001b40 4d 55 4c 20 20 20 20 20 24 72 2c 20 24 61 2c 20 |MUL $r, $a, | 00001b50 24 72 0a 20 20 20 20 20 20 20 20 54 53 54 20 20 |$r. TST | 00001b60 20 20 20 24 72 2c 20 23 31 3c 3c 31 35 20 20 20 | $r, #1<<15 | 00001b70 20 20 20 3b 72 65 6d 65 6d 62 65 72 2c 20 63 61 | ;remember, ca| 00001b80 6e 27 74 20 75 73 65 20 6d 6f 76 73 20 72 2c 72 |n't use movs r,r| 00001b90 2c 6c 73 72 20 23 31 36 2c 20 61 73 20 74 68 69 |,lsr #16, as thi| 00001ba0 73 20 77 6f 75 6c 64 20 63 6f 72 72 75 70 74 20 |s would corrupt | 00001bb0 56 2c 20 77 68 69 63 68 20 69 73 20 73 74 6f 72 |V, which is stor| 00001bc0 69 6e 67 20 73 69 67 6e 20 6f 66 20 72 65 73 75 |ing sign of resu| 00001bd0 6c 74 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |lt. MOV | 00001be0 20 20 20 24 72 2c 20 24 72 2c 20 4c 53 52 20 23 | $r, $r, LSR #| 00001bf0 31 36 0a 20 20 20 20 20 20 20 20 41 44 44 4e 45 |16. ADDNE| 00001c00 20 20 20 24 72 2c 20 24 72 2c 20 23 31 0a 20 20 | $r, $r, #1. | 00001c10 20 20 20 20 20 20 4d 4c 41 20 20 20 20 20 24 72 | MLA $r| 00001c20 2c 20 24 61 2c 20 24 77 2c 20 24 72 0a 0a 20 20 |, $a, $w, $r.. | 00001c30 20 20 20 20 20 20 52 53 42 56 53 20 20 20 24 72 | RSBVS $r| 00001c40 2c 20 24 72 2c 20 23 30 0a 0a 20 20 20 20 20 20 |, $r, #0.. | 00001c50 20 20 4d 45 4e 44 0a 0a 0a 0a 3b 20 73 71 72 74 | MEND....; sqrt| 00001c60 31 36 0a 3b 20 69 6e 74 65 67 65 72 20 73 71 75 |16.; integer squ| 00001c70 61 72 65 20 72 6f 6f 74 20 72 65 74 75 72 6e 69 |are root returni| 00001c80 6e 67 20 31 36 2d 62 69 74 20 66 69 78 65 64 20 |ng 16-bit fixed | 00001c90 70 6f 69 6e 74 20 6e 75 6d 62 65 72 2c 20 61 73 |point number, as| 00001ca0 73 75 6d 69 6e 67 20 78 20 69 73 20 31 36 2d 62 |suming x is 16-b| 00001cb0 69 74 20 66 69 78 65 64 20 70 6f 69 6e 74 0a 3b |it fixed point.;| 00001cc0 20 69 65 20 72 65 74 75 72 6e 73 20 73 71 72 74 | ie returns sqrt| 00001cd0 28 78 3c 3c 31 36 29 0a 3b 20 49 74 20 74 61 6b |(x<<16).; It tak| 00001ce0 65 73 20 36 20 70 61 72 61 6d 65 74 65 72 73 20 |es 6 parameters | 00001cf0 2d 20 61 6c 6c 20 72 65 67 69 73 74 65 72 20 6e |- all register n| 00001d00 61 6d 65 73 0a 3b 0a 3b 20 24 78 3a 20 20 20 78 |ames.;.; $x: x| 00001d10 0a 3b 20 24 72 3a 20 20 20 72 65 73 75 6c 74 20 |.; $r: result | 00001d20 2d 20 6d 61 79 20 62 65 20 74 68 65 20 73 61 6d |- may be the sam| 00001d30 65 20 61 73 20 78 0a 3b 20 24 6e 3a 20 20 20 63 |e as x.; $n: c| 00001d40 6f 70 79 20 6f 66 20 78 20 75 73 65 64 20 64 75 |opy of x used du| 00001d50 72 69 6e 67 20 63 61 6c 63 75 6c 61 74 69 6f 6e |ring calculation| 00001d60 0a 3b 20 24 74 3a 20 20 20 74 72 61 6e 73 69 65 |.; $t: transie| 00001d70 6e 74 20 73 63 72 61 74 63 68 0a 3b 20 24 64 3a |nt scratch.; $d:| 00001d80 20 20 20 72 65 6d 61 69 6e 64 65 72 0a 3b 20 24 | remainder.; $| 00001d90 6f 3a 20 20 20 63 6f 6e 73 74 61 6e 74 20 76 61 |o: constant va| 00001da0 6c 75 65 20 6f 66 20 31 0a 3b 0a 20 20 20 20 20 |lue of 1.;. | 00001db0 20 20 20 4d 41 43 52 4f 0a 24 6c 61 62 65 6c 20 | MACRO.$label | 00001dc0 20 73 71 72 74 31 36 20 20 24 78 2c 20 24 72 2c | sqrt16 $x, $r,| 00001dd0 20 24 6e 2c 20 24 74 2c 20 24 64 2c 20 24 6f 0a | $n, $t, $d, $o.| 00001de0 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 54 20 |. ASSERT | 00001df0 20 24 78 20 3c 3e 20 24 6e 0a 20 20 20 20 20 20 | $x <> $n. | 00001e00 20 20 41 53 53 45 52 54 20 20 24 78 20 3c 3e 20 | ASSERT $x <> | 00001e10 24 74 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 |$t. ASSER| 00001e20 54 20 20 24 78 20 3c 3e 20 24 64 0a 20 20 20 20 |T $x <> $d. | 00001e30 20 20 20 20 41 53 53 45 52 54 20 20 24 78 20 3c | ASSERT $x <| 00001e40 3e 20 24 6f 0a 20 20 20 20 20 20 20 20 41 53 53 |> $o. ASS| 00001e50 45 52 54 20 20 24 6e 20 3c 3e 20 24 74 0a 20 20 |ERT $n <> $t. | 00001e60 20 20 20 20 20 20 41 53 53 45 52 54 20 20 24 6e | ASSERT $n| 00001e70 20 3c 3e 20 24 64 0a 20 20 20 20 20 20 20 20 41 | <> $d. A| 00001e80 53 53 45 52 54 20 20 24 6e 20 3c 3e 20 24 6f 0a |SSERT $n <> $o.| 00001e90 20 20 20 20 20 20 20 20 41 53 53 45 52 54 20 20 | ASSERT | 00001ea0 24 74 20 3c 3e 20 24 64 0a 20 20 20 20 20 20 20 |$t <> $d. | 00001eb0 20 41 53 53 45 52 54 20 20 24 74 20 3c 3e 20 24 | ASSERT $t <> $| 00001ec0 6f 0a 20 20 20 20 20 20 20 20 41 53 53 45 52 54 |o. ASSERT| 00001ed0 20 20 24 64 20 3c 3e 20 24 6f 0a 0a 20 20 20 20 | $d <> $o.. | 00001ee0 20 20 20 20 4c 43 4c 41 20 20 20 20 63 6f 75 6e | LCLA coun| 00001ef0 74 65 72 0a 0a 24 6c 61 62 65 6c 20 20 4d 4f 56 |ter..$label MOV| 00001f00 20 20 20 20 20 24 6e 2c 20 24 78 0a 20 20 20 20 | $n, $x. | 00001f10 20 20 20 20 4d 4f 56 20 20 20 20 20 24 6f 2c 20 | MOV $o, | 00001f20 23 31 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |#1. MOV | 00001f30 20 20 20 24 78 2c 20 23 30 0a 20 20 20 20 20 20 | $x, #0. | 00001f40 20 20 4d 4f 56 20 20 20 20 20 24 64 2c 20 23 30 | MOV $d, #0| 00001f50 0a 0a 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 |.. AND | 00001f60 20 20 24 74 2c 20 24 6e 2c 20 23 28 33 3c 3c 33 | $t, $n, #(3<<3| 00001f70 30 29 0a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |0). MOV | 00001f80 20 20 20 24 74 2c 20 24 74 2c 20 4c 53 52 20 23 | $t, $t, LSR #| 00001f90 33 30 0a 20 20 20 20 20 20 20 20 4f 52 52 20 20 |30. ORR | 00001fa0 20 20 20 24 64 2c 20 24 64 2c 20 24 74 0a 20 20 | $d, $d, $t. | 00001fb0 20 20 20 20 20 20 41 44 44 20 20 20 20 20 24 74 | ADD $t| 00001fc0 2c 20 24 6f 2c 20 24 78 2c 20 4c 53 4c 20 23 31 |, $o, $x, LSL #1| 00001fd0 0a 20 20 20 20 20 20 20 20 43 4d 50 20 20 20 20 |. CMP | 00001fe0 20 24 64 2c 20 24 74 0a 20 20 20 20 20 20 20 20 | $d, $t. | 00001ff0 53 55 42 47 45 20 20 20 24 64 2c 20 24 64 2c 20 |SUBGE $d, $d, | 00002000 24 74 0a 20 20 20 20 20 20 20 20 41 44 44 47 45 |$t. ADDGE| 00002010 20 20 20 24 78 2c 20 24 78 2c 20 23 31 0a 0a 63 | $x, $x, #1..c| 00002020 6f 75 6e 74 65 72 20 53 45 54 41 20 20 20 20 32 |ounter SETA 2| 00002030 38 0a 20 20 20 20 20 20 20 20 57 48 49 4c 45 20 |8. WHILE | 00002040 20 20 63 6f 75 6e 74 65 72 20 3c 20 33 32 20 20 | counter < 32 | 00002050 20 20 20 20 20 20 20 20 20 20 20 3b 77 61 6e 74 | ;want| 00002060 20 3e 3d 20 30 2c 20 68 6f 77 65 76 65 72 20 63 | >= 0, however c| 00002070 6f 75 6e 74 65 72 20 69 73 20 75 6e 73 69 67 6e |ounter is unsign| 00002080 65 64 2c 20 73 6f 20 61 66 74 65 72 20 30 20 69 |ed, so after 0 i| 00002090 74 20 67 6f 65 73 20 68 69 67 68 2c 20 74 68 75 |t goes high, thu| 000020a0 73 20 3c 20 33 32 20 77 69 6c 6c 20 63 61 74 63 |s < 32 will catc| 000020b0 68 20 69 74 21 0a 20 20 20 20 20 20 20 20 4d 4f |h it!. MO| 000020c0 56 20 20 20 20 20 24 78 2c 20 24 78 2c 20 4c 53 |V $x, $x, LS| 000020d0 4c 20 23 31 0a 20 20 20 20 20 20 20 20 4d 4f 56 |L #1. MOV| 000020e0 20 20 20 20 20 24 64 2c 20 24 64 2c 20 4c 53 4c | $d, $d, LSL| 000020f0 20 23 32 0a 20 20 20 20 20 20 20 20 41 4e 44 20 | #2. AND | 00002100 20 20 20 20 24 74 2c 20 24 6e 2c 20 23 28 33 3c | $t, $n, #(3<| 00002110 3c 63 6f 75 6e 74 65 72 29 0a 20 20 20 20 20 20 |<counter). | 00002120 20 20 5b 20 20 20 20 20 20 20 63 6f 75 6e 74 65 | [ counte| 00002130 72 20 3c 3e 20 30 0a 20 20 20 20 20 20 20 20 4d |r <> 0. M| 00002140 4f 56 20 20 20 20 20 24 74 2c 20 24 74 2c 20 4c |OV $t, $t, L| 00002150 53 52 20 23 63 6f 75 6e 74 65 72 0a 20 20 20 20 |SR #counter. | 00002160 20 20 20 20 5d 0a 20 20 20 20 20 20 20 20 4f 52 | ]. OR| 00002170 52 20 20 20 20 20 24 64 2c 20 24 64 2c 20 24 74 |R $d, $d, $t| 00002180 0a 20 20 20 20 20 20 20 20 41 44 44 20 20 20 20 |. ADD | 00002190 20 24 74 2c 20 24 6f 2c 20 24 78 2c 20 4c 53 4c | $t, $o, $x, LSL| 000021a0 20 23 31 0a 20 20 20 20 20 20 20 20 43 4d 50 20 | #1. CMP | 000021b0 20 20 20 20 24 64 2c 20 24 74 0a 20 20 20 20 20 | $d, $t. | 000021c0 20 20 20 53 55 42 47 45 20 20 20 24 64 2c 20 24 | SUBGE $d, $| 000021d0 64 2c 20 24 74 0a 20 20 20 20 20 20 20 20 41 44 |d, $t. AD| 000021e0 44 47 45 20 20 20 24 78 2c 20 24 78 2c 20 23 31 |DGE $x, $x, #1| 000021f0 0a 63 6f 75 6e 74 65 72 20 53 45 54 41 20 20 20 |.counter SETA | 00002200 20 63 6f 75 6e 74 65 72 2d 32 0a 20 20 20 20 20 | counter-2. | 00002210 20 20 20 57 45 4e 44 0a 0a 63 6f 75 6e 74 65 72 | WEND..counter| 00002220 20 53 45 54 41 20 20 20 20 31 34 0a 20 20 20 20 | SETA 14. | 00002230 20 20 20 20 57 48 49 4c 45 20 20 20 63 6f 75 6e | WHILE coun| 00002240 74 65 72 20 3c 20 33 32 0a 20 20 20 20 20 20 20 |ter < 32. | 00002250 20 4d 4f 56 20 20 20 20 20 24 78 2c 20 24 78 2c | MOV $x, $x,| 00002260 20 4c 53 4c 20 23 31 0a 20 20 20 20 20 20 20 20 | LSL #1. | 00002270 4d 4f 56 20 20 20 20 20 24 64 2c 20 24 64 2c 20 |MOV $d, $d, | 00002280 4c 53 4c 20 23 32 0a 20 20 20 20 20 20 20 20 41 |LSL #2. A| 00002290 44 44 20 20 20 20 20 24 74 2c 20 24 6f 2c 20 24 |DD $t, $o, $| 000022a0 78 2c 20 4c 53 4c 20 23 31 0a 20 20 20 20 20 20 |x, LSL #1. | 000022b0 20 20 43 4d 50 20 20 20 20 20 24 64 2c 20 24 74 | CMP $d, $t| 000022c0 0a 20 20 20 20 20 20 20 20 53 55 42 47 45 20 20 |. SUBGE | 000022d0 20 24 64 2c 20 24 64 2c 20 24 74 0a 20 20 20 20 | $d, $d, $t. | 000022e0 20 20 20 20 41 44 44 47 45 20 20 20 24 78 2c 20 | ADDGE $x, | 000022f0 24 78 2c 20 23 31 0a 63 6f 75 6e 74 65 72 20 53 |$x, #1.counter S| 00002300 45 54 41 20 20 20 20 63 6f 75 6e 74 65 72 2d 32 |ETA counter-2| 00002310 0a 20 20 20 20 20 20 20 20 57 45 4e 44 0a 0a 20 |. WEND.. | 00002320 20 20 20 20 20 20 20 5b 20 20 20 20 20 20 20 24 | [ $| 00002330 72 20 3c 3e 20 24 78 0a 20 20 20 20 20 20 20 20 |r <> $x. | 00002340 4d 4f 56 20 20 20 20 20 24 72 2c 20 24 78 0a 20 |MOV $r, $x. | 00002350 20 20 20 20 20 20 20 5d 0a 0a 20 20 20 20 20 20 | ].. | 00002360 20 20 4d 45 4e 44 0a 0a 0a 0a 20 20 20 20 20 20 | MEND.... | 00002370 20 20 45 4e 44 0a | END.| 00002376