Post Reply 
(42S) CARDIAC
10-12-2014, 06:15 PM
Post: #2
RE: (HP-42S) CARDIAC
Greatest Common Divisor

Code:
05              a   DATA
06              b   DATA
07              c   DATA

10  005     load        INP     a
11  006                 INP     b
12  105     start       CLA     a
13  605     loop        STO     b
14  706                 SUB     b
15  317                 TAC     break
16  813                 JMP     loop
17  105     break       CLA     a
18  607                 STO     c
19  700                 SUB     1
20  326                 TAC     exit
21  106                 CLA     b
22  605                 STO     a
23  107                 CLA     c
24  606                 STO     b
25  812                 JMP     start
26  506                 OUT     b
27  910                 HRS     load

Example (after loading the program):

What is gcd(408, 360)?

408 STO 05
360 STO 06
12 XEQ 99

The result is:

R06=24

You can copy&paste this deck of cards into the simulator to run this example:

2
800
10
005
11
006
12
105
13
605
14
706
15
317
16
813
17
105
18
607
19
700
20
326
21
106
22
605
23
107
24
606
25
812
26
506
27
910
810
408
360
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(42S) CARDIAC - Thomas Klemm - 10-11-2014, 08:54 PM
RE: (HP-42S) CARDIAC - Thomas Klemm - 10-12-2014 06:15 PM
RE: (HP-42S) CARDIAC - Dave Britten - 10-13-2014, 07:30 PM
RE: (HP-42S) CARDIAC - Thomas Klemm - 10-13-2014, 09:06 PM
RE: (HP-42S) CARDIAC - Dave Britten - 10-13-2014, 09:27 PM
RE: (HP-42S) CARDIAC - Thomas Klemm - 10-16-2014, 09:49 PM



User(s) browsing this thread: 1 Guest(s)