Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars » Regulars/StarInfo/Radford/Calc_lib

Regulars/StarInfo/Radford/Calc_lib

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 1995-11.adf » !Regulars
Filename: Regulars/StarInfo/Radford/Calc_lib
Read OK:
File size: 1E7B bytes
Load address: 0000
Exec address: 0000
File contents
   10DEFPROCassemble_calculator
   20ON ERROR REPORT:PRINT" AN ERROR HAS BEEN DETECTED @ ";ERL:END
   30carry=8
   40accuracy%=800   :REM THIS IS THE MAXIMUM NUMBER OF DIGITS TO BE CALCULATED
   50DIM code% 1200+(4*accuracy%)
   60FOR pass%=0 TO 2 STEP 2
   70P%=code%
   80[
   90OPT pass%
  100
  110.begin_addition
  120STMFD R13!,{R14}
  130
  140BL get_addresses
  150
  160\find end of operand1 AND operand2
  170
  180MOV R3,R0
  190MOV R5,#0
  200.loop_get_end1
  210  LDRB R4,[R3],#1
  220  ADD R5,R5,#1
  230  CMP R4,#10
  240BNE loop_get_end1
  250
  260MOV R3,R1
  270MOV R6,#0
  280.loop_get_end2
  290  LDRB R4,[R3],#1
  300  ADD R6,R6,#1
  310  CMP R4,#10
  320BNE loop_get_end2
  330
  340\LENGTH OF OPERAND 1 IS RETURNED IN R5, LENGTH OF OPERAND 2 IS IN R6
  350
  360SUB R3,R5,R6      \R3 IS DIFF
  370CMP R3,#0
  380RSBLT R3,R3,#0
  390CMP R5,R6
  400MOVLT R4,R1
  410MOVLT R1,R0
  420MOVLT R0,R4
  430
  440MOVGT R4,R5      \R4 IS MAXLENGTH
  450MOVLE R4,R6
  460
  470MOV carry,#0
  480
  490\structure for...next loop
  500
  510SUB R4,R4,#2
  520MOV R7,R4
  530  .for_loopify1c
  540  LDRB R9,[R0,R7]    \Q1%
  550  SUBS R14,R7,R3
  560  LDRGTB R10,[R1,R14]
  570  MOVLE R10,#0       \Q2%
  580  ADD R9,R9,R10
  590  ADD R9,R9,carry
  600
  610
  620    \ASSEMBLE MOD AND DIV FUNCTION
  630    STMFD R13!,{R0-R6}
  640    MOV R0,R9
  650    MOV R1,#10
  660    ANDS R6,R0,#1<<31
  670    RSBMI R0,R0,#0
  680    EOR R5,R6,R1
  690    CMP R1,#0
  700    RSBMI R1,R1,#0
  710
  720    MOV R2,#0
  730    MOV R3,#0
  740    MOV R4,#1<<31
  750
  760    .division_loop
  770    MOVS R0,R0,ASL#1
  780    ADC R2,R2,R2
  790    CMP R2,R1
  800    SUBGE R2,R2,R1
  810    ORRGE R3,R3,R4
  820    MOVS R4,R4,LSR#1
  830    BNE division_loop
  840
  850    CMP R5,#0
  860    RSBMI R3,R3,#0
  870    CMP R6,#0
  880    RSBMI R2,R2,#0
  890
  900    STR R3,divres
  910    STR R2,modres
  920
  930    LDMFD R13!,{R0-R6}
  940
  950  LDR R14,modres
  960  STRB R14,[R2,R7]
  970  LDR carry,divres
  980
  990  SUBS R7,R7,#1
 1000
 1010BNE for_loopify1c
 1020CMP carry,#0
 1030STRNEB carry,[R2]
 1040MOV R14,#10
 1050ADD R4,R4,#2
 1060STRB R14,[R2,R4]
 1070
 1080BL RemoveLeading0s
 1090LDMFD R13!,{PC}
 1100
 1110.divres
 1120EQUD 0
 1130.modres
 1140EQUD 0
 1150
 1160.begin_division
 1170STMFD R13!,{R14}
 1180
 1190\A VALUE OF TEN CORRESPONDS TO TERMINATING BYTE
 1200
 1210BL get_addresses
 1220
 1230
 1240\find end of operand1 AND operand2
 1250
 1260MOV R3,R0
 1270MOV R5,#0
 1280.loop_get_end1b
 1290  LDRB R4,[R3],#1
 1300  ADD R5,R5,#1
 1310  CMP R4,#10
 1320BNE loop_get_end1b
 1330ADD R5,R5,#1
 1340
 1350MOV R3,R1
 1360MOV R6,#0
 1370.loop_get_end2b
 1380  LDRB R4,[R3],#1
 1390  ADD R6,R6,#1
 1400  CMP R4,#10
 1410BNE loop_get_end2b
 1420SUB R6,R6,#1
 1430
 1440\LENGTH OF OPERAND 1 IS RETURNED IN R5, LENGTH OF OPERAND 2 IS IN R6
 1450
 1460\REGISTERS AVAILABLE R3,R4,R8-R12,R14 - carry=8
 1470
 1480MOV R7,#0
 1490.for_loopify1b
 1500  ADD R3,R0,R7
 1510  MVN R4,#0
 1520
 1530  .repeat1
 1540    ADD R4,R4,#1
 1550    MOV carry,#1
 1560    SUB R9,R6,#1
 1570    .for_loopify2b
 1580      MOV R10,#0
 1590      CMP R9,#0
 1600      LDRGEB R10,[R1,R9]
 1610
 1620      LDRB R14,[R3,R9]
 1630      SUB R10,R14,R10
 1640      ADD R10,R10,carry
 1650      ADD R10,R10,#9
 1660
 1670      \ASSEMBLE MOD AND DIV FUNCTION
 1680      STMFD R13!,{R0-R6}
 1690      MOV R0,R10
 1700      MOV R1,#10
 1710      ANDS R6,R0,#1<<31
 1720      RSBMI R0,R0,#0
 1730      EOR R5,R6,R1
 1740      CMP R1,#0
 1750      RSBMI R1,R1,#0
 1760
 1770      MOV R2,#0
 1780      MOV R3,#0
 1790      MOV R4,#1<<31
 1800
 1810      .division_loop2
 1820      MOVS R0,R0,ASL#1
 1830      ADC R2,R2,R2
 1840      CMP R2,R1
 1850      SUBGE R2,R2,R1
 1860      ORRGE R3,R3,R4
 1870      MOVS R4,R4,LSR#1
 1880      BNE division_loop2
 1890
 1900      CMP R5,#0
 1910      RSBMI R3,R3,#0
 1920      CMP R6,#0
 1930      RSBMI R2,R2,#0
 1940
 1950      STR R3,divres2
 1960      STR R2,modres2
 1970
 1980      LDMFD R13!,{R0-R6}
 1990
 2000      LDR R14,modres2
 2010      STRB R14,[R3,R9]
 2020      LDR R8,divres2
 2030      SUB R9,R9,#1
 2040      CMN R9,R7
 2050
 2060
 2070    BNE for_loopify2b
 2080    CMP carry,#0
 2090  BNE repeat1
 2100  SUB R9,R6,#1
 2110    .for_loopify3b
 2120    MOV R10,#0
 2130    CMP R9,#0
 2140    LDRGEB R10,[R1,R9]
 2150    LDRB R14,[R3,R9]
 2160    ADD R10,R10,R14
 2170    ADD R10,R10,carry
 2180
 2190    \ASSEMBLE MOD AND DIV FUNCTION
 2200    STMFD R13!,{R0-R6}
 2210    MOV R0,R10
 2220    MOV R1,#10
 2230    ANDS R6,R0,#1<<31
 2240    RSBMI R0,R0,#0
 2250    EOR R5,R6,R1
 2260    CMP R1,#0
 2270    RSBMI R1,R1,#0
 2280
 2290    MOV R2,#0
 2300    MOV R3,#0
 2310    MOV R4,#1<<31
 2320
 2330    .division_loop3
 2340    MOVS R0,R0,ASL#1
 2350    ADC R2,R2,R2
 2360    CMP R2,R1
 2370    SUBGE R2,R2,R1
 2380    ORRGE R3,R3,R4
 2390    MOVS R4,R4,LSR#1
 2400    BNE division_loop3
 2410
 2420    CMP R5,#0
 2430    RSBMI R3,R3,#0
 2440    CMP R6,#0
 2450    RSBMI R2,R2,#0
 2460
 2470    STR R3,divres2
 2480    STR R2,modres2
 2490
 2500    LDMFD R13!,{R0-R6}
 2510
 2520    LDR R14,modres2
 2530    STRB R14,[R3,R9]
 2540    LDR R8,divres2
 2550    SUB R9,R9,#1
 2560    CMN R9,R7
 2570  BNE for_loopify3b
 2580  STRB R4,[R2,R7]
 2590  ADD R7,R7,#1
 2600  SUB R14,R5,R6
 2610  CMP R7,R14
 2620BLT for_loopify1b
 2630MOV R14,#10
 2640STRB R14,[R2,R7]
 2650
 2660BL RemoveLeading0s
 2670LDMFD R13!,{PC}
 2680
 2690
 2700.divres2
 2710EQUD 0
 2720.modres2
 2730EQUD 0
 2740
 2750.begin_multiplication
 2760STMFD R13!,{R14}
 2770
 2780\A VALUE OF TEN CORRESPONDS TO TERMINATING BYTE
 2790
 2800BL get_addresses
 2810
 2820
 2830\find end of operand1 AND operand2
 2840
 2850MOV R3,R0
 2860MOV R5,#0
 2870.loop_get_end1d
 2880  LDRB R4,[R3],#1
 2890  ADD R5,R5,#1
 2900  CMP R4,#10
 2910BNE loop_get_end1d
 2920
 2930MOV R3,R1
 2940MOV R6,#0
 2950.loop_get_end2d
 2960  LDRB R4,[R3],#1
 2970  ADD R6,R6,#1
 2980  CMP R4,#10
 2990BNE loop_get_end2d
 3000
 3010\LENGTH OF OPERAND 1 IS RETURNED IN R5, LENGTH OF OPERAND 2 IS IN R6
 3020
 3030ADD R7,R5,R6             \CONTAINS TOTAL LENGTHS
 3040
 3050\REGISTERS AVAILABLE = R3,R4,R8-R12,R14
 3060
 3070\structure For..next loop-
 3080
 3090MOV R3,#0
 3100MOV R4,R2
 3110SUB R14,R7,#1 \LOOP COUNTER
 3120.for_loopify1d
 3130  STRB R3,[R4],#1
 3140  SUBS R14,R14,#1
 3150BNE for_loopify1d
 3160MOV R3,#10
 3170STRB R3,[R4]
 3180
 3190SUB R11,R6,#2
 3200.for_loopify2d
 3210  MOV carry,#0
 3220  LDRB R3,[R1,R11]
 3230  ADD R4,R2,R11
 3240  ADD R4,R4,#1
 3250  SUB R10,R5,#2
 3260  .for_loopify3d
 3270    LDRB R9,[R0,R10]
 3280    MUL R14,R3,R9
 3290    ADD R14,R14,carry
 3300    STMFD R13!,{R8}
 3310    LDRB R8,[R4,R10]
 3320    ADD R14,R14,R8
 3330
 3340    \ASSEMBLE MOD AND DIV FUNCTION
 3350    STMFD R13!,{R0-R6}
 3360    MOV R0,R14
 3370    MOV R1,#10
 3380    ANDS R6,R0,#1<<31
 3390    RSBMI R0,R0,#0
 3400    EOR R5,R6,R1
 3410    CMP R1,#0
 3420    RSBMI R1,R1,#0
 3430
 3440    MOV R2,#0
 3450    MOV R3,#0
 3460    MOV R4,#1<<31
 3470
 3480    .division_loopd
 3490    MOVS R0,R0,ASL#1
 3500    ADC R2,R2,R2
 3510    CMP R2,R1
 3520    SUBGE R2,R2,R1
 3530    ORRGE R3,R3,R4
 3540    MOVS R4,R4,LSR#1
 3550    BNE division_loopd
 3560
 3570    CMP R5,#0
 3580    RSBMI R3,R3,#0
 3590    CMP R6,#0
 3600    RSBMI R2,R2,#0
 3610
 3620    STR R3,divresd
 3630    STR R2,modresd
 3640
 3650    LDMFD R13!,{R0-R6}
 3660
 3670    LDR R8,modresd
 3680    STRB R8,[R4,R10]
 3690    LDMFD R13!,{R8}
 3700    LDR R8,divresd
 3710    SUBS R10,R10,#1
 3720  BNE for_loopify3d
 3730  STRB R8,[R4,R10]
 3740  SUBS R11,R11,#1
 3750BNE for_loopify2d
 3760
 3770BL RemoveLeading0s
 3780LDMFD R13!,{PC}
 3790
 3800.divresd
 3810EQUD 0
 3820.modresd
 3830EQUD 0
 3840
 3850
 3860
 3870.get_addresses
 3880STMFD R13!,{R14}
 3890ADR R0,operand1
 3900B addn1
 3910
 3920.operand1
 3930FNBytes(accuracy%)
 3940
 3950.addn1
 3960ADR R1,operand2
 3970B addn2
 3980
 3990.operand2
 4000FNBytes(accuracy%)
 4010
 4020.addn2
 4030ADR R2,result
 4040
 4050BL flush_result
 4060LDMFD R13!,{PC}
 4070
 4080.result
 4090FNBytes(2*accuracy%)
 4100ALIGN
 4110
 4120.RemoveLeading0s
 4130STMFD R13!,{R14}
 4140:
 4150MOV R4,#0
 4160.loop_remove0s
 4170LDRB R5,[R2,R4]
 4180CMP R5,#0
 4190ADDEQ R4,R4,#1
 4200BEQ loop_remove0s
 4210
 4220MOV R3,#0
 4230.loop_swap_string
 4240LDRB R5,[R2,R4]
 4250STRB R5,[R2,R3]
 4260CMP R5,#10
 4270ADDNE R4,R4,#1
 4280ADDNE R3,R3,#1
 4290BNE loop_swap_string
 4300
 4310:
 4320LDMFD R13!,{PC}
 4330
 4340.flush_result
 4350STMFD R13!,{R14}
 4360:
 4370MOV R3,#(2*accuracy%)
 4380MOV R4,#0
 4390.flushloop
 4400STRB R4,[R2,R3]
 4410SUBS R3,R3,#1
 4420BGE flushloop
 4430
 4440:
 4450LDMFD R13!,{PC}
 4460
 4470
 4480]
 4490NEXT
 4500:
 4510ENDPROC
 4520:
 4530DEFFNBytes(inc%)
 4540FOR Ninc=0 TO inc%
 4550P%?Ninc=0
 4560NEXT
 4570P%+=inc%
 4580=0

��assemble_calculator
/� � �:�" AN ERROR HAS BEEN DETECTED @ ";�:�
carry=8
(Laccuracy%=800   :� THIS IS THE MAXIMUM NUMBER OF DIGITS TO BE CALCULATED
2� code% 1200+(4*accuracy%)
<� pass%=0 � 2 � 2
FP%=code%
P[
Z
OPT pass%
d
n.begin_addition
xSTMFD R13!,{R14}
�
�BL get_addresses
�
�$\find end of operand1 � operand2
�
�
MOV R3,R0
�
MOV R5,#0
�.loop_get_end1
�  LDRB R4,[R3],#1
�  ADD R5,R5,#1
�  CMP R4,#10
�BNE loop_get_end1
�

MOV R3,R1

MOV R6,#0
.loop_get_end2
"  LDRB R4,[R3],#1
,  ADD R6,R6,#1
6  CMP R4,#10
@BNE loop_get_end2
J
TB\�GTH � OPERAND 1 IS RETURNED IN R5, �GTH � OPERAND 2 IS IN R6
^
h!SUB R3,R5,R6      \R3 IS DIFF
r
CMP R3,#0
|RSBLT R3,R3,#0
�
CMP R5,R6
�MOVLT R4,R1
�MOVLT R1,R0
�MOVLT R0,R4
�
�%MOVGT R4,R5      \R4 IS MAXLENGTH
�MOVLE R4,R6
�
�MOV carry,#0
�
�\structure for...next loop
�
�SUB R4,R4,#2

MOV R7,R4
  .for_loopify1c
  LDRB R9,[R0,R7]    \Q1%
&  SUBS R14,R7,R3
0  LDRGTB R10,[R1,R14]
:  MOVLE R10,#0       \Q2%
D  ADD R9,R9,R10
N  ADD R9,R9,carry
X
b
l     \ASSEMBLE � � � FUNCTION
v    STMFD R13!,{R0-R6}
�    MOV R0,R9
�    MOV R1,#10
�    �S R6,R0,#1<<31
�    RSBMI R0,R0,#0
�    � R5,R6,R1
�    CMP R1,#0
�    RSBMI R1,R1,#0
�
�    MOV R2,#0
�    MOV R3,#0
�    MOV R4,#1<<31
�
�    .division_loop
    MOVS R0,R0,ASL#1
    ADC R2,R2,R2
    CMP R2,R1
     SUBGE R2,R2,R1
*    �RGE R3,R3,R4
4    MOVS R4,R4,LSR#1
>    BNE division_loop
H
R    CMP R5,#0
\    RSBMI R3,R3,#0
f    CMP R6,#0
p    RSBMI R2,R2,#0
z
�    STR R3,divres
�    STR R2,modres
�
�    LDMFD R13!,{R0-R6}
�
�  LDR R14,modres
�  STRB R14,[R2,R7]
�  LDR carry,divres
�
�  SUBS R7,R7,#1
�
�BNE for_loopify1c
�CMP carry,#0
STRNEB carry,[R2]
MOV R14,#10
ADD R4,R4,#2
$STRB R14,[R2,R4]
.
8BL RemoveLeading0s
BLDMFD R13!,{PC}
L
V.divres
`
EQUD 0
j.modres
t
EQUD 0
~
�.begin_division
�STMFD R13!,{R14}
�
�/\A �UE � TEN CORRESPONDS � TERMINATING BYTE
�
�BL get_addresses
�
�
�$\find end of operand1 � operand2
�
�
MOV R3,R0
�
MOV R5,#0
.loop_get_end1b

  LDRB R4,[R3],#1
  ADD R5,R5,#1
  CMP R4,#10
(BNE loop_get_end1b
2ADD R5,R5,#1
<
F
MOV R3,R1
P
MOV R6,#0
Z.loop_get_end2b
d  LDRB R4,[R3],#1
n  ADD R6,R6,#1
x  CMP R4,#10
�BNE loop_get_end2b
�SUB R6,R6,#1
�
�B\�GTH � OPERAND 1 IS RETURNED IN R5, �GTH � OPERAND 2 IS IN R6
�
�3\REGISTERS AVAILABLE R3,R4,R8-R12,R14 - carry=8
�
�
MOV R7,#0
�.for_loopify1b
�  ADD R3,R0,R7
�  MVN R4,#0
�
�  .repeat1
    ADD R4,R4,#1
    MOV carry,#1
    SUB R9,R6,#1
"    .for_loopify2b
,      MOV R10,#0
6      CMP R9,#0
@      LDRGEB R10,[R1,R9]
J
T      LDRB R14,[R3,R9]
^      SUB R10,R14,R10
h      ADD R10,R10,carry
r      ADD R10,R10,#9
|
�"      \ASSEMBLE � � � FUNCTION
�      STMFD R13!,{R0-R6}
�      MOV R0,R10
�      MOV R1,#10
�      �S R6,R0,#1<<31
�      RSBMI R0,R0,#0
�      � R5,R6,R1
�      CMP R1,#0
�      RSBMI R1,R1,#0
�
�      MOV R2,#0
�      MOV R3,#0
�      MOV R4,#1<<31

      .division_loop2
      MOVS R0,R0,ASL#1
&      ADC R2,R2,R2
0      CMP R2,R1
:      SUBGE R2,R2,R1
D      �RGE R3,R3,R4
N      MOVS R4,R4,LSR#1
X      BNE division_loop2
b
l      CMP R5,#0
v      RSBMI R3,R3,#0
�      CMP R6,#0
�      RSBMI R2,R2,#0
�
�      STR R3,divres2
�      STR R2,modres2
�
�      LDMFD R13!,{R0-R6}
�
�      LDR R14,modres2
�      STRB R14,[R3,R9]
�      LDR R8,divres2
�      SUB R9,R9,#1
�      CMN R9,R7


    BNE for_loopify2b
     CMP carry,#0
*  BNE repeat1
4  SUB R9,R6,#1
>    .for_loopify3b
H    MOV R10,#0
R    CMP R9,#0
\    LDRGEB R10,[R1,R9]
f    LDRB R14,[R3,R9]
p    ADD R10,R10,R14
z    ADD R10,R10,carry
�
�     \ASSEMBLE � � � FUNCTION
�    STMFD R13!,{R0-R6}
�    MOV R0,R10
�    MOV R1,#10
�    �S R6,R0,#1<<31
�    RSBMI R0,R0,#0
�    � R5,R6,R1
�    CMP R1,#0
�    RSBMI R1,R1,#0
�
�    MOV R2,#0
�    MOV R3,#0
	    MOV R4,#1<<31
	
	    .division_loop3
	$    MOVS R0,R0,ASL#1
	.    ADC R2,R2,R2
	8    CMP R2,R1
	B    SUBGE R2,R2,R1
	L    �RGE R3,R3,R4
	V    MOVS R4,R4,LSR#1
	`    BNE division_loop3
	j
	t    CMP R5,#0
	~    RSBMI R3,R3,#0
	�    CMP R6,#0
	�    RSBMI R2,R2,#0
	�
	�    STR R3,divres2
	�    STR R2,modres2
	�
	�    LDMFD R13!,{R0-R6}
	�
	�    LDR R14,modres2
	�    STRB R14,[R3,R9]
	�    LDR R8,divres2
	�    SUB R9,R9,#1
    CMN R9,R7

  BNE for_loopify3b
  STRB R4,[R2,R7]
  ADD R7,R7,#1
(  SUB R14,R5,R6
2  CMP R7,R14
<BLT for_loopify1b
FMOV R14,#10
PSTRB R14,[R2,R7]
Z
dBL RemoveLeading0s
nLDMFD R13!,{PC}
x
�
�.divres2
�
EQUD 0
�.modres2
�
EQUD 0
�
�.begin_multiplication
�STMFD R13!,{R14}
�
�/\A �UE � TEN CORRESPONDS � TERMINATING BYTE
�
�BL get_addresses
�

$\find end of operand1 � operand2

"
MOV R3,R0
,
MOV R5,#0
6.loop_get_end1d
@  LDRB R4,[R3],#1
J  ADD R5,R5,#1
T  CMP R4,#10
^BNE loop_get_end1d
h
r
MOV R3,R1
|
MOV R6,#0
�.loop_get_end2d
�  LDRB R4,[R3],#1
�  ADD R6,R6,#1
�  CMP R4,#10
�BNE loop_get_end2d
�
�B\�GTH � OPERAND 1 IS RETURNED IN R5, �GTH � OPERAND 2 IS IN R6
�
�1ADD R7,R5,R6             \CONTAINS �TAL �GTHS
�
�+\REGISTERS AVAILABLE = R3,R4,R8-R12,R14
�
�\structure For..next loop-


MOV R3,#0

MOV R4,R2
&SUB R14,R7,#1 \LOOP COUNTER
0.for_loopify1d
:  STRB R3,[R4],#1
D  SUBS R14,R14,#1
NBNE for_loopify1d
XMOV R3,#10
bSTRB R3,[R4]
l
vSUB R11,R6,#2
�.for_loopify2d
�  MOV carry,#0
�  LDRB R3,[R1,R11]
�  ADD R4,R2,R11
�  ADD R4,R4,#1
�  SUB R10,R5,#2
�  .for_loopify3d
�    LDRB R9,[R0,R10]
�    MUL R14,R3,R9
�    ADD R14,R14,carry
�    STMFD R13!,{R8}
�    LDRB R8,[R4,R10]
�    ADD R14,R14,R8



     \ASSEMBLE � � � FUNCTION

    STMFD R13!,{R0-R6}

     MOV R0,R14

*    MOV R1,#10

4    �S R6,R0,#1<<31

>    RSBMI R0,R0,#0

H    � R5,R6,R1

R    CMP R1,#0

\    RSBMI R1,R1,#0

f

p    MOV R2,#0

z    MOV R3,#0

�    MOV R4,#1<<31

�

�    .division_loopd

�    MOVS R0,R0,ASL#1

�    ADC R2,R2,R2

�    CMP R2,R1

�    SUBGE R2,R2,R1

�    �RGE R3,R3,R4

�    MOVS R4,R4,LSR#1

�    BNE division_loopd

�

�    CMP R5,#0

�    RSBMI R3,R3,#0
    CMP R6,#0
    RSBMI R2,R2,#0

$    STR R3,divresd
.    STR R2,modresd
8
B    LDMFD R13!,{R0-R6}
L
V    LDR R8,modresd
`    STRB R8,[R4,R10]
j    LDMFD R13!,{R8}
t    LDR R8,divresd
~    SUBS R10,R10,#1
�  BNE for_loopify3d
�  STRB R8,[R4,R10]
�  SUBS R11,R11,#1
�BNE for_loopify2d
�
�BL RemoveLeading0s
�LDMFD R13!,{PC}
�
�.divresd
�
EQUD 0
�.modresd
�
EQUD 0




.get_addresses
(STMFD R13!,{R14}
2ADR R0,operand1
<B addn1
F
P
.operand1
Z�Bytes(accuracy%)
d
n
.addn1
xADR R1,operand2
�B addn2
�
�
.operand2
��Bytes(accuracy%)
�
�
.addn2
�ADR R2,result
�
�BL flush_result
�LDMFD R13!,{PC}
�
�.result
��Bytes(2*accuracy%)
	ALIGN

.RemoveLeading0s
"STMFD R13!,{R14}
,:
6
MOV R4,#0
@.loop_remove0s
JLDRB R5,[R2,R4]
T
CMP R5,#0
^ADDEQ R4,R4,#1
hBEQ loop_remove0s
r
|
MOV R3,#0
�.loop_swap_string
�LDRB R5,[R2,R4]
�STRB R5,[R2,R3]
�CMP R5,#10
�ADDNE R4,R4,#1
�ADDNE R3,R3,#1
�BNE loop_swap_string
�
�:
�LDMFD R13!,{PC}
�
�.flush_result
�STMFD R13!,{R14}
:
MOV R3,#(2*accuracy%)

MOV R4,#0
&.flushloop
0STRB R4,[R2,R3]
:SUBS R3,R3,#1
DBGE flushloop
N
X:
bLDMFD R13!,{PC}
l
v
�]
��
�:
��
�:
�ݤBytes(inc%)
�� Ninc=0 � inc%
�
P%?Ninc=0
��
�P%+=inc%
�=0
�
00000000  0d 00 0a 19 dd f2 61 73  73 65 6d 62 6c 65 5f 63  |......assemble_c|
00000010  61 6c 63 75 6c 61 74 6f  72 0d 00 14 2f ee 20 85  |alculator.../. .|
00000020  20 f6 3a f1 22 20 41 4e  20 45 52 52 4f 52 20 48  | .:." AN ERROR H|
00000030  41 53 20 42 45 45 4e 20  44 45 54 45 43 54 45 44  |AS BEEN DETECTED|
00000040  20 40 20 22 3b 9e 3a e0  0d 00 1e 0b 63 61 72 72  | @ ";.:.....carr|
00000050  79 3d 38 0d 00 28 4c 61  63 63 75 72 61 63 79 25  |y=8..(Laccuracy%|
00000060  3d 38 30 30 20 20 20 3a  f4 20 54 48 49 53 20 49  |=800   :. THIS I|
00000070  53 20 54 48 45 20 4d 41  58 49 4d 55 4d 20 4e 55  |S THE MAXIMUM NU|
00000080  4d 42 45 52 20 4f 46 20  44 49 47 49 54 53 20 54  |MBER OF DIGITS T|
00000090  4f 20 42 45 20 43 41 4c  43 55 4c 41 54 45 44 0d  |O BE CALCULATED.|
000000a0  00 32 1e de 20 63 6f 64  65 25 20 31 32 30 30 2b  |.2.. code% 1200+|
000000b0  28 34 2a 61 63 63 75 72  61 63 79 25 29 0d 00 3c  |(4*accuracy%)..<|
000000c0  15 e3 20 70 61 73 73 25  3d 30 20 b8 20 32 20 88  |.. pass%=0 . 2 .|
000000d0  20 32 0d 00 46 0c 50 25  3d 63 6f 64 65 25 0d 00  | 2..F.P%=code%..|
000000e0  50 05 5b 0d 00 5a 0d 4f  50 54 20 70 61 73 73 25  |P.[..Z.OPT pass%|
000000f0  0d 00 64 04 0d 00 6e 13  2e 62 65 67 69 6e 5f 61  |..d...n..begin_a|
00000100  64 64 69 74 69 6f 6e 0d  00 78 14 53 54 4d 46 44  |ddition..x.STMFD|
00000110  20 52 31 33 21 2c 7b 52  31 34 7d 0d 00 82 04 0d  | R13!,{R14}.....|
00000120  00 8c 14 42 4c 20 67 65  74 5f 61 64 64 72 65 73  |...BL get_addres|
00000130  73 65 73 0d 00 96 04 0d  00 a0 24 5c 66 69 6e 64  |ses.......$\find|
00000140  20 65 6e 64 20 6f 66 20  6f 70 65 72 61 6e 64 31  | end of operand1|
00000150  20 80 20 6f 70 65 72 61  6e 64 32 0d 00 aa 04 0d  | . operand2.....|
00000160  00 b4 0d 4d 4f 56 20 52  33 2c 52 30 0d 00 be 0d  |...MOV R3,R0....|
00000170  4d 4f 56 20 52 35 2c 23  30 0d 00 c8 12 2e 6c 6f  |MOV R5,#0.....lo|
00000180  6f 70 5f 67 65 74 5f 65  6e 64 31 0d 00 d2 15 20  |op_get_end1.... |
00000190  20 4c 44 52 42 20 52 34  2c 5b 52 33 5d 2c 23 31  | LDRB R4,[R3],#1|
000001a0  0d 00 dc 12 20 20 41 44  44 20 52 35 2c 52 35 2c  |....  ADD R5,R5,|
000001b0  23 31 0d 00 e6 10 20 20  43 4d 50 20 52 34 2c 23  |#1....  CMP R4,#|
000001c0  31 30 0d 00 f0 15 42 4e  45 20 6c 6f 6f 70 5f 67  |10....BNE loop_g|
000001d0  65 74 5f 65 6e 64 31 0d  00 fa 04 0d 01 04 0d 4d  |et_end1........M|
000001e0  4f 56 20 52 33 2c 52 31  0d 01 0e 0d 4d 4f 56 20  |OV R3,R1....MOV |
000001f0  52 36 2c 23 30 0d 01 18  12 2e 6c 6f 6f 70 5f 67  |R6,#0.....loop_g|
00000200  65 74 5f 65 6e 64 32 0d  01 22 15 20 20 4c 44 52  |et_end2..".  LDR|
00000210  42 20 52 34 2c 5b 52 33  5d 2c 23 31 0d 01 2c 12  |B R4,[R3],#1..,.|
00000220  20 20 41 44 44 20 52 36  2c 52 36 2c 23 31 0d 01  |  ADD R6,R6,#1..|
00000230  36 10 20 20 43 4d 50 20  52 34 2c 23 31 30 0d 01  |6.  CMP R4,#10..|
00000240  40 15 42 4e 45 20 6c 6f  6f 70 5f 67 65 74 5f 65  |@.BNE loop_get_e|
00000250  6e 64 32 0d 01 4a 04 0d  01 54 42 5c a9 47 54 48  |nd2..J...TB\.GTH|
00000260  20 ca 20 4f 50 45 52 41  4e 44 20 31 20 49 53 20  | . OPERAND 1 IS |
00000270  52 45 54 55 52 4e 45 44  20 49 4e 20 52 35 2c 20  |RETURNED IN R5, |
00000280  a9 47 54 48 20 ca 20 4f  50 45 52 41 4e 44 20 32  |.GTH . OPERAND 2|
00000290  20 49 53 20 49 4e 20 52  36 0d 01 5e 04 0d 01 68  | IS IN R6..^...h|
000002a0  21 53 55 42 20 52 33 2c  52 35 2c 52 36 20 20 20  |!SUB R3,R5,R6   |
000002b0  20 20 20 5c 52 33 20 49  53 20 44 49 46 46 0d 01  |   \R3 IS DIFF..|
000002c0  72 0d 43 4d 50 20 52 33  2c 23 30 0d 01 7c 12 52  |r.CMP R3,#0..|.R|
000002d0  53 42 4c 54 20 52 33 2c  52 33 2c 23 30 0d 01 86  |SBLT R3,R3,#0...|
000002e0  0d 43 4d 50 20 52 35 2c  52 36 0d 01 90 0f 4d 4f  |.CMP R5,R6....MO|
000002f0  56 4c 54 20 52 34 2c 52  31 0d 01 9a 0f 4d 4f 56  |VLT R4,R1....MOV|
00000300  4c 54 20 52 31 2c 52 30  0d 01 a4 0f 4d 4f 56 4c  |LT R1,R0....MOVL|
00000310  54 20 52 30 2c 52 34 0d  01 ae 04 0d 01 b8 25 4d  |T R0,R4.......%M|
00000320  4f 56 47 54 20 52 34 2c  52 35 20 20 20 20 20 20  |OVGT R4,R5      |
00000330  5c 52 34 20 49 53 20 4d  41 58 4c 45 4e 47 54 48  |\R4 IS MAXLENGTH|
00000340  0d 01 c2 0f 4d 4f 56 4c  45 20 52 34 2c 52 36 0d  |....MOVLE R4,R6.|
00000350  01 cc 04 0d 01 d6 10 4d  4f 56 20 63 61 72 72 79  |.......MOV carry|
00000360  2c 23 30 0d 01 e0 04 0d  01 ea 1e 5c 73 74 72 75  |,#0........\stru|
00000370  63 74 75 72 65 20 66 6f  72 2e 2e 2e 6e 65 78 74  |cture for...next|
00000380  20 6c 6f 6f 70 0d 01 f4  04 0d 01 fe 10 53 55 42  | loop........SUB|
00000390  20 52 34 2c 52 34 2c 23  32 0d 02 08 0d 4d 4f 56  | R4,R4,#2....MOV|
000003a0  20 52 37 2c 52 34 0d 02  12 14 20 20 2e 66 6f 72  | R7,R4....  .for|
000003b0  5f 6c 6f 6f 70 69 66 79  31 63 0d 02 1c 1d 20 20  |_loopify1c....  |
000003c0  4c 44 52 42 20 52 39 2c  5b 52 30 2c 52 37 5d 20  |LDRB R9,[R0,R7] |
000003d0  20 20 20 5c 51 31 25 0d  02 26 14 20 20 53 55 42  |   \Q1%..&.  SUB|
000003e0  53 20 52 31 34 2c 52 37  2c 52 33 0d 02 30 19 20  |S R14,R7,R3..0. |
000003f0  20 4c 44 52 47 54 42 20  52 31 30 2c 5b 52 31 2c  | LDRGTB R10,[R1,|
00000400  52 31 34 5d 0d 02 3a 1d  20 20 4d 4f 56 4c 45 20  |R14]..:.  MOVLE |
00000410  52 31 30 2c 23 30 20 20  20 20 20 20 20 5c 51 32  |R10,#0       \Q2|
00000420  25 0d 02 44 13 20 20 41  44 44 20 52 39 2c 52 39  |%..D.  ADD R9,R9|
00000430  2c 52 31 30 0d 02 4e 15  20 20 41 44 44 20 52 39  |,R10..N.  ADD R9|
00000440  2c 52 39 2c 63 61 72 72  79 0d 02 58 04 0d 02 62  |,R9,carry..X...b|
00000450  04 0d 02 6c 20 20 20 20  20 5c 41 53 53 45 4d 42  |...l     \ASSEMB|
00000460  4c 45 20 83 20 80 20 81  20 46 55 4e 43 54 49 4f  |LE . . . FUNCTIO|
00000470  4e 0d 02 76 1a 20 20 20  20 53 54 4d 46 44 20 52  |N..v.    STMFD R|
00000480  31 33 21 2c 7b 52 30 2d  52 36 7d 0d 02 80 11 20  |13!,{R0-R6}.... |
00000490  20 20 20 4d 4f 56 20 52  30 2c 52 39 0d 02 8a 12  |   MOV R0,R9....|
000004a0  20 20 20 20 4d 4f 56 20  52 31 2c 23 31 30 0d 02  |    MOV R1,#10..|
000004b0  94 17 20 20 20 20 80 53  20 52 36 2c 52 30 2c 23  |..    .S R6,R0,#|
000004c0  31 3c 3c 33 31 0d 02 9e  16 20 20 20 20 52 53 42  |1<<31....    RSB|
000004d0  4d 49 20 52 30 2c 52 30  2c 23 30 0d 02 a8 12 20  |MI R0,R0,#0.... |
000004e0  20 20 20 82 20 52 35 2c  52 36 2c 52 31 0d 02 b2  |   . R5,R6,R1...|
000004f0  11 20 20 20 20 43 4d 50  20 52 31 2c 23 30 0d 02  |.    CMP R1,#0..|
00000500  bc 16 20 20 20 20 52 53  42 4d 49 20 52 31 2c 52  |..    RSBMI R1,R|
00000510  31 2c 23 30 0d 02 c6 04  0d 02 d0 11 20 20 20 20  |1,#0........    |
00000520  4d 4f 56 20 52 32 2c 23  30 0d 02 da 11 20 20 20  |MOV R2,#0....   |
00000530  20 4d 4f 56 20 52 33 2c  23 30 0d 02 e4 15 20 20  | MOV R3,#0....  |
00000540  20 20 4d 4f 56 20 52 34  2c 23 31 3c 3c 33 31 0d  |  MOV R4,#1<<31.|
00000550  02 ee 04 0d 02 f8 16 20  20 20 20 2e 64 69 76 69  |.......    .divi|
00000560  73 69 6f 6e 5f 6c 6f 6f  70 0d 03 02 18 20 20 20  |sion_loop....   |
00000570  20 4d 4f 56 53 20 52 30  2c 52 30 2c 41 53 4c 23  | MOVS R0,R0,ASL#|
00000580  31 0d 03 0c 14 20 20 20  20 41 44 43 20 52 32 2c  |1....    ADC R2,|
00000590  52 32 2c 52 32 0d 03 16  11 20 20 20 20 43 4d 50  |R2,R2....    CMP|
000005a0  20 52 32 2c 52 31 0d 03  20 16 20 20 20 20 53 55  | R2,R1.. .    SU|
000005b0  42 47 45 20 52 32 2c 52  32 2c 52 31 0d 03 2a 15  |BGE R2,R2,R1..*.|
000005c0  20 20 20 20 84 52 47 45  20 52 33 2c 52 33 2c 52  |    .RGE R3,R3,R|
000005d0  34 0d 03 34 18 20 20 20  20 4d 4f 56 53 20 52 34  |4..4.    MOVS R4|
000005e0  2c 52 34 2c 4c 53 52 23  31 0d 03 3e 19 20 20 20  |,R4,LSR#1..>.   |
000005f0  20 42 4e 45 20 64 69 76  69 73 69 6f 6e 5f 6c 6f  | BNE division_lo|
00000600  6f 70 0d 03 48 04 0d 03  52 11 20 20 20 20 43 4d  |op..H...R.    CM|
00000610  50 20 52 35 2c 23 30 0d  03 5c 16 20 20 20 20 52  |P R5,#0..\.    R|
00000620  53 42 4d 49 20 52 33 2c  52 33 2c 23 30 0d 03 66  |SBMI R3,R3,#0..f|
00000630  11 20 20 20 20 43 4d 50  20 52 36 2c 23 30 0d 03  |.    CMP R6,#0..|
00000640  70 16 20 20 20 20 52 53  42 4d 49 20 52 32 2c 52  |p.    RSBMI R2,R|
00000650  32 2c 23 30 0d 03 7a 04  0d 03 84 15 20 20 20 20  |2,#0..z.....    |
00000660  53 54 52 20 52 33 2c 64  69 76 72 65 73 0d 03 8e  |STR R3,divres...|
00000670  15 20 20 20 20 53 54 52  20 52 32 2c 6d 6f 64 72  |.    STR R2,modr|
00000680  65 73 0d 03 98 04 0d 03  a2 1a 20 20 20 20 4c 44  |es........    LD|
00000690  4d 46 44 20 52 31 33 21  2c 7b 52 30 2d 52 36 7d  |MFD R13!,{R0-R6}|
000006a0  0d 03 ac 04 0d 03 b6 14  20 20 4c 44 52 20 52 31  |........  LDR R1|
000006b0  34 2c 6d 6f 64 72 65 73  0d 03 c0 16 20 20 53 54  |4,modres....  ST|
000006c0  52 42 20 52 31 34 2c 5b  52 32 2c 52 37 5d 0d 03  |RB R14,[R2,R7]..|
000006d0  ca 16 20 20 4c 44 52 20  63 61 72 72 79 2c 64 69  |..  LDR carry,di|
000006e0  76 72 65 73 0d 03 d4 04  0d 03 de 13 20 20 53 55  |vres........  SU|
000006f0  42 53 20 52 37 2c 52 37  2c 23 31 0d 03 e8 04 0d  |BS R7,R7,#1.....|
00000700  03 f2 15 42 4e 45 20 66  6f 72 5f 6c 6f 6f 70 69  |...BNE for_loopi|
00000710  66 79 31 63 0d 03 fc 10  43 4d 50 20 63 61 72 72  |fy1c....CMP carr|
00000720  79 2c 23 30 0d 04 06 15  53 54 52 4e 45 42 20 63  |y,#0....STRNEB c|
00000730  61 72 72 79 2c 5b 52 32  5d 0d 04 10 0f 4d 4f 56  |arry,[R2]....MOV|
00000740  20 52 31 34 2c 23 31 30  0d 04 1a 10 41 44 44 20  | R14,#10....ADD |
00000750  52 34 2c 52 34 2c 23 32  0d 04 24 14 53 54 52 42  |R4,R4,#2..$.STRB|
00000760  20 52 31 34 2c 5b 52 32  2c 52 34 5d 0d 04 2e 04  | R14,[R2,R4]....|
00000770  0d 04 38 16 42 4c 20 52  65 6d 6f 76 65 4c 65 61  |..8.BL RemoveLea|
00000780  64 69 6e 67 30 73 0d 04  42 13 4c 44 4d 46 44 20  |ding0s..B.LDMFD |
00000790  52 31 33 21 2c 7b 50 43  7d 0d 04 4c 04 0d 04 56  |R13!,{PC}..L...V|
000007a0  0b 2e 64 69 76 72 65 73  0d 04 60 0a 45 51 55 44  |..divres..`.EQUD|
000007b0  20 30 0d 04 6a 0b 2e 6d  6f 64 72 65 73 0d 04 74  | 0..j..modres..t|
000007c0  0a 45 51 55 44 20 30 0d  04 7e 04 0d 04 88 13 2e  |.EQUD 0..~......|
000007d0  62 65 67 69 6e 5f 64 69  76 69 73 69 6f 6e 0d 04  |begin_division..|
000007e0  92 14 53 54 4d 46 44 20  52 31 33 21 2c 7b 52 31  |..STMFD R13!,{R1|
000007f0  34 7d 0d 04 9c 04 0d 04  a6 2f 5c 41 20 bb 55 45  |4}......./\A .UE|
00000800  20 ca 20 54 45 4e 20 43  4f 52 52 45 53 50 4f 4e  | . TEN CORRESPON|
00000810  44 53 20 b8 20 54 45 52  4d 49 4e 41 54 49 4e 47  |DS . TERMINATING|
00000820  20 42 59 54 45 0d 04 b0  04 0d 04 ba 14 42 4c 20  | BYTE........BL |
00000830  67 65 74 5f 61 64 64 72  65 73 73 65 73 0d 04 c4  |get_addresses...|
00000840  04 0d 04 ce 04 0d 04 d8  24 5c 66 69 6e 64 20 65  |........$\find e|
00000850  6e 64 20 6f 66 20 6f 70  65 72 61 6e 64 31 20 80  |nd of operand1 .|
00000860  20 6f 70 65 72 61 6e 64  32 0d 04 e2 04 0d 04 ec  | operand2.......|
00000870  0d 4d 4f 56 20 52 33 2c  52 30 0d 04 f6 0d 4d 4f  |.MOV R3,R0....MO|
00000880  56 20 52 35 2c 23 30 0d  05 00 13 2e 6c 6f 6f 70  |V R5,#0.....loop|
00000890  5f 67 65 74 5f 65 6e 64  31 62 0d 05 0a 15 20 20  |_get_end1b....  |
000008a0  4c 44 52 42 20 52 34 2c  5b 52 33 5d 2c 23 31 0d  |LDRB R4,[R3],#1.|
000008b0  05 14 12 20 20 41 44 44  20 52 35 2c 52 35 2c 23  |...  ADD R5,R5,#|
000008c0  31 0d 05 1e 10 20 20 43  4d 50 20 52 34 2c 23 31  |1....  CMP R4,#1|
000008d0  30 0d 05 28 16 42 4e 45  20 6c 6f 6f 70 5f 67 65  |0..(.BNE loop_ge|
000008e0  74 5f 65 6e 64 31 62 0d  05 32 10 41 44 44 20 52  |t_end1b..2.ADD R|
000008f0  35 2c 52 35 2c 23 31 0d  05 3c 04 0d 05 46 0d 4d  |5,R5,#1..<...F.M|
00000900  4f 56 20 52 33 2c 52 31  0d 05 50 0d 4d 4f 56 20  |OV R3,R1..P.MOV |
00000910  52 36 2c 23 30 0d 05 5a  13 2e 6c 6f 6f 70 5f 67  |R6,#0..Z..loop_g|
00000920  65 74 5f 65 6e 64 32 62  0d 05 64 15 20 20 4c 44  |et_end2b..d.  LD|
00000930  52 42 20 52 34 2c 5b 52  33 5d 2c 23 31 0d 05 6e  |RB R4,[R3],#1..n|
00000940  12 20 20 41 44 44 20 52  36 2c 52 36 2c 23 31 0d  |.  ADD R6,R6,#1.|
00000950  05 78 10 20 20 43 4d 50  20 52 34 2c 23 31 30 0d  |.x.  CMP R4,#10.|
00000960  05 82 16 42 4e 45 20 6c  6f 6f 70 5f 67 65 74 5f  |...BNE loop_get_|
00000970  65 6e 64 32 62 0d 05 8c  10 53 55 42 20 52 36 2c  |end2b....SUB R6,|
00000980  52 36 2c 23 31 0d 05 96  04 0d 05 a0 42 5c a9 47  |R6,#1.......B\.G|
00000990  54 48 20 ca 20 4f 50 45  52 41 4e 44 20 31 20 49  |TH . OPERAND 1 I|
000009a0  53 20 52 45 54 55 52 4e  45 44 20 49 4e 20 52 35  |S RETURNED IN R5|
000009b0  2c 20 a9 47 54 48 20 ca  20 4f 50 45 52 41 4e 44  |, .GTH . OPERAND|
000009c0  20 32 20 49 53 20 49 4e  20 52 36 0d 05 aa 04 0d  | 2 IS IN R6.....|
000009d0  05 b4 33 5c 52 45 47 49  53 54 45 52 53 20 41 56  |..3\REGISTERS AV|
000009e0  41 49 4c 41 42 4c 45 20  52 33 2c 52 34 2c 52 38  |AILABLE R3,R4,R8|
000009f0  2d 52 31 32 2c 52 31 34  20 2d 20 63 61 72 72 79  |-R12,R14 - carry|
00000a00  3d 38 0d 05 be 04 0d 05  c8 0d 4d 4f 56 20 52 37  |=8........MOV R7|
00000a10  2c 23 30 0d 05 d2 12 2e  66 6f 72 5f 6c 6f 6f 70  |,#0.....for_loop|
00000a20  69 66 79 31 62 0d 05 dc  12 20 20 41 44 44 20 52  |ify1b....  ADD R|
00000a30  33 2c 52 30 2c 52 37 0d  05 e6 0f 20 20 4d 56 4e  |3,R0,R7....  MVN|
00000a40  20 52 34 2c 23 30 0d 05  f0 04 0d 05 fa 0e 20 20  | R4,#0........  |
00000a50  2e 72 65 70 65 61 74 31  0d 06 04 14 20 20 20 20  |.repeat1....    |
00000a60  41 44 44 20 52 34 2c 52  34 2c 23 31 0d 06 0e 14  |ADD R4,R4,#1....|
00000a70  20 20 20 20 4d 4f 56 20  63 61 72 72 79 2c 23 31  |    MOV carry,#1|
00000a80  0d 06 18 14 20 20 20 20  53 55 42 20 52 39 2c 52  |....    SUB R9,R|
00000a90  36 2c 23 31 0d 06 22 16  20 20 20 20 2e 66 6f 72  |6,#1..".    .for|
00000aa0  5f 6c 6f 6f 70 69 66 79  32 62 0d 06 2c 14 20 20  |_loopify2b..,.  |
00000ab0  20 20 20 20 4d 4f 56 20  52 31 30 2c 23 30 0d 06  |    MOV R10,#0..|
00000ac0  36 13 20 20 20 20 20 20  43 4d 50 20 52 39 2c 23  |6.      CMP R9,#|
00000ad0  30 0d 06 40 1c 20 20 20  20 20 20 4c 44 52 47 45  |0..@.      LDRGE|
00000ae0  42 20 52 31 30 2c 5b 52  31 2c 52 39 5d 0d 06 4a  |B R10,[R1,R9]..J|
00000af0  04 0d 06 54 1a 20 20 20  20 20 20 4c 44 52 42 20  |...T.      LDRB |
00000b00  52 31 34 2c 5b 52 33 2c  52 39 5d 0d 06 5e 19 20  |R14,[R3,R9]..^. |
00000b10  20 20 20 20 20 53 55 42  20 52 31 30 2c 52 31 34  |     SUB R10,R14|
00000b20  2c 52 31 30 0d 06 68 1b  20 20 20 20 20 20 41 44  |,R10..h.      AD|
00000b30  44 20 52 31 30 2c 52 31  30 2c 63 61 72 72 79 0d  |D R10,R10,carry.|
00000b40  06 72 18 20 20 20 20 20  20 41 44 44 20 52 31 30  |.r.      ADD R10|
00000b50  2c 52 31 30 2c 23 39 0d  06 7c 04 0d 06 86 22 20  |,R10,#9..|...." |
00000b60  20 20 20 20 20 5c 41 53  53 45 4d 42 4c 45 20 83  |     \ASSEMBLE .|
00000b70  20 80 20 81 20 46 55 4e  43 54 49 4f 4e 0d 06 90  | . . FUNCTION...|
00000b80  1c 20 20 20 20 20 20 53  54 4d 46 44 20 52 31 33  |.      STMFD R13|
00000b90  21 2c 7b 52 30 2d 52 36  7d 0d 06 9a 14 20 20 20  |!,{R0-R6}....   |
00000ba0  20 20 20 4d 4f 56 20 52  30 2c 52 31 30 0d 06 a4  |   MOV R0,R10...|
00000bb0  14 20 20 20 20 20 20 4d  4f 56 20 52 31 2c 23 31  |.      MOV R1,#1|
00000bc0  30 0d 06 ae 19 20 20 20  20 20 20 80 53 20 52 36  |0....      .S R6|
00000bd0  2c 52 30 2c 23 31 3c 3c  33 31 0d 06 b8 18 20 20  |,R0,#1<<31....  |
00000be0  20 20 20 20 52 53 42 4d  49 20 52 30 2c 52 30 2c  |    RSBMI R0,R0,|
00000bf0  23 30 0d 06 c2 14 20 20  20 20 20 20 82 20 52 35  |#0....      . R5|
00000c00  2c 52 36 2c 52 31 0d 06  cc 13 20 20 20 20 20 20  |,R6,R1....      |
00000c10  43 4d 50 20 52 31 2c 23  30 0d 06 d6 18 20 20 20  |CMP R1,#0....   |
00000c20  20 20 20 52 53 42 4d 49  20 52 31 2c 52 31 2c 23  |   RSBMI R1,R1,#|
00000c30  30 0d 06 e0 04 0d 06 ea  13 20 20 20 20 20 20 4d  |0........      M|
00000c40  4f 56 20 52 32 2c 23 30  0d 06 f4 13 20 20 20 20  |OV R2,#0....    |
00000c50  20 20 4d 4f 56 20 52 33  2c 23 30 0d 06 fe 17 20  |  MOV R3,#0.... |
00000c60  20 20 20 20 20 4d 4f 56  20 52 34 2c 23 31 3c 3c  |     MOV R4,#1<<|
00000c70  33 31 0d 07 08 04 0d 07  12 19 20 20 20 20 20 20  |31........      |
00000c80  2e 64 69 76 69 73 69 6f  6e 5f 6c 6f 6f 70 32 0d  |.division_loop2.|
00000c90  07 1c 1a 20 20 20 20 20  20 4d 4f 56 53 20 52 30  |...      MOVS R0|
00000ca0  2c 52 30 2c 41 53 4c 23  31 0d 07 26 16 20 20 20  |,R0,ASL#1..&.   |
00000cb0  20 20 20 41 44 43 20 52  32 2c 52 32 2c 52 32 0d  |   ADC R2,R2,R2.|
00000cc0  07 30 13 20 20 20 20 20  20 43 4d 50 20 52 32 2c  |.0.      CMP R2,|
00000cd0  52 31 0d 07 3a 18 20 20  20 20 20 20 53 55 42 47  |R1..:.      SUBG|
00000ce0  45 20 52 32 2c 52 32 2c  52 31 0d 07 44 17 20 20  |E R2,R2,R1..D.  |
00000cf0  20 20 20 20 84 52 47 45  20 52 33 2c 52 33 2c 52  |    .RGE R3,R3,R|
00000d00  34 0d 07 4e 1a 20 20 20  20 20 20 4d 4f 56 53 20  |4..N.      MOVS |
00000d10  52 34 2c 52 34 2c 4c 53  52 23 31 0d 07 58 1c 20  |R4,R4,LSR#1..X. |
00000d20  20 20 20 20 20 42 4e 45  20 64 69 76 69 73 69 6f  |     BNE divisio|
00000d30  6e 5f 6c 6f 6f 70 32 0d  07 62 04 0d 07 6c 13 20  |n_loop2..b...l. |
00000d40  20 20 20 20 20 43 4d 50  20 52 35 2c 23 30 0d 07  |     CMP R5,#0..|
00000d50  76 18 20 20 20 20 20 20  52 53 42 4d 49 20 52 33  |v.      RSBMI R3|
00000d60  2c 52 33 2c 23 30 0d 07  80 13 20 20 20 20 20 20  |,R3,#0....      |
00000d70  43 4d 50 20 52 36 2c 23  30 0d 07 8a 18 20 20 20  |CMP R6,#0....   |
00000d80  20 20 20 52 53 42 4d 49  20 52 32 2c 52 32 2c 23  |   RSBMI R2,R2,#|
00000d90  30 0d 07 94 04 0d 07 9e  18 20 20 20 20 20 20 53  |0........      S|
00000da0  54 52 20 52 33 2c 64 69  76 72 65 73 32 0d 07 a8  |TR R3,divres2...|
00000db0  18 20 20 20 20 20 20 53  54 52 20 52 32 2c 6d 6f  |.      STR R2,mo|
00000dc0  64 72 65 73 32 0d 07 b2  04 0d 07 bc 1c 20 20 20  |dres2........   |
00000dd0  20 20 20 4c 44 4d 46 44  20 52 31 33 21 2c 7b 52  |   LDMFD R13!,{R|
00000de0  30 2d 52 36 7d 0d 07 c6  04 0d 07 d0 19 20 20 20  |0-R6}........   |
00000df0  20 20 20 4c 44 52 20 52  31 34 2c 6d 6f 64 72 65  |   LDR R14,modre|
00000e00  73 32 0d 07 da 1a 20 20  20 20 20 20 53 54 52 42  |s2....      STRB|
00000e10  20 52 31 34 2c 5b 52 33  2c 52 39 5d 0d 07 e4 18  | R14,[R3,R9]....|
00000e20  20 20 20 20 20 20 4c 44  52 20 52 38 2c 64 69 76  |      LDR R8,div|
00000e30  72 65 73 32 0d 07 ee 16  20 20 20 20 20 20 53 55  |res2....      SU|
00000e40  42 20 52 39 2c 52 39 2c  23 31 0d 07 f8 13 20 20  |B R9,R9,#1....  |
00000e50  20 20 20 20 43 4d 4e 20  52 39 2c 52 37 0d 08 02  |    CMN R9,R7...|
00000e60  04 0d 08 0c 04 0d 08 16  19 20 20 20 20 42 4e 45  |.........    BNE|
00000e70  20 66 6f 72 5f 6c 6f 6f  70 69 66 79 32 62 0d 08  | for_loopify2b..|
00000e80  20 14 20 20 20 20 43 4d  50 20 63 61 72 72 79 2c  | .    CMP carry,|
00000e90  23 30 0d 08 2a 11 20 20  42 4e 45 20 72 65 70 65  |#0..*.  BNE repe|
00000ea0  61 74 31 0d 08 34 12 20  20 53 55 42 20 52 39 2c  |at1..4.  SUB R9,|
00000eb0  52 36 2c 23 31 0d 08 3e  16 20 20 20 20 2e 66 6f  |R6,#1..>.    .fo|
00000ec0  72 5f 6c 6f 6f 70 69 66  79 33 62 0d 08 48 12 20  |r_loopify3b..H. |
00000ed0  20 20 20 4d 4f 56 20 52  31 30 2c 23 30 0d 08 52  |   MOV R10,#0..R|
00000ee0  11 20 20 20 20 43 4d 50  20 52 39 2c 23 30 0d 08  |.    CMP R9,#0..|
00000ef0  5c 1a 20 20 20 20 4c 44  52 47 45 42 20 52 31 30  |\.    LDRGEB R10|
00000f00  2c 5b 52 31 2c 52 39 5d  0d 08 66 18 20 20 20 20  |,[R1,R9]..f.    |
00000f10  4c 44 52 42 20 52 31 34  2c 5b 52 33 2c 52 39 5d  |LDRB R14,[R3,R9]|
00000f20  0d 08 70 17 20 20 20 20  41 44 44 20 52 31 30 2c  |..p.    ADD R10,|
00000f30  52 31 30 2c 52 31 34 0d  08 7a 19 20 20 20 20 41  |R10,R14..z.    A|
00000f40  44 44 20 52 31 30 2c 52  31 30 2c 63 61 72 72 79  |DD R10,R10,carry|
00000f50  0d 08 84 04 0d 08 8e 20  20 20 20 20 5c 41 53 53  |.......     \ASS|
00000f60  45 4d 42 4c 45 20 83 20  80 20 81 20 46 55 4e 43  |EMBLE . . . FUNC|
00000f70  54 49 4f 4e 0d 08 98 1a  20 20 20 20 53 54 4d 46  |TION....    STMF|
00000f80  44 20 52 31 33 21 2c 7b  52 30 2d 52 36 7d 0d 08  |D R13!,{R0-R6}..|
00000f90  a2 12 20 20 20 20 4d 4f  56 20 52 30 2c 52 31 30  |..    MOV R0,R10|
00000fa0  0d 08 ac 12 20 20 20 20  4d 4f 56 20 52 31 2c 23  |....    MOV R1,#|
00000fb0  31 30 0d 08 b6 17 20 20  20 20 80 53 20 52 36 2c  |10....    .S R6,|
00000fc0  52 30 2c 23 31 3c 3c 33  31 0d 08 c0 16 20 20 20  |R0,#1<<31....   |
00000fd0  20 52 53 42 4d 49 20 52  30 2c 52 30 2c 23 30 0d  | RSBMI R0,R0,#0.|
00000fe0  08 ca 12 20 20 20 20 82  20 52 35 2c 52 36 2c 52  |...    . R5,R6,R|
00000ff0  31 0d 08 d4 11 20 20 20  20 43 4d 50 20 52 31 2c  |1....    CMP R1,|
00001000  23 30 0d 08 de 16 20 20  20 20 52 53 42 4d 49 20  |#0....    RSBMI |
00001010  52 31 2c 52 31 2c 23 30  0d 08 e8 04 0d 08 f2 11  |R1,R1,#0........|
00001020  20 20 20 20 4d 4f 56 20  52 32 2c 23 30 0d 08 fc  |    MOV R2,#0...|
00001030  11 20 20 20 20 4d 4f 56  20 52 33 2c 23 30 0d 09  |.    MOV R3,#0..|
00001040  06 15 20 20 20 20 4d 4f  56 20 52 34 2c 23 31 3c  |..    MOV R4,#1<|
00001050  3c 33 31 0d 09 10 04 0d  09 1a 17 20 20 20 20 2e  |<31........    .|
00001060  64 69 76 69 73 69 6f 6e  5f 6c 6f 6f 70 33 0d 09  |division_loop3..|
00001070  24 18 20 20 20 20 4d 4f  56 53 20 52 30 2c 52 30  |$.    MOVS R0,R0|
00001080  2c 41 53 4c 23 31 0d 09  2e 14 20 20 20 20 41 44  |,ASL#1....    AD|
00001090  43 20 52 32 2c 52 32 2c  52 32 0d 09 38 11 20 20  |C R2,R2,R2..8.  |
000010a0  20 20 43 4d 50 20 52 32  2c 52 31 0d 09 42 16 20  |  CMP R2,R1..B. |
000010b0  20 20 20 53 55 42 47 45  20 52 32 2c 52 32 2c 52  |   SUBGE R2,R2,R|
000010c0  31 0d 09 4c 15 20 20 20  20 84 52 47 45 20 52 33  |1..L.    .RGE R3|
000010d0  2c 52 33 2c 52 34 0d 09  56 18 20 20 20 20 4d 4f  |,R3,R4..V.    MO|
000010e0  56 53 20 52 34 2c 52 34  2c 4c 53 52 23 31 0d 09  |VS R4,R4,LSR#1..|
000010f0  60 1a 20 20 20 20 42 4e  45 20 64 69 76 69 73 69  |`.    BNE divisi|
00001100  6f 6e 5f 6c 6f 6f 70 33  0d 09 6a 04 0d 09 74 11  |on_loop3..j...t.|
00001110  20 20 20 20 43 4d 50 20  52 35 2c 23 30 0d 09 7e  |    CMP R5,#0..~|
00001120  16 20 20 20 20 52 53 42  4d 49 20 52 33 2c 52 33  |.    RSBMI R3,R3|
00001130  2c 23 30 0d 09 88 11 20  20 20 20 43 4d 50 20 52  |,#0....    CMP R|
00001140  36 2c 23 30 0d 09 92 16  20 20 20 20 52 53 42 4d  |6,#0....    RSBM|
00001150  49 20 52 32 2c 52 32 2c  23 30 0d 09 9c 04 0d 09  |I R2,R2,#0......|
00001160  a6 16 20 20 20 20 53 54  52 20 52 33 2c 64 69 76  |..    STR R3,div|
00001170  72 65 73 32 0d 09 b0 16  20 20 20 20 53 54 52 20  |res2....    STR |
00001180  52 32 2c 6d 6f 64 72 65  73 32 0d 09 ba 04 0d 09  |R2,modres2......|
00001190  c4 1a 20 20 20 20 4c 44  4d 46 44 20 52 31 33 21  |..    LDMFD R13!|
000011a0  2c 7b 52 30 2d 52 36 7d  0d 09 ce 04 0d 09 d8 17  |,{R0-R6}........|
000011b0  20 20 20 20 4c 44 52 20  52 31 34 2c 6d 6f 64 72  |    LDR R14,modr|
000011c0  65 73 32 0d 09 e2 18 20  20 20 20 53 54 52 42 20  |es2....    STRB |
000011d0  52 31 34 2c 5b 52 33 2c  52 39 5d 0d 09 ec 16 20  |R14,[R3,R9].... |
000011e0  20 20 20 4c 44 52 20 52  38 2c 64 69 76 72 65 73  |   LDR R8,divres|
000011f0  32 0d 09 f6 14 20 20 20  20 53 55 42 20 52 39 2c  |2....    SUB R9,|
00001200  52 39 2c 23 31 0d 0a 00  11 20 20 20 20 43 4d 4e  |R9,#1....    CMN|
00001210  20 52 39 2c 52 37 0d 0a  0a 17 20 20 42 4e 45 20  | R9,R7....  BNE |
00001220  66 6f 72 5f 6c 6f 6f 70  69 66 79 33 62 0d 0a 14  |for_loopify3b...|
00001230  15 20 20 53 54 52 42 20  52 34 2c 5b 52 32 2c 52  |.  STRB R4,[R2,R|
00001240  37 5d 0d 0a 1e 12 20 20  41 44 44 20 52 37 2c 52  |7]....  ADD R7,R|
00001250  37 2c 23 31 0d 0a 28 13  20 20 53 55 42 20 52 31  |7,#1..(.  SUB R1|
00001260  34 2c 52 35 2c 52 36 0d  0a 32 10 20 20 43 4d 50  |4,R5,R6..2.  CMP|
00001270  20 52 37 2c 52 31 34 0d  0a 3c 15 42 4c 54 20 66  | R7,R14..<.BLT f|
00001280  6f 72 5f 6c 6f 6f 70 69  66 79 31 62 0d 0a 46 0f  |or_loopify1b..F.|
00001290  4d 4f 56 20 52 31 34 2c  23 31 30 0d 0a 50 14 53  |MOV R14,#10..P.S|
000012a0  54 52 42 20 52 31 34 2c  5b 52 32 2c 52 37 5d 0d  |TRB R14,[R2,R7].|
000012b0  0a 5a 04 0d 0a 64 16 42  4c 20 52 65 6d 6f 76 65  |.Z...d.BL Remove|
000012c0  4c 65 61 64 69 6e 67 30  73 0d 0a 6e 13 4c 44 4d  |Leading0s..n.LDM|
000012d0  46 44 20 52 31 33 21 2c  7b 50 43 7d 0d 0a 78 04  |FD R13!,{PC}..x.|
000012e0  0d 0a 82 04 0d 0a 8c 0c  2e 64 69 76 72 65 73 32  |.........divres2|
000012f0  0d 0a 96 0a 45 51 55 44  20 30 0d 0a a0 0c 2e 6d  |....EQUD 0.....m|
00001300  6f 64 72 65 73 32 0d 0a  aa 0a 45 51 55 44 20 30  |odres2....EQUD 0|
00001310  0d 0a b4 04 0d 0a be 19  2e 62 65 67 69 6e 5f 6d  |.........begin_m|
00001320  75 6c 74 69 70 6c 69 63  61 74 69 6f 6e 0d 0a c8  |ultiplication...|
00001330  14 53 54 4d 46 44 20 52  31 33 21 2c 7b 52 31 34  |.STMFD R13!,{R14|
00001340  7d 0d 0a d2 04 0d 0a dc  2f 5c 41 20 bb 55 45 20  |}......./\A .UE |
00001350  ca 20 54 45 4e 20 43 4f  52 52 45 53 50 4f 4e 44  |. TEN CORRESPOND|
00001360  53 20 b8 20 54 45 52 4d  49 4e 41 54 49 4e 47 20  |S . TERMINATING |
00001370  42 59 54 45 0d 0a e6 04  0d 0a f0 14 42 4c 20 67  |BYTE........BL g|
00001380  65 74 5f 61 64 64 72 65  73 73 65 73 0d 0a fa 04  |et_addresses....|
00001390  0d 0b 04 04 0d 0b 0e 24  5c 66 69 6e 64 20 65 6e  |.......$\find en|
000013a0  64 20 6f 66 20 6f 70 65  72 61 6e 64 31 20 80 20  |d of operand1 . |
000013b0  6f 70 65 72 61 6e 64 32  0d 0b 18 04 0d 0b 22 0d  |operand2......".|
000013c0  4d 4f 56 20 52 33 2c 52  30 0d 0b 2c 0d 4d 4f 56  |MOV R3,R0..,.MOV|
000013d0  20 52 35 2c 23 30 0d 0b  36 13 2e 6c 6f 6f 70 5f  | R5,#0..6..loop_|
000013e0  67 65 74 5f 65 6e 64 31  64 0d 0b 40 15 20 20 4c  |get_end1d..@.  L|
000013f0  44 52 42 20 52 34 2c 5b  52 33 5d 2c 23 31 0d 0b  |DRB R4,[R3],#1..|
00001400  4a 12 20 20 41 44 44 20  52 35 2c 52 35 2c 23 31  |J.  ADD R5,R5,#1|
00001410  0d 0b 54 10 20 20 43 4d  50 20 52 34 2c 23 31 30  |..T.  CMP R4,#10|
00001420  0d 0b 5e 16 42 4e 45 20  6c 6f 6f 70 5f 67 65 74  |..^.BNE loop_get|
00001430  5f 65 6e 64 31 64 0d 0b  68 04 0d 0b 72 0d 4d 4f  |_end1d..h...r.MO|
00001440  56 20 52 33 2c 52 31 0d  0b 7c 0d 4d 4f 56 20 52  |V R3,R1..|.MOV R|
00001450  36 2c 23 30 0d 0b 86 13  2e 6c 6f 6f 70 5f 67 65  |6,#0.....loop_ge|
00001460  74 5f 65 6e 64 32 64 0d  0b 90 15 20 20 4c 44 52  |t_end2d....  LDR|
00001470  42 20 52 34 2c 5b 52 33  5d 2c 23 31 0d 0b 9a 12  |B R4,[R3],#1....|
00001480  20 20 41 44 44 20 52 36  2c 52 36 2c 23 31 0d 0b  |  ADD R6,R6,#1..|
00001490  a4 10 20 20 43 4d 50 20  52 34 2c 23 31 30 0d 0b  |..  CMP R4,#10..|
000014a0  ae 16 42 4e 45 20 6c 6f  6f 70 5f 67 65 74 5f 65  |..BNE loop_get_e|
000014b0  6e 64 32 64 0d 0b b8 04  0d 0b c2 42 5c a9 47 54  |nd2d.......B\.GT|
000014c0  48 20 ca 20 4f 50 45 52  41 4e 44 20 31 20 49 53  |H . OPERAND 1 IS|
000014d0  20 52 45 54 55 52 4e 45  44 20 49 4e 20 52 35 2c  | RETURNED IN R5,|
000014e0  20 a9 47 54 48 20 ca 20  4f 50 45 52 41 4e 44 20  | .GTH . OPERAND |
000014f0  32 20 49 53 20 49 4e 20  52 36 0d 0b cc 04 0d 0b  |2 IS IN R6......|
00001500  d6 31 41 44 44 20 52 37  2c 52 35 2c 52 36 20 20  |.1ADD R7,R5,R6  |
00001510  20 20 20 20 20 20 20 20  20 20 20 5c 43 4f 4e 54  |           \CONT|
00001520  41 49 4e 53 20 b8 54 41  4c 20 a9 47 54 48 53 0d  |AINS .TAL .GTHS.|
00001530  0b e0 04 0d 0b ea 2b 5c  52 45 47 49 53 54 45 52  |......+\REGISTER|
00001540  53 20 41 56 41 49 4c 41  42 4c 45 20 3d 20 52 33  |S AVAILABLE = R3|
00001550  2c 52 34 2c 52 38 2d 52  31 32 2c 52 31 34 0d 0b  |,R4,R8-R12,R14..|
00001560  f4 04 0d 0b fe 1e 5c 73  74 72 75 63 74 75 72 65  |......\structure|
00001570  20 46 6f 72 2e 2e 6e 65  78 74 20 6c 6f 6f 70 2d  | For..next loop-|
00001580  0d 0c 08 04 0d 0c 12 0d  4d 4f 56 20 52 33 2c 23  |........MOV R3,#|
00001590  30 0d 0c 1c 0d 4d 4f 56  20 52 34 2c 52 32 0d 0c  |0....MOV R4,R2..|
000015a0  26 1f 53 55 42 20 52 31  34 2c 52 37 2c 23 31 20  |&.SUB R14,R7,#1 |
000015b0  5c 4c 4f 4f 50 20 43 4f  55 4e 54 45 52 0d 0c 30  |\LOOP COUNTER..0|
000015c0  12 2e 66 6f 72 5f 6c 6f  6f 70 69 66 79 31 64 0d  |..for_loopify1d.|
000015d0  0c 3a 15 20 20 53 54 52  42 20 52 33 2c 5b 52 34  |.:.  STRB R3,[R4|
000015e0  5d 2c 23 31 0d 0c 44 15  20 20 53 55 42 53 20 52  |],#1..D.  SUBS R|
000015f0  31 34 2c 52 31 34 2c 23  31 0d 0c 4e 15 42 4e 45  |14,R14,#1..N.BNE|
00001600  20 66 6f 72 5f 6c 6f 6f  70 69 66 79 31 64 0d 0c  | for_loopify1d..|
00001610  58 0e 4d 4f 56 20 52 33  2c 23 31 30 0d 0c 62 10  |X.MOV R3,#10..b.|
00001620  53 54 52 42 20 52 33 2c  5b 52 34 5d 0d 0c 6c 04  |STRB R3,[R4]..l.|
00001630  0d 0c 76 11 53 55 42 20  52 31 31 2c 52 36 2c 23  |..v.SUB R11,R6,#|
00001640  32 0d 0c 80 12 2e 66 6f  72 5f 6c 6f 6f 70 69 66  |2.....for_loopif|
00001650  79 32 64 0d 0c 8a 12 20  20 4d 4f 56 20 63 61 72  |y2d....  MOV car|
00001660  72 79 2c 23 30 0d 0c 94  16 20 20 4c 44 52 42 20  |ry,#0....  LDRB |
00001670  52 33 2c 5b 52 31 2c 52  31 31 5d 0d 0c 9e 13 20  |R3,[R1,R11].... |
00001680  20 41 44 44 20 52 34 2c  52 32 2c 52 31 31 0d 0c  | ADD R4,R2,R11..|
00001690  a8 12 20 20 41 44 44 20  52 34 2c 52 34 2c 23 31  |..  ADD R4,R4,#1|
000016a0  0d 0c b2 13 20 20 53 55  42 20 52 31 30 2c 52 35  |....  SUB R10,R5|
000016b0  2c 23 32 0d 0c bc 14 20  20 2e 66 6f 72 5f 6c 6f  |,#2....  .for_lo|
000016c0  6f 70 69 66 79 33 64 0d  0c c6 18 20 20 20 20 4c  |opify3d....    L|
000016d0  44 52 42 20 52 39 2c 5b  52 30 2c 52 31 30 5d 0d  |DRB R9,[R0,R10].|
000016e0  0c d0 15 20 20 20 20 4d  55 4c 20 52 31 34 2c 52  |...    MUL R14,R|
000016f0  33 2c 52 39 0d 0c da 19  20 20 20 20 41 44 44 20  |3,R9....    ADD |
00001700  52 31 34 2c 52 31 34 2c  63 61 72 72 79 0d 0c e4  |R14,R14,carry...|
00001710  17 20 20 20 20 53 54 4d  46 44 20 52 31 33 21 2c  |.    STMFD R13!,|
00001720  7b 52 38 7d 0d 0c ee 18  20 20 20 20 4c 44 52 42  |{R8}....    LDRB|
00001730  20 52 38 2c 5b 52 34 2c  52 31 30 5d 0d 0c f8 16  | R8,[R4,R10]....|
00001740  20 20 20 20 41 44 44 20  52 31 34 2c 52 31 34 2c  |    ADD R14,R14,|
00001750  52 38 0d 0d 02 04 0d 0d  0c 20 20 20 20 20 5c 41  |R8.......     \A|
00001760  53 53 45 4d 42 4c 45 20  83 20 80 20 81 20 46 55  |SSEMBLE . . . FU|
00001770  4e 43 54 49 4f 4e 0d 0d  16 1a 20 20 20 20 53 54  |NCTION....    ST|
00001780  4d 46 44 20 52 31 33 21  2c 7b 52 30 2d 52 36 7d  |MFD R13!,{R0-R6}|
00001790  0d 0d 20 12 20 20 20 20  4d 4f 56 20 52 30 2c 52  |.. .    MOV R0,R|
000017a0  31 34 0d 0d 2a 12 20 20  20 20 4d 4f 56 20 52 31  |14..*.    MOV R1|
000017b0  2c 23 31 30 0d 0d 34 17  20 20 20 20 80 53 20 52  |,#10..4.    .S R|
000017c0  36 2c 52 30 2c 23 31 3c  3c 33 31 0d 0d 3e 16 20  |6,R0,#1<<31..>. |
000017d0  20 20 20 52 53 42 4d 49  20 52 30 2c 52 30 2c 23  |   RSBMI R0,R0,#|
000017e0  30 0d 0d 48 12 20 20 20  20 82 20 52 35 2c 52 36  |0..H.    . R5,R6|
000017f0  2c 52 31 0d 0d 52 11 20  20 20 20 43 4d 50 20 52  |,R1..R.    CMP R|
00001800  31 2c 23 30 0d 0d 5c 16  20 20 20 20 52 53 42 4d  |1,#0..\.    RSBM|
00001810  49 20 52 31 2c 52 31 2c  23 30 0d 0d 66 04 0d 0d  |I R1,R1,#0..f...|
00001820  70 11 20 20 20 20 4d 4f  56 20 52 32 2c 23 30 0d  |p.    MOV R2,#0.|
00001830  0d 7a 11 20 20 20 20 4d  4f 56 20 52 33 2c 23 30  |.z.    MOV R3,#0|
00001840  0d 0d 84 15 20 20 20 20  4d 4f 56 20 52 34 2c 23  |....    MOV R4,#|
00001850  31 3c 3c 33 31 0d 0d 8e  04 0d 0d 98 17 20 20 20  |1<<31........   |
00001860  20 2e 64 69 76 69 73 69  6f 6e 5f 6c 6f 6f 70 64  | .division_loopd|
00001870  0d 0d a2 18 20 20 20 20  4d 4f 56 53 20 52 30 2c  |....    MOVS R0,|
00001880  52 30 2c 41 53 4c 23 31  0d 0d ac 14 20 20 20 20  |R0,ASL#1....    |
00001890  41 44 43 20 52 32 2c 52  32 2c 52 32 0d 0d b6 11  |ADC R2,R2,R2....|
000018a0  20 20 20 20 43 4d 50 20  52 32 2c 52 31 0d 0d c0  |    CMP R2,R1...|
000018b0  16 20 20 20 20 53 55 42  47 45 20 52 32 2c 52 32  |.    SUBGE R2,R2|
000018c0  2c 52 31 0d 0d ca 15 20  20 20 20 84 52 47 45 20  |,R1....    .RGE |
000018d0  52 33 2c 52 33 2c 52 34  0d 0d d4 18 20 20 20 20  |R3,R3,R4....    |
000018e0  4d 4f 56 53 20 52 34 2c  52 34 2c 4c 53 52 23 31  |MOVS R4,R4,LSR#1|
000018f0  0d 0d de 1a 20 20 20 20  42 4e 45 20 64 69 76 69  |....    BNE divi|
00001900  73 69 6f 6e 5f 6c 6f 6f  70 64 0d 0d e8 04 0d 0d  |sion_loopd......|
00001910  f2 11 20 20 20 20 43 4d  50 20 52 35 2c 23 30 0d  |..    CMP R5,#0.|
00001920  0d fc 16 20 20 20 20 52  53 42 4d 49 20 52 33 2c  |...    RSBMI R3,|
00001930  52 33 2c 23 30 0d 0e 06  11 20 20 20 20 43 4d 50  |R3,#0....    CMP|
00001940  20 52 36 2c 23 30 0d 0e  10 16 20 20 20 20 52 53  | R6,#0....    RS|
00001950  42 4d 49 20 52 32 2c 52  32 2c 23 30 0d 0e 1a 04  |BMI R2,R2,#0....|
00001960  0d 0e 24 16 20 20 20 20  53 54 52 20 52 33 2c 64  |..$.    STR R3,d|
00001970  69 76 72 65 73 64 0d 0e  2e 16 20 20 20 20 53 54  |ivresd....    ST|
00001980  52 20 52 32 2c 6d 6f 64  72 65 73 64 0d 0e 38 04  |R R2,modresd..8.|
00001990  0d 0e 42 1a 20 20 20 20  4c 44 4d 46 44 20 52 31  |..B.    LDMFD R1|
000019a0  33 21 2c 7b 52 30 2d 52  36 7d 0d 0e 4c 04 0d 0e  |3!,{R0-R6}..L...|
000019b0  56 16 20 20 20 20 4c 44  52 20 52 38 2c 6d 6f 64  |V.    LDR R8,mod|
000019c0  72 65 73 64 0d 0e 60 18  20 20 20 20 53 54 52 42  |resd..`.    STRB|
000019d0  20 52 38 2c 5b 52 34 2c  52 31 30 5d 0d 0e 6a 17  | R8,[R4,R10]..j.|
000019e0  20 20 20 20 4c 44 4d 46  44 20 52 31 33 21 2c 7b  |    LDMFD R13!,{|
000019f0  52 38 7d 0d 0e 74 16 20  20 20 20 4c 44 52 20 52  |R8}..t.    LDR R|
00001a00  38 2c 64 69 76 72 65 73  64 0d 0e 7e 17 20 20 20  |8,divresd..~.   |
00001a10  20 53 55 42 53 20 52 31  30 2c 52 31 30 2c 23 31  | SUBS R10,R10,#1|
00001a20  0d 0e 88 17 20 20 42 4e  45 20 66 6f 72 5f 6c 6f  |....  BNE for_lo|
00001a30  6f 70 69 66 79 33 64 0d  0e 92 16 20 20 53 54 52  |opify3d....  STR|
00001a40  42 20 52 38 2c 5b 52 34  2c 52 31 30 5d 0d 0e 9c  |B R8,[R4,R10]...|
00001a50  15 20 20 53 55 42 53 20  52 31 31 2c 52 31 31 2c  |.  SUBS R11,R11,|
00001a60  23 31 0d 0e a6 15 42 4e  45 20 66 6f 72 5f 6c 6f  |#1....BNE for_lo|
00001a70  6f 70 69 66 79 32 64 0d  0e b0 04 0d 0e ba 16 42  |opify2d........B|
00001a80  4c 20 52 65 6d 6f 76 65  4c 65 61 64 69 6e 67 30  |L RemoveLeading0|
00001a90  73 0d 0e c4 13 4c 44 4d  46 44 20 52 31 33 21 2c  |s....LDMFD R13!,|
00001aa0  7b 50 43 7d 0d 0e ce 04  0d 0e d8 0c 2e 64 69 76  |{PC}.........div|
00001ab0  72 65 73 64 0d 0e e2 0a  45 51 55 44 20 30 0d 0e  |resd....EQUD 0..|
00001ac0  ec 0c 2e 6d 6f 64 72 65  73 64 0d 0e f6 0a 45 51  |...modresd....EQ|
00001ad0  55 44 20 30 0d 0f 00 04  0d 0f 0a 04 0d 0f 14 04  |UD 0............|
00001ae0  0d 0f 1e 12 2e 67 65 74  5f 61 64 64 72 65 73 73  |.....get_address|
00001af0  65 73 0d 0f 28 14 53 54  4d 46 44 20 52 31 33 21  |es..(.STMFD R13!|
00001b00  2c 7b 52 31 34 7d 0d 0f  32 13 41 44 52 20 52 30  |,{R14}..2.ADR R0|
00001b10  2c 6f 70 65 72 61 6e 64  31 0d 0f 3c 0b 42 20 61  |,operand1..<.B a|
00001b20  64 64 6e 31 0d 0f 46 04  0d 0f 50 0d 2e 6f 70 65  |ddn1..F...P..ope|
00001b30  72 61 6e 64 31 0d 0f 5a  15 a4 42 79 74 65 73 28  |rand1..Z..Bytes(|
00001b40  61 63 63 75 72 61 63 79  25 29 0d 0f 64 04 0d 0f  |accuracy%)..d...|
00001b50  6e 0a 2e 61 64 64 6e 31  0d 0f 78 13 41 44 52 20  |n..addn1..x.ADR |
00001b60  52 31 2c 6f 70 65 72 61  6e 64 32 0d 0f 82 0b 42  |R1,operand2....B|
00001b70  20 61 64 64 6e 32 0d 0f  8c 04 0d 0f 96 0d 2e 6f  | addn2.........o|
00001b80  70 65 72 61 6e 64 32 0d  0f a0 15 a4 42 79 74 65  |perand2.....Byte|
00001b90  73 28 61 63 63 75 72 61  63 79 25 29 0d 0f aa 04  |s(accuracy%)....|
00001ba0  0d 0f b4 0a 2e 61 64 64  6e 32 0d 0f be 11 41 44  |.....addn2....AD|
00001bb0  52 20 52 32 2c 72 65 73  75 6c 74 0d 0f c8 04 0d  |R R2,result.....|
00001bc0  0f d2 13 42 4c 20 66 6c  75 73 68 5f 72 65 73 75  |...BL flush_resu|
00001bd0  6c 74 0d 0f dc 13 4c 44  4d 46 44 20 52 31 33 21  |lt....LDMFD R13!|
00001be0  2c 7b 50 43 7d 0d 0f e6  04 0d 0f f0 0b 2e 72 65  |,{PC}.........re|
00001bf0  73 75 6c 74 0d 0f fa 17  a4 42 79 74 65 73 28 32  |sult.....Bytes(2|
00001c00  2a 61 63 63 75 72 61 63  79 25 29 0d 10 04 09 41  |*accuracy%)....A|
00001c10  4c 49 47 4e 0d 10 0e 04  0d 10 18 14 2e 52 65 6d  |LIGN.........Rem|
00001c20  6f 76 65 4c 65 61 64 69  6e 67 30 73 0d 10 22 14  |oveLeading0s..".|
00001c30  53 54 4d 46 44 20 52 31  33 21 2c 7b 52 31 34 7d  |STMFD R13!,{R14}|
00001c40  0d 10 2c 05 3a 0d 10 36  0d 4d 4f 56 20 52 34 2c  |..,.:..6.MOV R4,|
00001c50  23 30 0d 10 40 12 2e 6c  6f 6f 70 5f 72 65 6d 6f  |#0..@..loop_remo|
00001c60  76 65 30 73 0d 10 4a 13  4c 44 52 42 20 52 35 2c  |ve0s..J.LDRB R5,|
00001c70  5b 52 32 2c 52 34 5d 0d  10 54 0d 43 4d 50 20 52  |[R2,R4]..T.CMP R|
00001c80  35 2c 23 30 0d 10 5e 12  41 44 44 45 51 20 52 34  |5,#0..^.ADDEQ R4|
00001c90  2c 52 34 2c 23 31 0d 10  68 15 42 45 51 20 6c 6f  |,R4,#1..h.BEQ lo|
00001ca0  6f 70 5f 72 65 6d 6f 76  65 30 73 0d 10 72 04 0d  |op_remove0s..r..|
00001cb0  10 7c 0d 4d 4f 56 20 52  33 2c 23 30 0d 10 86 15  |.|.MOV R3,#0....|
00001cc0  2e 6c 6f 6f 70 5f 73 77  61 70 5f 73 74 72 69 6e  |.loop_swap_strin|
00001cd0  67 0d 10 90 13 4c 44 52  42 20 52 35 2c 5b 52 32  |g....LDRB R5,[R2|
00001ce0  2c 52 34 5d 0d 10 9a 13  53 54 52 42 20 52 35 2c  |,R4]....STRB R5,|
00001cf0  5b 52 32 2c 52 33 5d 0d  10 a4 0e 43 4d 50 20 52  |[R2,R3]....CMP R|
00001d00  35 2c 23 31 30 0d 10 ae  12 41 44 44 4e 45 20 52  |5,#10....ADDNE R|
00001d10  34 2c 52 34 2c 23 31 0d  10 b8 12 41 44 44 4e 45  |4,R4,#1....ADDNE|
00001d20  20 52 33 2c 52 33 2c 23  31 0d 10 c2 18 42 4e 45  | R3,R3,#1....BNE|
00001d30  20 6c 6f 6f 70 5f 73 77  61 70 5f 73 74 72 69 6e  | loop_swap_strin|
00001d40  67 0d 10 cc 04 0d 10 d6  05 3a 0d 10 e0 13 4c 44  |g........:....LD|
00001d50  4d 46 44 20 52 31 33 21  2c 7b 50 43 7d 0d 10 ea  |MFD R13!,{PC}...|
00001d60  04 0d 10 f4 11 2e 66 6c  75 73 68 5f 72 65 73 75  |......flush_resu|
00001d70  6c 74 0d 10 fe 14 53 54  4d 46 44 20 52 31 33 21  |lt....STMFD R13!|
00001d80  2c 7b 52 31 34 7d 0d 11  08 05 3a 0d 11 12 19 4d  |,{R14}....:....M|
00001d90  4f 56 20 52 33 2c 23 28  32 2a 61 63 63 75 72 61  |OV R3,#(2*accura|
00001da0  63 79 25 29 0d 11 1c 0d  4d 4f 56 20 52 34 2c 23  |cy%)....MOV R4,#|
00001db0  30 0d 11 26 0e 2e 66 6c  75 73 68 6c 6f 6f 70 0d  |0..&..flushloop.|
00001dc0  11 30 13 53 54 52 42 20  52 34 2c 5b 52 32 2c 52  |.0.STRB R4,[R2,R|
00001dd0  33 5d 0d 11 3a 11 53 55  42 53 20 52 33 2c 52 33  |3]..:.SUBS R3,R3|
00001de0  2c 23 31 0d 11 44 11 42  47 45 20 66 6c 75 73 68  |,#1..D.BGE flush|
00001df0  6c 6f 6f 70 0d 11 4e 04  0d 11 58 05 3a 0d 11 62  |loop..N...X.:..b|
00001e00  13 4c 44 4d 46 44 20 52  31 33 21 2c 7b 50 43 7d  |.LDMFD R13!,{PC}|
00001e10  0d 11 6c 04 0d 11 76 04  0d 11 80 05 5d 0d 11 8a  |..l...v.....]...|
00001e20  05 ed 0d 11 94 05 3a 0d  11 9e 05 e1 0d 11 a8 05  |......:.........|
00001e30  3a 0d 11 b2 11 dd a4 42  79 74 65 73 28 69 6e 63  |:......Bytes(inc|
00001e40  25 29 0d 11 bc 13 e3 20  4e 69 6e 63 3d 30 20 b8  |%)..... Ninc=0 .|
00001e50  20 69 6e 63 25 0d 11 c6  0d 50 25 3f 4e 69 6e 63  | inc%....P%?Ninc|
00001e60  3d 30 0d 11 d0 05 ed 0d  11 da 0c 50 25 2b 3d 69  |=0.........P%+=i|
00001e70  6e 63 25 0d 11 e4 06 3d  30 0d ff                 |nc%....=0..|
00001e7b