flat assembler
Message board for the users of flat assembler.

Index > Main > Questions by index of massive and procedures

Author
Thread Post new topic Reply to topic
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
What syntax of handling to element of massive?

mov si, 2
mov ax, mas[si] (MASM version?)

doesn't work.

What syntax of procedure and where may I read about procedures in FASM?
Post 09 Nov 2013, 00:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17476
Location: In your JS exploiting you and your system
revolution
Try this:
Code:
mov ax,[si+mas]    
Post 09 Nov 2013, 03:29
View user's profile Send private message Visit poster's website Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
I try to write first and last elements to variables, but have some troubles
like this:
Quote:
error: operand sizes do not match.

or this this
Quote:
error: invalid operand.

if use movsx

Code:
xor eax,eax
lea dx, [mas]
mov edi, 10
mov esi, 1
movsx ax, [esi+mas]
mov [a], ax
movsx ax, [edi+mas]
mov [b], ax    
Post 09 Nov 2013, 08:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17476
Location: In your JS exploiting you and your system
revolution
How have you defined mas?
Post 09 Nov 2013, 08:10
View user's profile Send private message Visit poster's website Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
revolution wrote:
How have you defined mas?

db, ten elements
Post 09 Nov 2013, 08:18
View user's profile Send private message Reply with quote
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt
You are trying to mov byte to ax (word)
Code:
mov al, [(e)si + mas]    

Or if you want to get 2 bytes in ax:
Code:
mov ax, word[(e)si + mas]    
Post 09 Nov 2013, 08:43
View user's profile Send private message Visit poster's website Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
Code:
mov ax, word[(e)si + mas]    

Quote:
error: invalid address.


It's just appel to elements of array, what's wrong the syntax to this o.O
Post 09 Nov 2013, 09:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17476
Location: In your JS exploiting you and your system
revolution
Just use si.
Code:
mov ax,word[si+mas]    
Post 09 Nov 2013, 09:07
View user's profile Send private message Visit poster's website Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
this is have no effect, look:


Description:
Filesize: 51.92 KB
Viewed: 4658 Time(s)

1.png


Post 09 Nov 2013, 09:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17476
Location: In your JS exploiting you and your system
revolution
If you are using a PE file then you will need to use the 32-bit registers for addressing. Use ESI.
Post 09 Nov 2013, 09:19
View user's profile Send private message Visit poster's website Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
If Array have 10 symbols, how many positions need to shift to appeal to last element?
Post 09 Nov 2013, 09:32
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Satansoft wrote:
If Array have 10 symbols, how many positions need to shift to appeal to last element?


In programming, everything is counted from 0. If you want to read the last word from your 10 bytes array, use:
Code:
mov  esi, mas
mov  ax, word [esi+8]    
Or even more simple:
Code:
mov  ax, word [mas+8]    
Using registers as an address worths only if you need to cycle through the array.

P.S. BTW, where are you from? Naming an array "масив" talks about some of the slavonic languages. Smile

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9


Last edited by JohnFound on 09 Nov 2013, 10:28; edited 1 time in total
Post 09 Nov 2013, 09:50
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Satansoft



Joined: 09 Nov 2013
Posts: 7
Satansoft
Thx to all helpers.

Quote:

Naming an array "масив" is a talks about Slavonic language.

Have no Slavonic language, it's an a group of languages.
Quote:

where are you from?

Greetings from Ukraine :3
Post 09 Nov 2013, 10:08
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Satansoft wrote:
Greetings from Ukraine :3

Welcome in the assembly world. Wink

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 09 Nov 2013, 10:29
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Bargest



Joined: 09 Feb 2012
Posts: 79
Location: Russia
Bargest
Do you really want to get WORD from array? It's defined as 'db', so reading by words will give you values as 406h, 609h, 92Bh, etc. I think you should use AL:
Code:
mov al, [mas + 9]
    
Post 09 Nov 2013, 16:44
View user's profile Send private message Reply with quote
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr
Try any of these:
Code:
; When mas is a global variable (as in your example), the following will work
mov  al, [mas + 9]

;-- OR --

mov  edx, mas
mov  al, [edx+9]


; But when 'mas' is a stack-based variable, you should use 'lea':
lea  edx, [mas]         ; also works when 'mas' is global
mov  al, [edx + 9]    
Post 09 Nov 2013, 17:19
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.