*
The second program (or rather two of them) implements
fast algorithms for division and multiplication of large
numbers. On this basis, it is easy to write the p / n decimal
numbers in the registers (the conversion line in number).
Designation:
MUL_HLBC_DE: Registers HLBC = HLBC * DE
DIV_HLBC_DE: Registers HLBC = HLBC / DE
Entry point MUL16 and DIV16, as follows from
names, perform the multiplication and division of 16-bit
numbers. And, if multiplied by 16 bits at 16, then
result is 32 bits.
;====================================
, 16-BIT MULTIPLY
;====================================
MUL16: LD HL, 0
MUL_HLBC_DE:
LD A, B
LD B, 11H
JR L4928
L4921: JR NC, L4924
ADD HL, DE
L4924: RR H
RR L
L4928: RRA
RR C
DJNZ L4921
LD B, A
RET
;====================================
, 16-BIT DIVIDE
;====================================
DIV16: LD HL, 0
DIV_HLBC_DE:
LD A, B
LD B, 10H
RL C
RLA
L493B: RL L
RL H
JR C, L494E
SBC HL, DE
JR NC, L4946
ADD HL, DE
L4946: CCF
L4947: RL C
RLA
DJNZ L493B
LD B, A
RET
L494E: OR A
SBC HL, DE
JR L4947
*
Well, like it is all for today. Yes, a little
do not forget: all these applets written somewhere in the
1983 was none other than Tim Paterson, author of MSX-DOS
and the first version of MS-DOS. Such are the things ...