News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Strange behavior in .data

Started by cobold, April 24, 2008, 08:40:22 PM

Previous topic - Next topic

cobold

Hello,

I have these data

    missind     db sudoku_anzahl dup (?)
    miss_num    db ?                        ;Wieviele Zahlen fehlen


In my code, I do fill the array missind[] and I am 100 percent sure that missind[] is filled correctly
For every number missing, I increment miss_num.
miss_num is always 1 instead of 44
So I supposed that I overwrite the array, but I sure do not!

Then I found out, that when I put align <somevalue> between  missind and miss_num everything works fine.
Please, can someone explain me what's happening here?

This code fills the array:
    mov esi,offset GameArray
    mov edi,offset missind
    xor ebx,ebx
    mov miss_num,0
    .while ebx < sudoku_anzahl
        mov al,[esi+ebx]
        .if al==0
            mov [edi+ebx],ebx
            add miss_num,1
        .else
            mov byte ptr[edi+ebx],0ffh
        .endif
        inc ebx
    .endw

test-output without ALIGN
last number missing, therefore missind[80] = 0ffh
80      255 = last byte of array missnum
81      1 = miss_num WRONG
82      56 = should be first byte of code-section ??
miss_num: 1 = shit

BUT WITH ALIGN
80      255 =okay
81      0  = ??? bec of align
82      44 = correct miss_num

So it cannot be wrong code, what's the problem here?
Please enlighten me someone.

cobold
 

MichaelW

The mov [edi+ebx],ebx is moving a dword, instead of a byte. Is this what you intended?

eschew obfuscation

cobold

Thanks a lot Michael,

no, I didn't intend to mov a dword - you opened my eyes!
I still have trouble with addressing - bec I supposed
mov [edi+ebx],ebx moves a BYTE because of lea edi, offset (Bytearray).

thks again, now it works!

rgds