
Best Answer dargueta, 09 April 2015 - 10:26 AM
Oh. Change
A: db 10 B: db 2
to
A: dd 10 B: dd 2
and that should fix it. I'll explain why if it does.
Go to the full post
deleteMyAccount - Apr 15 2018 07:08 PM
deleteMyAccount - Apr 15 2018 07:08 PM
nino - Apr 12 2018 09:13 AM
dasswadesh - Jan 30 2018 03:16 AM
Amyrivers - Oct 17 2017 01:24 AM
Best Answer dargueta, 09 April 2015 - 10:26 AM
Oh. Change
A: db 10 B: db 2
to
A: dd 10 B: dd 2
and that should fix it. I'll explain why if it does.
Go to the full postPosted 09 April 2015 - 10:26 AM Best Answer
Oh. Change
A: db 10 B: db 2
to
A: dd 10 B: dd 2
and that should fix it. I'll explain why if it does.
sudo rm -rf / && echo $'Sanitize your inputs!'
Posted 09 April 2015 - 10:41 AM
hhhhhhhhhhh loooooool it's works man thaaaaankx a looooot
but why ?? db dosn't work and dd works ?
Edited by zika, 09 April 2015 - 10:44 AM.
Posted 09 April 2015 - 11:00 AM
So here's the thing: db reserves a single byte in memory and assigns a value to it. dw reserves a word (two bytes, like ax), and dd reserves a doubleword (four bytes, like eax).
In C and other languages, doing something like this:
char a = 5; int b = a;
would result in a == b. The processor (and therefore assembly language) has no concept of data types; all memory is the same. A processor can't look at a memory address and tell the difference between a 32-bit integer, a 32-bit pointer, a four-byte array, etc. It's just four bytes. Data types are a language feature.
The problem was that you were reserving a byte for A but then reading an entire dword. Thus, the processor loaded A plus the next three bytes, regardless of what they were, into eax instead of loading the first byte and zeroing out the upper 24 bits as you were expecting.
So eax and ebx were mostly filled with random values when you were comparing them, thus resulting in your problem.
Edited by dargueta, 09 April 2015 - 11:01 AM.
sudo rm -rf / && echo $'Sanitize your inputs!'
Posted 09 April 2015 - 11:42 AM
emmmm ok thanks for clearfy ur answer.
so when I xor eax , eax the resault will be zero ok
but when I moved db to eax its take 1 byte and remain bytes it's feel by random values that's what do u mean ?
Posted 09 April 2015 - 11:47 AM
The rest is filled by whatever the next three bytes in memory happen to be. It might not be random. For example:
A: db 1 B: db 2 C: db 3 D: db 4 mov eax, [A] ; EAX = 0x04030201
sudo rm -rf / && echo $'Sanitize your inputs!'
Posted 09 April 2015 - 12:16 PM
thanx a lot Mr dargueta take this u have no idea how much I smached me screen to do that
Posted 09 April 2015 - 08:53 PM
Haha no problem. By the way, if you do need to do zero extension, you can use movzx, or movsx for signed numbers.
Take these examples:
unsigned char A = 5; unsigned int i = A; movzx eax, BYTE [A]
signed char B = -5; int i = B; movsx eax, BYTE [B]
You can also do the reverse:
al = -10; signed short s = al; movsx WORD [s] = al
And between registers:
movzx eax, bl
Edited by dargueta, 09 April 2015 - 08:54 PM.
sudo rm -rf / && echo $'Sanitize your inputs!'
Posted 10 April 2015 - 01:49 AM
got it Mr dargueta thanx a lot
I'v changed dd to db and change mov eax , [A] to mov al ,[A] and it's works . thanx I'll try to do it with movzx and movsx and see the output
Haha no problem. By the way, if you do need to do zero extension, you can use movzx, or movsx for signed numbers.
Take these examples:
unsigned char A = 5; unsigned int i = A; movzx eax, BYTE [A]signed char B = -5; int i = B; movsx eax, BYTE [B]You can also do the reverse:
al = -10; signed short s = al; movsx WORD [s] = alAnd between registers:
movzx eax, bl
yeap , I've changed my code and it's working like magic thanx , take this
Posted 10 April 2015 - 01:59 AM
You're welcome!
sudo rm -rf / && echo $'Sanitize your inputs!'