3323 MM Assignment3.odt

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 3

3323_Divya Ulhasrao Challawar

Assignment 3
A2 batch

code:
----------------------------------------------------------------------------------------------------------------------------
Section .data
msg1 db " Enter the number",0ah
msg1len equ $ -msg1

msg2 db " Positive",0ah


msg2len equ $ -msg2

msg3 db " Negative",0ah


msg3len equ $ -msg3

msg4 db "The number is zero",0ah


msg4len equ $ -msg3

Section .bss
n1 resb 2

Section .text

Global _start
_start:
mov eax,4
mov ebx,1
mov ecx,msg1
mov edx,msg1len
int 80h

mov eax,3
mov ebx,0
mov ecx,n1
mov edx,2
int 80h

mov esi,n1
mov al, byte[esi]

cmp al, 2Bh


je p

cmp al, 2Dh


je n

cmp al,30h
je z

p:

mov eax,4
mov ebx,1
mov ecx,msg2
mov edx,msg2len
int 80h
jmp end

n:
mov eax,4
mov ebx,1
mov ecx,msg3
mov edx,msg3len
int 80h
jmp end

z:
mov eax,4
mov ebx,1
mov ecx,msg4
mov edx,msg4len
int 80h
jmp end

end:
mov eax,1
mov ebx,0
int 80h

----------------------------------------------------------------------------------------------------------------------------
output:
----------------------------------------------------------------------------------------------------------------------------
[ccoew@localhost ~]$ gedit numbers.asm
[ccoew@localhost ~]$ nasm -f elf64 -F stabs numbers.asm
[ccoew@localhost ~]$ ld -o num numbers.o
[ccoew@localhost ~]$ ./num
Enter the number
0
The number is zero
0
[ccoew@localhost ~]$ ./num
Enter the number
40
Positive
[ccoew@localhost ~]$
[ccoew@localhost ~]$ ./num
Enter the number
-2
Negative
----------------------------------------------------------------------------------------------------------------------------

You might also like