App. - 26
Appendix 4.19 Program showing divided value of 4-digit BIN value to 4 places of decimals
(1) Example 1
The program displays the operation result using a dividend and a divisor which
are individually specified in two 4-digit digital switches on two 4-digit displays
(integral part and decimal part).
Digital switch
X3F to X30
X2F to X20
X0
Digital display
QCPU QX
42
QY
42P
Y5F to Y50 Y4F to Y40
Importing dividend and divisor
Division
Displaying a quotient
Clearing index registers Z0
and Z1 and data register D10
Multiplying the remainder with 10,
dividing the result, and taking a
quotient of lower 1 digit
Displaying the lower 1 digit
Counting the number of times
(register Z1)
4 obtained?
END
YES
INC Z1
NO
NEXT
FOR
Setting the display address
after decimal point
Dividend Digital switch X30 to X3F → D0
Divisor Digital switch X20 to X2F → D1
(D0) / (D1) = (D2) ...... (D3)
Quotient Remainder
4 × (Z1) → (D10) HC-(D10) → (Z0)
1st time 4 × 0 → 0 HC-K0 → HC
2nd time 4 × 1 → 4 HC-K4 → H8
3rd time 4 × 2 → 8 HC-K8 → H4
4th time 4 × 3 → 12 HC-K12 → H0
(D3) × 10 → (D3)
(D3) / (D1) = (D2) ...... (D3)
Y4C to 4F
Y48 to 4B
Y44 to 47
Y40 to 43
Last-
1st
digit
Last-
2nd
digit
Last-
3rd
digit
Last-
4th
digit