-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISINARR.ASM
82 lines (60 loc) · 1.33 KB
/
ISINARR.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
;
; a000005m.asm
;
; count the divisors of numbers up to 1000
;
; OEIS A000005
;
.model small
.stack 100h
EXTRN dispspace:PROC
EXTRN disp0x:PROC
EXTRN dispCR:PROC
EXTRN disph16:PROC
EXTRN dispd16:PROC
.data
arr dw 1000h dup (00h)
arrlen dw 0000h
.code
isinarr proc
mov dx, @data
mov ds, dx
mov si, 0000h
mov arr[si], 0001h
mov arr[si+2], 0003h
mov arr[si+4], 0007h
mov arr[si+6], 000Bh
mov arrlen, 4
mov ax, 000Bh
call inarr
mov ax, 4C00H ; exit to dos
int 21h
ret
isinarr endp
inarr PROC
push si
push bx
push cx
push dx
mov bx, ax
mov ax, 0000h ; ax is now found flag, bx is
; integer for which to search array
mov cx, arrlen
mov si, 0000h
searchnext:
cmp bx, arr[si]
je found
inc si
inc si
loop searchnext
jmp donesearch
found:
mov ax, 0001h
donesearch:
pop dx
pop cx
pop bx
pop si
ret
inarr endp
end