Professional Documents
Culture Documents
3323 MM Assignment3.odt
3323 MM Assignment3.odt
3323 MM Assignment3.odt
Assignment 3
A2 batch
code:
----------------------------------------------------------------------------------------------------------------------------
Section .data
msg1 db " Enter the number",0ah
msg1len equ $ -msg1
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,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
----------------------------------------------------------------------------------------------------------------------------