Hi,
i'm a student, and i must study assembler and i have some questions:
1)I must do a progam in witch there is an array of integers , and if the element of array is divisible for 3 do a message
2)i'm looking for free good tutorials or guide for assembler can you help me?
sorry for my english...
The MASM32 package has multiple help files and tutorials, current version is 9.
http://www.masm32.com/
Colino,
welcome on board. After reading those examples try to write some code. If it won't work post it in here and help will be soon.
Hi Colino. Arrays work a little different in MASM32, in fact there is no structure type called "Array." But you can achieve the same thing with a STRUCT. Here is a basic struct with 5 elements:
MyStruct STRUCT
one DD ?
two DD ?
three DD ?
four DD ?
five DD ?
MyStruct ENDS
For a full explanation of how structs work, please see \masm32\help\asmintro.hlp, under "Working With Structures."
Have fun and welcome to the group! :U
Code snippet
.data
numarray dd 100 dup (0) ; zero based array 0 to 99, each initialized to 0
szDiv3Msg db "Divides 3 evenly",0
szCaption db "Division by 3 tests.",0
.code
mov ecx, 3
mov esi, 0 ; this is where the loop index should be initialized
.repeat
; mov esi, 0 ; not here inside the loop
mov edx, 0
mov eax, [numarray + esi*4]
div ecx
.if edx == 0 ; edx has the remainder
invoke MessageBox,NULL,ADDR szDiv3Msg,ADDR szCaption,MB_OK
.endif
inc esi
.until esi >= 100 ; elements 0 to 99
dsouza123,
there is a lil bug "mov esi,0" must be out of cycle to avoid infinite loop.
True
My mistake good catch.
It was a quick example to show array declaration and traversal.