News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How can i use array in assembly

Started by hung3526, March 16, 2025, 09:44:41 PM

Previous topic - Next topic

hung3526

Hi, I'm new to this forum.
I'm learning Assembly and need help on array.
For now, I don't know how to do basic thing like typing or printing the array and want to learn how to do it.

zedd151

What will your array consist of?

Hex bytes, ascii Chars, Unicode chars, words, dwords, qwords, pointers, something else?
A more detailed explanation of what exactly you want to achieve is needed, otherwise we can only speculate on what the array is supposed to contain and what is needed to print it. (To console, I assume) :smiley:

To print the array, the size and type of data in the array is needed, as well as the size of the array. Do you have any code started? If so, please post it.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Hmm, now we have 2 topics going on this subject.
I posted a small example here.
Let me know if you have questions (I'm sure you will).
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on March 17, 2025, 12:28:25 PMHmm, now we have 2 topics going on this subject.
I posted a small example here.
Let me know if you have questions (I'm sure you will).

Maybe stoo can append your example here?
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

hung3526

Quote from: zedd151 on March 17, 2025, 12:12:47 AMWhat will your array consist of?

Hex bytes, ascii Chars, Unicode chars, words, dwords, qwords, pointers, something else?
A more detailed explanation of what exactly you want to achieve is needed, otherwise we can only speculate on what the array is supposed to contain and what is needed to print it. (To console, I assume) :smiley:

To print the array, the size and type of data in the array is needed, as well as the size of the array. Do you have any code started? If so, please post it.

i want to work with an arrays of 10 integers and do something like find the sum, the maximum and print all the positive numbers

jj2007

Quote from: hung3526 on March 18, 2025, 01:00:47 AMi want to work with an arrays of 10 integers and do something like find the sum, the maximum and print all the positive numbers

Check his example.

Quote from: NoCforMe on March 17, 2025, 12:28:25 PMI posted a small example here.

zedd151

Quote from: hung3526 on March 18, 2025, 01:00:47 AMi want to work with an arrays of 10 integers and do something like find the sum, the maximum and print all the positive numbers
Is this an assignment for school, or is this a personal project of your own?
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Quote from: zedd151 on March 18, 2025, 01:18:23 AM
Quote from: hung3526 on March 18, 2025, 01:00:47 AMi want to work with an arrays of 10 integers and do something like find the sum, the maximum and print all the positive numbers
Is this an assignment for school, or is this a personal project of your own?
Who cares? It's an interesting subject, useful for lots of programmers.
Assembly language programming should be fun. That's why I do it.

LordAdef

hi and welcome!

NotCforme gave you an example.

Basically, you need to create a "space" in memory, with the number of "things" you will deal with.
These "things" have a size, integers are dwords, DD:

using NotCforme example:
QuoteArray DD 100 DUP(?)
NotC creates this "space" in memory where the starting address in memory is called Array. If you noticed, he "duplicates" 100 times the size of a dword.

so... in pseudo code

if the offset of Array, ( Array [ 0 ] ), is the first element in that "space", and the size is dword, the second item is the address of
Array[4]
Array[8]
..and so on

use variables instead of numbers, and some interactive logic, and will quickly find out how to add your integers.
The rest you can figure out by studying NotCforme example. I wrote this in a hurry, but I hope it clarifies some basic ground.

You should bare in mind that memory is linear



zedd151

#9
Quote from: NoCforMe on March 18, 2025, 04:45:16 AMWho cares? It's an interesting subject, useful for lots of programmers.
It would inform us on just how much help he needs, is he "brand spankin' new to assembly coding"? For example.

"Does he understand the basics on setting up a bare bones *.asm file at least, just needing to add code and data to it?" i.e., the header (preamble I have heard it called, too) and section declarations, etc. are in the file already.

Without knowing, we can only speculate. So it's better to ask, so we clearly know the depth of help needed here.

It would also be helpful to know whether or not he has either the Masm32 SDK installed, or the Masm64 SDK installed. Or neither.... That would inform us whether he wants to write a 32 bit program, or 64 bit program, or even 16 bit..

More information like this is always better to have, for those wanting to help newcomers.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

stoo23

QuoteMaybe stoo can append your example here?
So is this something that you feel is still necessary (If at all ??) or should the 2 x threads continue to exist separately?