2018-08-07 02:14:36 +00:00
|
|
|
#include "rom.h"
|
|
|
|
#include "macros.h"
|
2018-09-08 15:00:19 +00:00
|
|
|
#include "globals.h"
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2019-07-07 17:25:47 +00:00
|
|
|
* = $300 ; any address outside of page zero is okay because all code is relocatable
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2021-07-08 01:19:07 +00:00
|
|
|
RCD(DEMO)
|
2019-07-07 17:25:47 +00:00
|
|
|
|
2018-08-07 02:14:36 +00:00
|
|
|
CMN
|
2018-09-18 00:35:19 +00:00
|
|
|
SET(R0, 9.4662)
|
2019-07-07 17:25:47 +00:00
|
|
|
SET(R1, SQRT2)
|
2019-04-30 01:32:06 +00:00
|
|
|
LDI(R7, R1)
|
2019-04-30 21:21:49 +00:00
|
|
|
MUL(R7, R7, R7)
|
2018-09-18 00:35:19 +00:00
|
|
|
PSH(R0)
|
|
|
|
BRS(FACTORIAL)
|
|
|
|
POP(R4)
|
2019-07-07 17:25:47 +00:00
|
|
|
SET(R5, E)
|
2019-04-27 00:37:50 +00:00
|
|
|
LDI(R6, R5)
|
2021-07-08 01:19:07 +00:00
|
|
|
SET(R1, ZER)
|
2019-07-07 17:25:47 +00:00
|
|
|
INR(R1)
|
|
|
|
SVI(R1, R6)
|
|
|
|
LDI(R0, R1)
|
2018-08-07 02:14:36 +00:00
|
|
|
ESC
|
|
|
|
BRK
|
2021-07-08 01:19:07 +00:00
|
|
|
|
|
|
|
BGN(FACTORIAL)
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2018-09-18 00:35:19 +00:00
|
|
|
POP(R1)
|
2019-07-07 17:25:47 +00:00
|
|
|
SET(R2, 1)
|
2018-08-07 02:14:36 +00:00
|
|
|
MOD(R3, R1, R2)
|
|
|
|
SUB(R1, R1, R3)
|
|
|
|
_1 TST(R1)
|
|
|
|
BRZ(_2)
|
|
|
|
MUL(R2, R2, R1)
|
2018-09-01 14:40:57 +00:00
|
|
|
DCR(R1)
|
2018-08-07 02:14:36 +00:00
|
|
|
BRA(_1)
|
2018-09-18 00:35:19 +00:00
|
|
|
_2 PSH(R2)
|
|
|
|
RTN
|
2021-07-08 01:19:07 +00:00
|
|
|
|
2018-08-07 02:14:36 +00:00
|
|
|
END(FACTORIAL)
|
|
|
|
|
2018-08-14 01:23:05 +00:00
|
|
|
END(DEMO)
|
2018-09-11 23:26:08 +00:00
|
|
|
|
2021-07-08 01:19:07 +00:00
|
|
|
RDT(_)
|
2019-07-07 17:25:47 +00:00
|
|
|
|
|
|
|
; preset constants
|
2021-07-08 01:19:07 +00:00
|
|
|
DEF(PI, 3.14159)
|
|
|
|
DEF(E, 2.71828)
|
|
|
|
DEF(SQRT2, 1.41421)
|
2019-07-07 17:25:47 +00:00
|
|
|
|
|
|
|
; working space
|
2021-07-08 01:19:07 +00:00
|
|
|
RES(2)
|
2019-07-07 17:25:47 +00:00
|
|
|
|
|
|
|
END(_)
|