The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Colino on April 05, 2006, 01:33:47 PM

Title: Some questions
Post by: Colino on April 05, 2006, 01:33:47 PM
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...
Title: Re: Some questions
Post by: dsouza123 on April 05, 2006, 02:21:43 PM
The MASM32 package has multiple help files and tutorials, current version is 9.

http://www.masm32.com/   
Title: Re: Some questions
Post by: asmfan on April 05, 2006, 06:05:31 PM
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.
Title: Re: Some questions
Post by: Mark Jones on April 05, 2006, 06:28:53 PM
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
Title: Re: Some questions
Post by: dsouza123 on April 05, 2006, 06:47:27 PM
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
Title: Re: Some questions
Post by: asmfan on April 05, 2006, 07:05:48 PM
dsouza123,
there is a lil bug "mov   esi,0" must be out of cycle to avoid infinite loop.
Title: Re: Some questions
Post by: dsouza123 on April 05, 2006, 09:41:40 PM
True

My mistake good catch.

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