Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

Help with an "Array"

A community discussion post from the original code:zIRON forum.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

sorry my mistake i forgot 1 thing *4

procedure printdeck(int32* deck) {
  edx = deck;

  for (ecx = 0 to 52) {    
    eax = [edx+ecx*4];
    print(eax, '\r\n'); 
  }
}

because ecx goes up by 1, this is an offset of address of edx, so +1 is only by 1 byte

edx+1 = byte 2, you want to go up in intervals of 4 since it is an integer :)

a small example:

program WIN32CUI 'test';

#include 'ch.zir';

type DECK = int32;

procedure printdeck(DECK* cards) {
	edx = cards;
	
	for (ecx = 0 to 5) {
		eax = [edx+ecx*4];
		print(eax, '\r\n');
	}
}


DECK mydeck[6];
mydeck[1] = 13;

printdeck(@mydeck);

wait_key();
ExitProcess(0);
Molotov member
Posts
49
Threads
21
Location
Behind Keyboard

ah yeah works perfectly.. how in the name of me did i miss that shit..

"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Glad to hear,

If you need any more help just let me know.