DATA Mydata
    p:    WORD
    s:    CHAR* = "Fibonacci sequence:",13,0
    one:  WORD = 1
    two:  WORD = 2
    n:    WORD = 15
    i:    WORD = 0
    TEMP: WORD
END Mydata
  
PROGRAM Main
    SETV s
    STA  p
 loop:
    LDAI p
    JMPZ exit
    PUT
    INC  p
    JMP  loop
 exit:
    NOP
 loop1:
    LDA   n
    SUB   i
    JMPZ  exit1
    LDA   i
    PUSH            # parameter push
    CALL  Fibo
    DCA             # the result of Fibo is in ACC and convert this to decimal expression
    POP             # parameter pop
    LDA   2
    PUT
    LDA   3
    PUT
    LDA   4
    PUT 
    LDA   5
    PUT
    INC   i
    JMP   loop1
 exit1:
    HALT
END Main
  
FUNCTION Fibo   
    XLDA 1          # parameter LOAD
    JMPZ exit
    SUB  one
    JMPZ exit
    XLDA 1          # parameter LOAD
    SUB  two
    PUSH            # parameter PUSH
    CALL Fibo
    XSTA -1         # local area 1
    POP             # parameter POP
    XLDA 1          # parameter LOAD
    SUB  one
    PUSH            # parameter PUSH
    CALL Fibo
    STA  TEMP       # TEMP in memD 
    POP             # parameter POP
    XLDA -1         # local area 1
    ADD  TEMP
    RET
 exit:
    LDA  one
    RET
END Fibo
  