Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "asm_io.inc"
- segment .data
- array dw 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- segment .text
- global asm_main
- asm_main:
- mov eax, 0
- mov esi, 0
- mov ecx, 0
- while_loop:
- cmp esi, 20
- je end_loop
- mov ax, [array+esi]
- call es_par
- add esi,2
- jmp while_loop
- end_loop:
- dump_regs ecx
- ret
- _suma:
- cmp eax, 0
- je retornar_1 ; SI EL REGISTRO EAX ES 0 al registro ecx le sumo 0
- add cx, [array+esi]; SI EL REGISTRO EAX NO ES 0 al registro ecx le sumo el par del arreglo
- jmp fin
- retornar_1:
- add cx, 0
- fin:
- ret
- es_par:
- push ebp ; apilo el puntero base en la pila
- mov ebp, esp
- mov eax, [array+esi]
- shr eax ,1
- jc _impar
- shl eax ,1
- call _suma
- _impar
- mov esp, ebp
- pop ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement