Hello everyone!

I have a small problem, taking up good ol' winasm again and i struck my wall to the head at the first 100 lines...

I have a loop in the code, and i want to add a string (atm just 1 char) to an array, and then I want to get this string out of the array again.. and i can't get it to work... :(



mov hHandleArray[ecx],ebx
...
lea edx, hHandleArray[ecx]
...


But they are empty ... i do something wrong i know .. but can't figure out what ...

Thanks!

PS. f0dder thanks alot for your help earlier! :alright:
Posted on 2004-04-07 04:24:02 by cTT
I use these two MACROs to DWORDS arrays and i have no problem with them.



DATA?
array1 DWORD ?
;...
SetIndexValue MACRO array,index,val
mov ecx,index
shl ecx,2
mov array[ecx],val
endm

GetIndexValue MACRO array,index
mov ecx,index
shl ecx,2
mov eax,array[ecx]
endm
;...
SetIndexValue array1,0,2
GetIndexValue array1,0

hope this helps :notsure:
Posted on 2004-04-07 04:53:45 by bj1500
Helped alot! Thank you! :D
Posted on 2004-04-07 06:54:38 by cTT
Lol, you can't be serious!
Posted on 2004-04-07 08:55:11 by Sephiroth3
Sure can! :)
Posted on 2004-04-07 09:20:53 by cTT

Lol, you can't be serious!


everyone has to start somewhere Sephiroth3.

Welcome cTT and don't worry, it will all come back to you soon :alright:
Posted on 2004-04-07 16:08:08 by Hiroshimator
Probly will ... ;) Waiting for it is painful tho hehe :)
Posted on 2004-04-07 17:30:21 by cTT
Actually I was referring not to cTT but to bj1500's molesting of the assembly programming language :P
Well, I guess that's the trend these days.
Posted on 2004-04-07 17:33:10 by Sephiroth3
What is wrong with my code? please explain!

if I do something wrong please let me know so i can be better on this.

just writing "lol you cant be serious" dosent help me very much.
I know i'm a "noob" or "newbie" (or what ever you call it) in assembler but i like to program in assembler and really want to learn alot about this. so please send me a message or something when i'm doing something wrong while trying to help other people on this board.
Posted on 2004-04-07 18:51:26 by bj1500
Hmm okay, well, what I meant was it takes longer to type the name of the macro than typing the appropriate instruction :P I'm sure you'll get tired of writing SetIndexValue all over your code instead of mov. Most people would prefer to use macros to save headaches. For example, you could use a macro to enter names of imported functions accessed through the import libraries included with MASM like this:
imp macro name:REQ,np:REQ

bleh textequ @CatStr(<__imp__&name&@>,%np*4)
%extrn bleh:dword
%name equ bleh
endm

Another use for a macro could be entering data for an Interrupt Descriptor Table, where the high word of the ISR address does not directly follow the low word.

Remember that you can use a register (except for ESP) multiplied by 1, 2, 4 or 8 in an address with a 32-bit offset or another register and a 8-bit or 32-bit offset. An example of this addressing mode would be . I'm sure you can figure out the rest...
Posted on 2004-04-07 19:27:37 by Sephiroth3
actually I use this macro to make my code more readable.
I dont understand why you cant do like this
and if i should do this "by hand" I would have very hard to read my own code...
This code make it easier for me.

and its true that i'm come from a high level language like VB and delphi.
Posted on 2004-04-07 19:31:43 by bj1500

Hmm okay, well, what I meant was it takes longer to type the name of the macro than typing the appropriate instruction :P I'm sure you'll get tired of writing SetIndexValue all over your code instead of mov. Most people would prefer to use macros to save headaches. For example, you could use a macro to enter names of imported functions accessed through the import libraries included with MASM like this:
imp macro name:REQ,np:REQ

bleh textequ @CatStr(<__imp__&name&@>,%np*4)
%extrn bleh:dword
%name equ bleh
endm

Another use for a macro could be entering data for an Interrupt Descriptor Table, where the high word of the ISR address does not directly follow the low word.

Remember that you can use a register (except for ESP) multiplied by 1, 2, 4 or 8 in an address with a 32-bit offset or another register and a 8-bit or 32-bit offset. An example of this addressing mode would be . I'm sure you can figure out the rest...


Okey but i'm still used to write long function names from highlevel language.
actully writing mov everywhere should give me a headache :grin:

But now lets end this discussion.
I code like i use to do and you code like you use do to :tongue:
Posted on 2004-04-07 19:37:56 by bj1500
if you think he molests it, u aint seen my rapin and pillaging yet ...

sephiroth, that name sounds familliar, are you from the gamedev forum?
Posted on 2004-04-07 20:26:00 by drarem
Lol ok, well I've seen a lot of weird shit on this board anyway.
I've never been to the gamedev.net board, but Sephiroth is a very common Internet name. It became popular due to the last boss in the Final Fantasy 7 video game for the Playstation, whom many players found to be quite a striking character. I had just played that game when I got my Internet account, so I went with the name Sephiroth3 (there were two Sephiroths already on the board I first went to :P)
Posted on 2004-04-07 20:48:03 by Sephiroth3
bj,

Keep using those long names. Just make sure they say what they mean.

I've worked with production assembly code with lots of long names. And it is extremely helpful when you're passing code from one person to another.

Just an optimization:

SetIndexValue MACRO array,index,val

mov ecx,index
mov array[ecx*4],val
endm

GetIndexValue MACRO array,index
mov ecx,index
mov eax,array[ecx*4]
endm
Posted on 2004-04-07 22:24:25 by tenkey
Thanks tenkey, even better :)
And yeah, bj1500, forts?tt anv?nda l?nga namn :) B?de f?r dig och mig :alright:
Posted on 2004-04-08 00:16:50 by cTT
Tja indeksen er jo ofte allerede i et register og da blir det jo bare teit :P
Posted on 2004-04-08 07:48:44 by Sephiroth3
S? snak dog Engelsk, i Svenske hunde ;)
Posted on 2004-04-08 08:56:13 by f0dder
Actually, i didnt understand shit of your danish sentence there f0dd... :)

Speh, well, that right too ... hmm ... well i use long name for it now ... change it when i get used to this again ... :)
Posted on 2004-04-08 09:15:07 by cTT
Btw, the macros could probably be improved by using of masm's parameter checking feature thingamajig (OPATTR, I think) on the index: if it's a constant, use it directly. If it's a register, use it directly. If it's a memory value, load it into a register and then use it.
Posted on 2004-04-08 09:44:00 by f0dder