-
Notifications
You must be signed in to change notification settings - Fork 0
/
A000322M.ASM
139 lines (106 loc) · 2.92 KB
/
A000322M.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
;--------------------------------------------------------------------
;
; a000322m.asm
;
; Pentanacci numbers: F(n) = F(n-1) + F(n-2) + F(n-3) + F(n-4)
; + F(n-5), F(0) = F(1) = F(2) = F(3) = F(4) = 1
;
; OEIS A000322
;
;--------------------------------------------------------------------
.model small
.stack 100h
EXTRN dispspace:PROC
EXTRN disp0x:PROC
EXTRN dispCR:PROC
EXTRN disph16:PROC
EXTRN dispd16:PROC
.data
max dw 14h
arr dw 15h DUP (00h)
f0 dw 0000h
f1 dw 0000h
f2 dw 0000h
f3 dw 0000h
f4 dw 0000h
f5 dw 0000h
.code
a000322 PROC
push bp
mov bp, sp
push si
mov dx,@data
mov ds,dx
mov arr[0], 0001h ; F(0) = 1
mov f5, 0001h
mov arr[2], 0001h ; F(1) = 1
mov f4, 0001h
mov arr[4], 0001h ; F(2) = 1
mov f3, 0001h
mov arr[6], 0001h ; F(3) = 1
mov f2, 0001h
mov arr[8], 0001h ; F(4) = 1
mov f1, 0001h
mov si, 000Ah
mov cx, 0005h ; cx = n
getanother:
mov ax, f5
add ax, f4
add ax, f3
add ax, f2
add ax, f1
mov arr[si], ax
inc si
inc si
inc cx
cmp cx, max
je displaynow
mov bx, f4 ; F5 = F4
mov f5, bx
mov bx, f3 ; F4 = F3
mov f4, bx
mov bx, f2 ; F3 = F2
mov f3, bx
mov bx, f1 ; F2 = F1
mov f2, bx
mov f1, ax ; F2 = F1
jmp getanother
displaynow:
mov cx, 0000h
mov si, 0000h
disploop:
mov ax, arr[si]
call dispA
inc cx
cmp cx, max
je alldone
inc si
inc si
jmp disploop
alldone:
mov ax, 4C00h
int 21h
a000322 endp
;-------------------------------------------------------------------------
dispA PROC ; display routine for OEIS
; a......(n) in ax, n in cx
push ax
push bx
push cx
push dx
mov dx, ax
mov ax, cx
call dispd16
call dispspace
call dispspace
call dispspace
mov ax, dx
call dispd16
call dispCR
pop dx
pop cx
pop bx
pop ax
ret
dispA endp
end