Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "asm_io.inc"
  2.  
  3. segment .data
  4. array dw 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  5.  
  6. segment .text
  7.  
  8. global asm_main
  9. asm_main:
  10.     mov eax, 0
  11.     mov esi, 0
  12.     mov ecx, 0
  13.         while_loop:
  14.         cmp esi, 20
  15.         je end_loop
  16.         mov ax, [array+esi]
  17.         call es_par
  18.         add esi,2
  19.         jmp while_loop
  20.     end_loop:
  21.     dump_regs ecx
  22. ret  
  23.  
  24. _suma:
  25.     cmp eax, 0
  26.         je retornar_1 ; SI EL REGISTRO EAX ES 0 al registro ecx le sumo 0
  27.         add cx, [array+esi]; SI EL REGISTRO EAX NO ES 0 al registro ecx le sumo el par del arreglo
  28.         jmp fin
  29.         retornar_1:
  30.         add cx, 0
  31.     fin:
  32. ret
  33.  
  34. es_par:
  35.   push ebp ; apilo el puntero base en la pila
  36.   mov ebp, esp
  37.   mov eax, [array+esi]
  38.   shr eax ,1
  39.   jc _impar
  40.   shl eax ,1
  41.   call _suma
  42.   _impar
  43.   mov esp, ebp
  44.   pop ebp
  45. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement