AVL program with file handling.
https://drive.google.com/file/d/0BxZLLe3YK34xWE1qWE5FNlVnbkU/edit?usp=sharing
CREDITS -Omkar Patil
SECTION .datamsg1 : db "Enter two nos:",10len1 : equ $-msg1msg2 : db "The addition is "len2 : equ $-msg2SECTION .bssnum1 resb 4num2 resb 4count1 resb 1count2 resb 1count3 resb 1SECTION .textglobal _start_start: mov eax,4 mov ebx,1 mov ecx,msg1 mov edx,len1 int 0x80label1: mov eax,3 mov ebx,1 mov ecx,num1 mov edx,4 int 0x80 mov byte[count1],02h mov ebx,[num1] SUB ebx,3030hlp: cmp bl,09 jb dig sub bl,07hdig: rol bx,08 dec byte[count1] jnz lp rol bl,4 add bl,bh mov bh,00h mov [num1],ebx label2: mov eax,3 mov ebx,1 mov ecx,num2 mov edx,4 int 0x80 mov byte[count2],02h mov ebx,[num2] SUB ebx,3030hlp1: cmp bl,09 jb dig1 sub bl,07hdig1: rol bx,08 dec byte[count2] jnz lp1 rol bl,4 add bl,bh mov bh,00h mov [num2],ebx adc ebx,[num1]display:mov byte[count3],02h mov ecx,ebx and cx,000Fh and bx,00F0h ror bl,04 mov bh,cllp2: cmp bl,09 jb dig2 add bl,07hdig2: rol bx,08 dec byte[count3] jnz lp2 add bx,3030h mov[num1],ebx mov eax,4 mov ebx,1 mov ecx,num1 mov edx,2 int 0x80 exit: mov eax,1 mov ebx,0 int 0x80
SECTION .data
ReplyDeletemsg1 : db "Enter two nos:",10
len1 : equ $-msg1
msg2 : db "The addition is "
len2 : equ $-msg2
SECTION .bss
num1 resb 4
num2 resb 4
count1 resb 1
count2 resb 1
count3 resb 1
SECTION .text
global _start
_start:
mov eax,4
mov ebx,1
mov ecx,msg1
mov edx,len1
int 0x80
label1: mov eax,3
mov ebx,1
mov ecx,num1
mov edx,4
int 0x80
mov byte[count1],02h
mov ebx,[num1]
SUB ebx,3030h
lp: cmp bl,09
jb dig
sub bl,07h
dig: rol bx,08
dec byte[count1]
jnz lp
rol bl,4
add bl,bh
mov bh,00h
mov [num1],ebx
label2: mov eax,3
mov ebx,1
mov ecx,num2
mov edx,4
int 0x80
mov byte[count2],02h
mov ebx,[num2]
SUB ebx,3030h
lp1: cmp bl,09
jb dig1
sub bl,07h
dig1: rol bx,08
dec byte[count2]
jnz lp1
rol bl,4
add bl,bh
mov bh,00h
mov [num2],ebx
adc ebx,[num1]
display:mov byte[count3],02h
mov ecx,ebx
and cx,000Fh
and bx,00F0h
ror bl,04
mov bh,cl
lp2: cmp bl,09
jb dig2
add bl,07h
dig2: rol bx,08
dec byte[count3]
jnz lp2
add bx,3030h
mov[num1],ebx
mov eax,4
mov ebx,1
mov ecx,num1
mov edx,2
int 0x80
exit: mov eax,1
mov ebx,0
int 0x80