Register | Login
Forum Index > Source Help > Help with an "Array"
Author Message
Pages: 1 2
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[1251] Help with an "Array" - posted: 2012-12-09 16:05:12
Having some problems finding a way to make my default carddeck it´s basicly just an int array.

was thinking about switching to a linkedlist in which i also could store the names, but not sure.

Code:
function makedefaultdeck(DWord lang; int32* deck) {
  uses ecx ebx;
  // Make card deck
  ebx = lang;
  ecx = 0;
  while(ecx < 52) {
    deck[ecx] = ecx+1; // not sure the best way to do this in ziron
    ecx++;
  }
}


thanks in advance.

"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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1252] - posted: 2012-12-09 16:15:58
give something like this a try:

Code:
function makedefaultdeck(DWord lang; int32* deck) {
  uses edx; // if you really want to make sure edx is not changed;
                  // else it is not important

  // Make card deck
  // edx = lang; // didnt see this used so removed for now
  eax = 1;
  edx = deck;

  while (eax < 53) {
    [edx+eax-1] = eax;
    eax += 1;
  }
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[1253] - posted: 2012-12-09 18:43:03
Ah works as it should.. This is embarrasing.. i´ve basicly forgotten everything in the last 6-8months..

How would i print out the deck using in another function?

"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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1254] - posted: 2012-12-09 20:07:49
don't quite understand your question but try along these lines:

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

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


please explain a little more if this is not what you mean smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[1256] - posted: 2012-12-09 22:13:08
actually it was exactly what i meant but i got the same as when i made it.. a crash in the application. i will update compiler and try again.

if it doesn´t work i´ll send you the crash report information here later.

"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
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[1257] - posted: 2012-12-09 22:23:15
This is what i get in crashreport from drwatson32.exe when i try to run that procedure.


eax=00000000 ebx=7ffd4000 ecx=ffffffff edx=00402134 esi=00370031 edi=04030201
eip=00403223 esp=0012ff98 ebp=0012ffa0 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246

funktion: testing
00403212 0800 or [eax],al
00403214 55 push ebp
00403215 8bec mov ebp,esp
00403217 57 push edi
00403218 51 push ecx
00403219 33c9 xor ecx,ecx
0040321b 8b7d08 mov edi,[ebp+0x8]
0040321e f7d1 not ecx
00403220 32c0 xor al,al
00403222 fc cld
ERROR ->00403223 f2ae repne scasb es:04030201=??
00403225 f7d1 not ecx
00403227 8d41ff lea eax,[ecx-0x1]
0040322a 59 pop ecx
0040322b 5f pop edi
0040322c c9 leave
0040322d c20400 ret 0x4
00403230 55 push ebp
00403231 8bec mov ebp,esp
00403233 56 push esi
00403234 57 push edi

*----> Bakåtspårning i stacken <----* // Backtrace in stack
WARNING: Stack unwind information not available. Following frames may be wrong.
ChildEBP RetAddr Args to Child
0012ffa0 004033c7 04030201 00402134 00000000 string_sample+0x3223
0012ffb8 00403042 00402134 7c817067 00390034 string_sample+0x33c7
0012fff0 00000000 00403000 00000000 78746341 string_sample+0x3042




"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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1258] - posted: 2012-12-09 23:03:06
That crash report looks very strange since a-lot of it looks messed up, also that is not showing the printdeck function I posted, can you show me exactly the function if you've made modifications too.


also try adding include for ch.zir

#include 'ch.zir';

just after your program declaration, and then to run it and tell me what it says then.

if the crash is only since printdeck try change it like so and let me know also:

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

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


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[1259] - posted: 2012-12-12 01:28:07
Tried with #include 'ch.zir';

I get access violation error at adress 4207155

When i try the updated function i don´t see what i expected.

it should write: 1, 2, 3, 4, 5, and so on

But i get: 67305985, 84148994, 100992003, 117835012 and so on, then second to last it writes 52 then 0

does it write memory adresses? im lost.

"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
Pages: 1 2
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 12 user(s) online. 0 member(s) and 12 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd