News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Some questions

Started by Colino, April 05, 2006, 01:33:47 PM

Previous topic - Next topic

Colino

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...

dsouza123

The MASM32 package has multiple help files and tutorials, current version is 9.

http://www.masm32.com/   

asmfan

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.
Russia is a weird place

Mark Jones

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
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

dsouza123

#4
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

asmfan

dsouza123,
there is a lil bug "mov   esi,0" must be out of cycle to avoid infinite loop.
Russia is a weird place

dsouza123

True

My mistake good catch.

It was a quick example to show array declaration and traversal.