flat assembler
Message board for the users of flat assembler.
Index
> Main > Array |
Author |
|
roticv 17 Jan 2004, 02:27
You need something to mark the end of the array... something like a double null or something like that.
|
|||
17 Jan 2004, 02:27 |
|
VitalOne 17 Jan 2004, 06:18
Code: proc GetString,ID enter push edx ebx ecx mov dl,byte[ID] lea esi,[_simple_array] mov ecx,0 .loop: lodsb cmp al,dl je .done inc ecx jmp .loop .done: inc ecx lea eax,[_simple_array+ecx] pop edx ebx ecx return This works for your situation but if your array ID is a character then it won't work (like 'A' and 65) So you should use a different system unless your arrays are small. |
|||
17 Jan 2004, 06:18 |
|
Alessio 18 Jan 2004, 18:50
Thank you all.
|
|||
18 Jan 2004, 18:50 |
|
Madis731 18 Jan 2004, 19:52
It seems to me that your code switches the places of ecx and edx
... push edx ebx ecx ... pop edx ebx ecx ... OR does it really compile to push edx push ebx push ecx pop ecx pop ebx pop edx ??? |
|||
18 Jan 2004, 19:52 |
|
VitalOne 19 Jan 2004, 03:02
No, that was an error , thanks.
|
|||
19 Jan 2004, 03:02 |
|
HarryTuttle 20 Jan 2004, 10:11
Code: include '%fasminc%/win32ax.inc' .data _simple_array: cat db 'cat',0 dog db 'dog',0 dolphin db 'dolhpin',0 monkey db 'monkey',0 donkey db 'donkey',0 pig db 'pig',0 end_array db 0,0 _simple_pointer2array dd cat,dog,dolphin,monkey,donkey,pig ;0->cat; 5->pig .code start: mov edi,2 ; <---which element shl edi,2 invoke MessageBox,0,[_simple_pointer2array+edi],"array",0; show me-> _simple_array[2] invoke ExitProcess,0 .end start _________________ Microsoft: brings power of yesterday to computers of today. |
|||
20 Jan 2004, 10:11 |
|
HarryTuttle 20 Jan 2004, 15:40
Thanx to Privalov:
Code: include '%fasminc%/win32ax.inc' macro strtbl name,[string] { common label name dword forward local label dd label forward label db string,0 } .data strtbl array_animal,'dog','cat','dolphin','monkey','donkey','pig' .code start: mov eax,5 ;<--- give me the pig , 0->dog ; 1->cat ;dolphin->2 mov esi,[array_animal+eax*4] invoke MessageBox,0,esi,"array",0 invoke ExitProcess,0 .end start _________________ Microsoft: brings power of yesterday to computers of today. |
|||
20 Jan 2004, 15:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.