News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Iterate through the array

Started by MetaMaz, January 25, 2017, 01:42:47 AM

Previous topic - Next topic

MetaMaz

Good day. Please help the novice to the task you need to iterate over the array.
Example Mas 1, -2,4,5, -7
We need to do this two arrays in one positive numbers in the other negative
Example MAC1 -2.-7
mas2 1.4.5
And if you can not hard to recommend books to the newest version MASM.

jj2007

Welcome to the Forum. Just post what you have coded so far, and we'll see if we can help you.

MetaMaz

.386
.Model flat, stdcall
option casemap: none;
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\fpu.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\fpu.lib

.data             
A1 DD -1,1,3,-8,5,3,5,1,-6,1
B1 DD 1,1,1,1,1,1,1,1,1,1
N1 DD 10 
_TA dd 21 DUP (0),0



titl1 db "lab_1 (masm32)",0


_info db "mas A1 = ",0ah,
"mas B1 = 9,8,7,6,5,4,3,2,1,0",0ah,
"out: %d",0
zBuf dd ?,0
.code                     
_start:     
  mov _TA,offset A1     
  mov _TA+40,offset B1 
  mov _TA+81, offset N1
  mov ebx, [_TA]
  call prog1  ;
invoke wsprintf,ADDR zBuf,ADDR _info,edx;
invoke MessageBox,0,addr zBuf,addr titl1,MB_OKCANCEL+MB_ICONQUESTION
invoke ExitProcess, 0

prog1 proc

cmp ecx,10
  xor edx,edx               
  mov ecx,[ebx+80]   
m1: mov esi,[ebx] 
  mov edi,[ebx+40] 
  cmp esi,edi               
  js  m2         
  jmp m3                     
m2:  inc edx         
m3:  add ebx,4
    loop m1 
  ret                               
prog1 endp                         
end _start 



That's what I have.
I need to alter so that would be one of an array of two arrays A1 to make the first positive numbers, the second of the negative.

jj2007

Quote from: MetaMaz on January 25, 2017, 09:07:14 AMThat's what I have.
I need to alter so that would be one of an array of two arrays A1 to make the first positive numbers, the second of the negative.

- Your code has no comments. You cannot code in assembler without detailed comments. Even the most experienced coders here will add a lot of comments to their sources.
- Your remark is not English; it looks like Google translate from an exotic language. I could try to guess what you mean, and maybe I'll try that IF and only IF you post code with plenty of comments.

MetaMaz

Yes I translate in Google.
Now I translate comments into English and will spread code to comment  :biggrin: