COMMON/common/appl.src
2021-07-07 21:19:07 -04:00

55 lines
634 B
Plaintext

#include "rom.h"
#include "macros.h"
#include "globals.h"
* = $300 ; any address outside of page zero is okay because all code is relocatable
RCD(DEMO)
CMN
SET(R0, 9.4662)
SET(R1, SQRT2)
LDI(R7, R1)
MUL(R7, R7, R7)
PSH(R0)
BRS(FACTORIAL)
POP(R4)
SET(R5, E)
LDI(R6, R5)
SET(R1, ZER)
INR(R1)
SVI(R1, R6)
LDI(R0, R1)
ESC
BRK
BGN(FACTORIAL)
POP(R1)
SET(R2, 1)
MOD(R3, R1, R2)
SUB(R1, R1, R3)
_1 TST(R1)
BRZ(_2)
MUL(R2, R2, R1)
DCR(R1)
BRA(_1)
_2 PSH(R2)
RTN
END(FACTORIAL)
END(DEMO)
RDT(_)
; preset constants
DEF(PI, 3.14159)
DEF(E, 2.71828)
DEF(SQRT2, 1.41421)
; working space
RES(2)
END(_)