Asking for comments on babysteps asm program
Posted: Thu Jul 11, 2013 5:41 am
Hi again!
I'm hoping some comments / criticism on this small asm testing I wrote. The program reads user input into array and then prints out the array using c library (through the pcasm books inc files)
The program works but am I doing something terribly badly?
I'm hoping some comments / criticism on this small asm testing I wrote. The program reads user input into array and then prints out the array using c library (through the pcasm books inc files)
The program works but am I doing something terribly badly?
Code: Select all
;nasm -f elf -o subs_arrays1.o subs_arrays1.asm
;gcc -m32 -lc -o subs_arrays1 driver.o subs_arrays1.o ../pcasm_shared/asm_io.o
;./subs_arrays1
%include "../pcasm_shared/asm_io.inc"
;initialized data
segment .data
prompt_message db "Enter a number: ", 0
;unintitialized data
segment .bss
array_user_input_numbers resd 3
;code
segment .text
global asm_main
asm_main:
;*********************************************************
;*********************************************************
for_user_input_begin:
mov ecx, 0
mov ebx, array_user_input_numbers
for_user_input_body:
mov eax, prompt_message
call print_string
push dword ebx ;ebp + 8
call get_input
add esp, 4
call print_nl
add ebx, 4
inc ecx
cmp ecx, 3
je for_user_input_end
jmp for_user_input_body
for_user_input_end:
;*********************************************************
;*********************************************************
for_print_begin:
mov ecx, 0
mov ebx, array_user_input_numbers
for_print_body:
mov eax, [ebx]
call print_int
call print_nl
inc ecx
add ebx, 4
cmp ecx, 3
je for_print_end
jmp for_print_body
for_print_end:
;*********************************************************
;*********************************************************
mov eax, 1
mov ebx, 0
int 80h
;*********************************************************
;*********************************************************
get_input:
; push ebx
; push eax
push ebp
mov ebp, esp
call read_int
mov ebx, [ebp + 8] ;how come this be 8 and not 4?
mov [ebx], eax
pop ebp
; pop eax
; pop ebx
ret