#
# canola - canon canola 1614p emulator
# Copyright (C) 2011 Peter Miller
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
;
; This software was provided by Chris Baird
; in the form of scans of two of his program cards. This was processed
; by canola-card-scanner(1) to produce editable text which was edited to
; produce the file you see here.
;
; ---------- Card-Pocket-Begin --------------------------------------------
; Title: Quadratic Equation, by C. Baird
; Style: aus
; Disassemble: true
; ---------- Card-Pocket-End ----------------------------------------------
;
; Solve for x when
;
; a * x**2 + b * x + c = 0
;
; The ENTRY light will occur 3 times, once for each of a, b and c. This
; will be followed by two numbers, one for each root. If there is no
; solutiuon only one number ("0.00") will be printed, followed by a
; blank line. The program then starts again.
;
FJ 1
ENT ; a
*
2
+=
SM3 ; 2 * a => M3
ENT ; b
CS
SM5 ; -b => M5
*
+=
SM4 ; b**2 => M4
ENT ; c
*
RM3
*
2
-= ; -4*a*c
M4 ; b**2 - 2*a*c => M4
RM4
MJ 2 ; bail if the determinant is negative
SQRT
SM4 ; sqrt(b**2 - 4*a*c) => M4
RM5 ; -b
+=
/
RM3
+= ; solution 1
PRINT
RM4
CS
RM5
+=
/
RM3
+= ; solution 2
PRINT
FD
UJ 1
FJ 2
0.00 ; No solution.
PRINT
FD
UJ 1