Tuesday 5 April 2016

32 bit ALP:Reading 32 bit numbers and printing them back

Q: Write an x86 ALP to read 10 32 bit numbers. Store these in an array. And print them back using various system calls.



Code


%macro disp 2 
mov eax,04  ;macro to call display function call
mov ebx,01
mov ecx,%1
mov edx,%2
int 80H
%endmacro

section .data
count: db 0AH

section .bss
array: resb 90H

global _start
section .text
_start:

mov esi,array  ; store location of array in esi

x: 
mov eax,03  ;read system call
mov ebx,01
mov ecx,esi
mov edx,09
int 80H
add esi,09
dec byte[count]  ;counter to set the number of calls
jnz x

mov esi,array
mov byte[count],0AH

y:
disp esi,09  ;call to macro
add esi,09
dec byte[count]
jnz y

mov eax,01  ;exit system call
mov ebx,00
int 80H

No comments:

Post a Comment