I need help with my MASM code. When I'm using dynamic allocation for arrays my other variables change values after adding few elements to array.
.686
.387
.model flat, stdcall
.xmm
include include\kernel32.inc
includelib lib\kernel32.lib
.data
szyfr DB 9, 15, 19, 2
;tab DD 4 dup (?) - it works fine
;wynik DD 4 dup (?) - it works fine
tmp DD 0
j DD 0
t DD 0
x DD 2
tmpa DD 0
tmpb DD 0
dlText DD 0
tab DD ?
wynik DD ?
.code
invoke GetProcessHeap
mov ebx, eax
INVOKE HeapAlloc, ebx, 0, 4 - it doesn't work
mov tab, eax
INVOKE HeapAlloc, ebx, 0, 4 - it doesn't work
mov wynik, eax
Writing to array:
xor edx, edx
mov eax, esi ; esi = iterator = i
mul x ; x = 2
mov edx, eax
add edx, j
add edx, offset tab
mov eax, t ; t = number <0, 26>
mov dword ptr [edx], eax ; tab[i][j] = number <0, 26>