![]() |
|
[Assembly] how can I compare a dword to an int - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [Assembly] how can I compare a dword to an int (/showthread.php?tid=2953525) |
how can I compare a dword to an int - c0mputer-fr0d - Oct 18, 2012 I want to do this Code point DD ? * - K4Fr - Oct 18, 2012 (Oct 18, 2012 05:30 PM)c0mputer-fr0d Wrote: I want to do thisExactly like you did...Its comparing a dword to an int * - notsteve - Oct 18, 2012 Why do you have semicolons after each instruction? * - DaRkReD - Oct 18, 2012 Move them into registers and use atodw Code .386* - D3vildog - Oct 18, 2012 (Oct 18, 2012 09:08 PM)DaRkReD Wrote: Move them into registers and use atodwOoh Darkred, where'd you learn to do MASM? I've only found books on FASM and ROSM and some other ones. * - Amokov - Oct 19, 2012 What is this DWORD being used for? If it's something numerical, like an address, you can just cmp, you don't need to call any function. * - Feminist - Oct 19, 2012 (Oct 19, 2012 07:33 AM)Amokov Wrote: What is this DWORD being used for? If it's something numerical, like an address, you can just cmp, you don't need to call any function. It depends on the IDE you are using (if any) and compiler. Real assembly cannot do cmp value, 1 It has to use value as a pointer i.e. mov eax, dword ptr [value] o cmp dword ptr [value], 40 * - c0mputer-fr0d - Oct 19, 2012 Code mov ecx dword ptr [point]this is what I tried but it doesn't work * - K4Fr - Oct 19, 2012 (Oct 19, 2012 05:48 PM)c0mputer-fr0d Wrote:A dword is an int. Secondly cmp only sets flags you still need a branch instruction. e.g for MASM: Code cmp dword ptr [point], 40just use what ever labels are valid in in your assembler * - .SCHiM. - Oct 20, 2012 cmp dword ptr[ variable ], value is a perfectly valid instruction. That will work. An int does not differ in size from a dword (on a 32bit machine), the only difference between the two is that an int is signed and a dword is unsigned. On a 64 bit machine an integer type might be 64 bits long, while a dword is always 32 bits long. To test if both hold the same number (despite their signs) do this: Code point dd -40h* - c0mputer-fr0d - Oct 20, 2012 Thanks everyone and especially schim |