-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasgn5.asm
102 lines (82 loc) · 1.56 KB
/
asgn5.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
%macro print 2
mov rax,01
mov rdi,01
mov rsi,%1
mov rdx,%2
syscall
%endmacro
section .data
msg1 db "Count of Positive numbers: ",
len1 equ $-msg1
msg2 db "Count of negative numbers:"
len2 equ $-msg2
msg3 db "",10,13,
len3 equ $-msg3
array db 10,12,-21,-12,-19,-34,41
section .bss
count resb 2
pcount resb 2
ncount resb 2
totalcount resb 2
section .text
global _start
_start:
mov byte[count],07
mov byte[pcount],00
mov byte[ncount],00
mov rsi,array
Up:
mov al,00
add al,[rsi]
js neg
inc byte[pcount]
jmp Down
neg:
inc byte[ncount]
Down:
add rsi,01
dec byte[count]
jnz Up
mov bl,[pcount]
mov dl,[ncount]
b1:
print msg1,len1
mov bh,[pcount]
call disp
print msg3,len3
print msg2,len2
mov bh,[ncount]
call disp
print msg3,len3
mov rax,60
mov rdi,00
syscall
disp:
mov byte[count],02
loop:
rol bh,04
mov al,bh
AND al,0FH
cmp al,09
jbe l1
add al,07h
l1:add al,30h
mov[totalcount],al
print totalcount,02
dec byte[count]
jnz loop
ret
; code at home/desktop/21226
;10,13 represents next line
;equ replaces the the code by that block
;bss block section size --> that does dynamic input thats not initialised
;codes to run the file are
;save file as asgn5.asm
;open the location and open folder in terminal where file is saved
;type command nasm -f elf64 asgn5.asm
;type ls
;check asgn5.o file is created or not
;type ld -o file asgn1.o
;type ls
;check in green the file is created or not
;type ./file and run