Hello!
This is my 32 bit number version and works too.
It add's even values into memory address dword [evenAdd].
It count's even values into memory address dword [evenCount].
LINUX:
section .data
list: dd 1,2,3,4,5,6,7,8,9,10
evenAdd: dd 0
evenCount: dd 0
section .bss
section .text
global _start
_start:
nop
; TODO: your code here
;clearing the registers that are going to be used
xor ecx,ecx
mov ebx,dword 2
mov esi,dword list
initialLoop:
push ecx ; (+1)
xor eax,eax
mov eax,dword [esi]
mov ecx,eax
div ebx
cmp edx,dword 1
je initialLoop.thisIsOddNumber
add dword [evenAdd],ecx
inc dword [evenCount]
initialLoop.thisIsOddNumber:
pop ecx ; (-1)
inc ecx
add esi,dword 4
cmp ecx,dword 10
jl initialLoop
; call CrackMonitorScreen
mov ebx,0
mov ebx,eax
mov eax, 1
int 0x80
; If data is => list: dd 1,2,3,4,5,6,7,8,9,10
; Then loop named "initialLoop", produces:
; value of dword [evenAdd] => 30
; value of dword [evenCount] => 5
WINDOWS:
This actually is the version, that i tested:
; ---------------------------------------------------------------------------
; WINDOWS VERSION
; ---------------------------------------------------------------------------
; ---------------------------------------------------------------------------
; Tell compiler to generate 32 bit code
; ---------------------------------------------------------------------------
bits 32
; ---------------------------------------------------------------------------
; Data segment:
; ---------------------------------------------------------------------------
section .data use32
; Multiline printf format
txt_format: db 10,"==========================="
db 10,"Hello world:"
db 10,"==========================="
db 10,"evenAdd: %d"
db 10,"evenCount: %d"
db 10,"===========================",10,0
align 8 ; Align data
list: dd 1,2,3,4,5,6,7,8,9,10
align 8 ; Align data
evenAdd: dd 0
align 8 ; Align data
evenCount: dd 0
align 8 ; Align data
; ---------------------------------------------------------------------------
; Code segment:
; ---------------------------------------------------------------------------
section .text use32
; ---------------------------------------------------------------------------
; C management
; ---------------------------------------------------------------------------
global main
extern printf
main:
xor ecx,ecx
mov ebx,dword 2
mov esi,dword list
initialLoop:
push ecx ; (+1)
xor eax,eax
mov eax,dword [esi]
mov ecx,eax
div ebx
cmp edx,dword 1
je initialLoop.thisIsOddNumber
add dword [evenAdd],ecx
inc dword [evenCount]
initialLoop.thisIsOddNumber:
pop ecx ; (-1)
inc ecx
add esi,dword 4
cmp ecx,dword 10
jl initialLoop
push dword [evenCount]
push dword [evenAdd]
push dword txt_format
call printf
add esp,dword 4*3
; -----------------------------------------------------------------------------
; Quit
; -----------------------------------------------------------------------------
mov eax,dword 0
ret
; ----
; END ----
; ----
This is output of windows example:
===========================
Hello world:
===========================
evenAdd: 30
evenCount: 5
===========================
I compiled like this:
"nasm.exe test.asm -f win32 -o test.obj"
"golink.exe /entry main test.obj MSVCRT.dll"
And that's it!
Encryptor256!!!
Edit:
Attachment contains updated code of Windows and Linux versions.
Attachment, Version History:
1. WindowsVersion1.pdf (OLD, basic)
2. WindowsVersion2_LODSD.pdf (OLD, using LODSD)
3. WindowsVersion3_TEST.pdf (NEW, using TEST, shorter code)
3. LinuxVersion3.pdf (NEW, using TEST, shorter code)
I assume that your code is for linux, so that's why, in this post, you can find, word "linux".
I didn't managed to test linux version, but windows version works fine.