1

Can someone help explain the following code. I'm trying to add comments to the following SIC/XE program that explains how this program is calculating a fibonacci sequence for the first 20 numbers, starting at 3.

FIB     START  0
First   LDT    #3       ;start at number 3
        LDS    #20      ;calculate up to 20
        +JSUB  RDREC        ;call read subroutine
        +JSUB  WRREC        ;call write subroutine
LENGTH  RESW   1
.
. SUBROUTINE RDREC
.
RDREC   CLEAR  A        ;set A to zero
LOOP1   TD     INPUT        ;Test input device
        JEQ    LOOP1        ;Loop if device is busy
        RD     INPUT        ;read one byte into register A
        COMPR  A,T      ;Test for end
        JLT    LOOP1        ;jump to loop until end
        COMPR  A,S      ;
        JGT    LOOP1
        STA    LENGTH
        RSUB
INPUT   BYTE   X'F1'
.
.SUBROUTINE WDREC
.
WRREC   LDX    #0
        LDS    #1
        LDA    #0
        LDT    LENGTH
LOOP2   TD     OUTPUT
        JEQ    LOOP2
        WD     OUTPUT
        ADDR   S,A
        STA    VALUE1
        STS    VALUE2
        LDA    VALUE2
        LDS    VALUE1
        TIXR   T 
        JLT    LOOP2
OUTPUT  BYTE   X'05'
VALUE1  RESW   1
VALUE2  RESW   1
        END    FIRST
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
LiterACola
  • 11
  • 1

0 Answers0