Test eax eax meaning. Commented May 20, 2016 at 15:03.
Test eax eax meaning Is it a multithreaded program? Is the fault reproducible? "I know sub $12, %esp as same as three time on pop %eax and mov $0, %eax. will perform an AND operation and store the result in eax, whereas %eax refers to the lower 32 bits of the 64-bit %rax register. The question is related to assembly language programming specific to the usage of registers EDX, EAX, and ECX. We can optimize it even further by Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company now we have the situation that we have in the tutorial: you have the start adress of the structure (eax) and add a 4 to it to get to the ammo. The last sentence of your answer sounds like it's saying that ZF=0 when you compare two equal things, which is backwards. This last case is actually an invalid instruction because there is an operand-size mismatch. 18: However, under the hood (i. Names Submit the Meaning of This Surname for a Chance To Win a $60 Genealogy DNA Test. Registers can be used in your software directly with instructions such as mov, add or cmp. It's interesting to note that most other 16- and 32-bit processors do not offer any equivalent means of accessing just the upper or lower parts of a register. The jump will be done if ZF is deactivated. It's also valid to talk about the MSB of the value as in your question and WV's comment, as the position of the highest non-zero bit (assuming unsigned), but that's unrelated to what SF is set from. Project172. Commented May 20, 2016 at 16:15. On the other hand, 64-bit registers begin with r. 14: if Length(sa1) = 0 then 004050E2 A19C9B4000 mov eax,[$00409b9c] 004050E7 85C0 test eax,eax 004050E9 7405 jz $004050f0 004050EB 83E804 sub eax,$04 004050EE 8B00 mov eax,[eax] 004050F0 85C0 test eax,eax Project172. All binary numbers which not have set the 13th bit on memory address [eax], or all numbers present like b'xxxxxxxx xxxxxxxx xx0xxxxx xxxxxxxx', where x is 0 or 1, there is exactly 2^31 numbers. g. mov %rax, %eax # AT&T syntax (INVALID!) mov eax, rax ; Intel syntax (INVALID!) but not identical. Why bother with this at all? Or have I got the wrong end of the stick? TIA Paul. Description ¶ . CMP EAX,1. The XOR eax, 1 instruction just flips the lowest bit of EAX. Ltext0: . if the value in EAX is 0x81010102, the zero flag (ZF) does not get set (see above), so flow of control does not branch here. It loads eax with the contents of memory (a 32-bit dword in this case) that is currently pointed to by eax. Comparing a register with an immediate value likely takes (at least) an extra cycle to load and an extra byte (or 2, or 4) for the constant value '0'. The CPU gives no special meaning to register values 1, sign is a programmer eax, ebx, ecx and so on are actually registers, which can be seen as "hardware" variables, somewhat similar to higher level-language's variables. Only the flags are updated. ) Yes, there is a difference. Follow answered Nov 8, 2021 at 20:25. 1 that means EAX 4. Therefore, Code Select Expand. The PLT is the Procedure Linkage Table. xchg eax, ebx (1 byte, 3 uops on modern GCC made me some assembly code, and inside theres this statement: lea eax, [ebx+eax] (Intel Syntax) Just curious, what would the difference between that, and: In normal INTEL syntax this instruction moves a value from memory into EAX. And it's the same with CMP vs SUB - CMP doesn't save the result of the subtraction, it just sets the appropriate flags (e. dll that means it's using EAX Unified. loc 1 5 0 . It can compare 8-bit, 16-bit, 32-bit or 64-bit The acceptable operands for the mov instruction are shown here. EAX_VALUE:RETURN_REGISTER. EBP is used as the base It's only useful to push imm/pop reg for small values that fit in an 8-bit immediate. Improve this answer. MOV ecx, 32 BT DWORD PTR [eax], ecx will read four bytes from [eax+4] to [eax+7] and then test bit 0 of the value. mov [eax], [ebx] is attempting to move one memory location (dereferenced from the value in the ebx register) to the memory location referred to in eax. See Tips for golfing in x86/x64 machine code. Share. if %eax value is zero, OF, xor eax,eax is the best way to zero a register in x86 asm (for many reasons, not just code-size), but in C source code you should always write var = 0; and let the compiler use xor for you. DNA test information. sub $12, %esp does not change eax, neither by popping into it nor by moving a 0 into it. ORinx EAX with itself will set the Z status bit if EAX is zero, without any side-effects on the contents of EAX, and more quickly than a direct compare with zero. Jump instructions are of two types. Perhaps a graphical picture would help: Before: eax: 0x12345678 memory @ 0x12345678: 0xffffffff After: Instruction test works like and instruction, the only difference is that result is not stored back in to the destination operand. Before execution: EDX = 0. vikas william vikas william. So the answer is yes. In other words, movl $_start, %eax loads the address of the symbol _start into %eax; movl _start, %eax reads 4 bytes from memory at the address of _start into %eax. gets and puts are at a dynamic library, its addresses are not known when linking the program. If you look at the disassembly of both: The way i understand TEST is that it works a bit like the AND operator and it sets some flags. Modified 8 years, 6 months ago. 3. By incidence . Only the PF, SF and ZF flags are set. Of course, this is impossible. LCFI1: sub %esp, 40 . You can't use eax with the movb instruction. Basically, it describes how game designers and their QA teams used to test EAX during development. 0 and everything below is The instruction at 0xc0101647 is shown in red. MOV DWORD PTR DS:[ESI+0x2], EAX //nySetEDX into what EDX should of did. 5. text . – Enrico Borba. Testing a condition here refers only to the act of checking the flags, the actual jumping is described under Conditional jumps. " Well, no, that's not true. If the result of the AND operation is negative, the Sign Flag (SF) will be set to 1. The next set of instructions are jump instructions. The xor opposed to, say, "movb $1, %eax" This instruction is invalid. All other jump 0040A3D1 A9 00010181 TEST EAX,81010100. You know how this instruction works (base + index * scale) but your troubles come from the fact that you keep considering the first component to always be an address ("i. [BIT_NUMBER] = 1: means that If you execute CPUID instruction with EAX register = EAX_VALUE, you will get the result in Are there other examples of gcc generated function prologues where this would have more meaning (or eax would have a value other than 0)? . LCFI2: . If it were valid, the instruction would be copying the contents of the 64-bit rax register into the 32-bit eax register. We can observe the results of these two instructions by setting a breakpoint on them. For example: If you only take every 2nd bit into account that means a value like 0b10101010101010 would yield a 0 as your initial estimation (or 1 after the or ecx, mov eax, [esp+4] test eax, eax, jnz positive ret ; Return immediately when input is 0 positive: mov ecx, eax shl ecx or eax, ecx bsr ecx, eax ; Get highest bit for later adjustment xor edx I am trying to make a messagebox in pure assembly. globl test_function . Next, there's EAX Unified. In this case if EAX == 0, then (ZF=1) JNZ (JNE) INSTRUCTION (Conditional jump) JNZ label It jumps to label if it is not equal or zero. Reversing code, large fs:18h meaning. So, later, each time you load the program, the dynamic libraries it needs are also loaded. The leading e stands for extended and means that your register is 32 bits wide. LBB2: mov DWORD PTR [%ebp-12 However since cmp is longer if you look at the output binary, test or sometimes and, or is preferred. I know that "test" does a bitwise and of eax and eax, but in this case, the rest of the instruction (je) is not carried out. The flags SF, ZF, PF are modified while the result of the AND is discarded. I guess I don't really understand how the flags work. If a game ships with eax. It can be as a whole used to check if the value %eax is zero or positive or negative. See the x86 tag wiki for links to guides, including a register diagram that shows how the partial regs are overlayed onto the wider ones. user16450 user16450. Note that with just one operation you're able to do an add and a multiplication in just one step. any adress in memory address space") and the second component to always be an index ("i. Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand (source 2 operand) and sets the SF, ZF, and PF status flags according to the result. – Peter Cordes. This means the CPU backs up one byte to the inc eax instruction to execute it again. TEST does the same as AND, but the result of the AND operation is discarded; just the appropriate flags are set. Namely, it sets the zero flag if the difference is zero (operands are equal). An instruction commonly used before jnz is test eax,eax (or any other register); I guess you could call non-zero EAX a "condition 0x55555555545a <main+127> call 0x555555555090 <strcmp@plt> 0x55555555545f <main+132> test eax, eax ;<- this line 0x555555555461 <main+134> je 0x555555555479 <main+158> Or is it not about the result, but rather about the flags: SF, ZF, PF that will light up? (test is exactly the same as and except that it does not write the result back to Think about what 0(%eax) means. The previous instruction, shown in blue, set %eax to 0, however. The biggest advantage of using it this way is it doesn't modify the vale of %eax (after performing %eax & %eax, it just discards away the value) and sets the condition flags as follows. Follow asked Jun 18, 2016 at 17:58. The instruction mov eax, eax may be a no-operation code but that is not what you have here. This is because RIP always points to the next instruction to be executed. Does issuing a backtrace point to the same place too ? (In this case, %rip is likely wrong, and the crash is elsewhere – nos. "You know wrong. From the linked article: GAS instructions generally have the form: mnemonic source, How to Mitigate Risks Before Delivering a Alright so I have this line in my assembly MOV EAX, DWORD PTR DS:[ESI] where ESI is 00402050 (ascii, "123456789012") After this instruction: EAX = 34333231 What really happened here? You should also mention that DS:[ESI] notation means that that ESI holds an offset from address in DS (data segment register), so the instruction moves double disp(base,index,scale). Now, what does (%eax) mean? It means the value in eax. However, they are not entirely independent, so one should be careful. ; jz is commonly used to explicitly test for something being equal to zero whereas je is commonly found after a cmp instruction. You would instead use an 8-bit register, or write the full register with a value that has the value you want in the low byte(s) you care about. If eax is zero, set eax to zero. Note that the bytes from [eax+5] to [eax+7] do not participate in the bit test, but they must still be accessible, or you will take an access violation. Applying and with it to the register eax results in non-zero if and only if the highest bit of eax is set, that is, the number stored in TEST EAX,EAX does not place the result on the register, it only has effect on the state of the ZF. InMemOrder lodsd ; EAX = Second module xchg eax, esi ; EAX = ESI, ESI = EAX lodsd ; EAX = Learn the fascinating origin of the Eax surname; its meaning & distribution. The constant 80000000h corresponds to highest bit set in binary value of 1000 0000 0000 0000 0000 0000 0000 0000. Thus, upon entry into the function, the stack looks like this: ; __stdcall GetAdvise 715171f7 85c0 test eax,eax ; test bits of eax 715171f9 7c2c jl No_Advise (71517227) ; jump if less than zero I am a beginner and writing assembly program to print numbers from 1 to 9 using this code: section . For example, on my machine, if you set all bits of %rax to 1, and then perform xor %eax, %eax, you will find that ALL of %rax is set Been working on an assembly assignment, and for the most part I understand assembly pretty well. mySetEDX //Replace old EDX with what I wish it should be. The OF and CF flags are set to 0, while AF flag is undefined. There are 9 different opcodes for the TEST instruction depending on the type and size of the operands. If two operands are equal, their bitwise AND is zero when both are zero. In Intel manual, the general format is: CPUID. ; It jumps to the specified location if the Zero Flag (ZF) is set (1). . So AL=EAX and there are no partial-register penalties for reading EAX. dll base address:. If the result is 0, the ZF flag is set to 1, otherwise set to 0. so 'movl 8(%ebp), %eax' means set %eax with the address of the %ebp. The MOVZX instruction zero-extends the source to the destination. That can be used to give some space to local variables of a subroutine. You're loading from memory, as indicated by the [] "contents-of" characters. Commented May 20, 2016 at 15:03. So if you have a small integer in eax, you can just mov [mem], ax to store the low 16b. LEA sets EAX = the address. loc 1 1 0 push %ebp . Here are the steps I have taken so far: Find kernel32. Consequently, this was an attempt to dereference a NULL pointer. When you see test eax eax, you’re essentially using it to check the state of %eax without actually modifying it, since the bitwise AND of any number with itself results in the same number. 11 1 1 bronze badge. The e part of eax means extended. defeating the optimizer, especially if var is uninitialized). Before executing CMP EAX, 1, the following is the status of the EAX The eax register simply points to a storage location in memory, which on x86 computers is 32 bits. This means that eax is treated as a pointer, so the right operand is taken from the address pointed to by eax, and the result is It's really difficult to produce a xor eax,eax with a register in GCC without using a -O2 or superior optimization (and without using the binary operation itself). mov eax, 1 (5 bytes total, with 3 zero bytes in the imm32 so it's also a problem for shellcode). would point to test eax, eax. MOV sets In the x86 assembly language, the TEST instruction performs a bitwise AND on two operands. The logic is like this: test eax, eax; setnz eax means, if eax is not zero (aka 1) set eax to 1. 9 Condition Code Exercises –addl $0x7fffffff,%rdx –andb %al, %bl –addb $0xff, %al –cmpw $0x7000, %cx 0000 0000 0000 0001 rax 0000 0000 0000 0000 rbx Processor Registers 0000 0000 0000 8801 rcx 0000 0000 0000 0002 rdx That's just weird syntax for [X + eax]. 2. Description. Shorter encoding, and no false dependency on the previous value of the upper 16b. if the value in EAX is 0x60E0FEFC, the zero flag (ZF) is set to 1 (see above). The array is situated in memory at DS:ESI. MOV EAX,DWORD PTR DS:[4053E4] TEST EAX,EAX: This excerpt has both CMP and TEST instructions. The SF flag is set to the most significant bit of the result of the AND. The easiest way to get the opcode of assembly instruction is just to compile it and disassemble the result (for example using nasm and then objdump or simply this site) - this way you don't have to remember anything about the opcodes which are sometimes weird. test rax, rax jz is_zero You can get the assembly output from a compiler and check or view it in an online tool like gcc godbolt MOV EAX,DWORD PTR DS:[4053E4] XOR EBX,EBX. TEST sets the zero flag, ZF, when the result of the AND operation is zero. That's where i got confused, and oddly, I knew that. EAX is the full 32-bit value; AX is the lower 16-bits; AL is the lower 8 bits; AH is the bits 8 through 15 (zero-based), the top half of AX; So AX is composed of AH:AL halves, and is itself the low half of EAX. That's because xor eax,eax is equivalent to mov eax,0, but for some reason, GCC uses the xor method for optimization (I don't know which is faster). It's also useful when you just want to see whether a register is zero: test eax, eax is more efficient (a shorter instruction) than cmp eax, 0. What makes this instruction valuable is TEST is like AND, but the results of the operation are not saved. The instruction JMP is an unconditional jump as it does not rely on any conditions to be met. I would This instruction is not meant to check only if the value of %eax is zero. Ask Question Asked 8 years, 6 months ago. aldeid. AX is just the low half of EAX. So as long as x == x + 0, no, there is obviously no difference. TEST EAX,EAX test eax, eax js 0xABCD0000 Here, the test instruction performs a bitwise AND operation between the content of the EAX register like before. com/w/index. Either at that time or later, the first time you call a function from a dynamic library, its address is resolved, and put into the GOT (Global Offset TEST EAX, EAX; TEST AL, AL; Assume a previous "MOVZX EAX, BYTE PTR [ESP+4]" instruction loaded a byte parameter with zero-extension to the remainder of EAX, preventing the combine-value penalty that I already know about. Only posting a comment because XOR EAX, EAX The TEST Instruction. LFB3: . xor ecx, ecx mov eax, fs:[ecx + 0x30] ; EAX = PEB mov eax, [eax + 0xc] ; EAX = PEB->Ldr mov esi, [eax + 0x14] ; ESI = PEB->Ldr. Can someone explain? In 32bit or 64bit mode, it's faster to zero ax with xor eax, eax. The outer loop generates the array and writes it to the screen and in to the array, The inner loop is then supposed to test if the value exists in the array. Commented Jun 13, 2017 at 18:50 MOV test. so that means ZF = 1 (and not 0). For instance `test eax,eax` will set the Z flag if eax is zero so you can use `jz` to jump if zero or `jnz` to jump if not zero, and the sign bit so you can use `js` to jump if It means: Calculate Address = (ESI + ECX * 4). For example, if it's version 4. EAX = 0x7 meaning EAX has What is instruction after test eax,eax? – m0skit0. Like push 1 (2 bytes) / pop eax (1 byte) for 3 bytes total, vs. In this case, it zero-extends the BYTE loaded from memory at [rbp-528+rax] to the DWORD destination register, EAX. "). type test_function, @function test_function: . I think MASM allows this, and NASM might not. bss num resb 1 The semantic meaning of jne is to jump if the two things you compared were not equal. As a And %eax is the value of that address. To the CPU that executes this instruction the contents of CMP EAX,EAX ;set the zero flag (no change to eax) SUB EAX,EAX ;set the zero flag (making eax=0 too) CMP EAX,EDX ;when they must be different clear the zero flag OR EAX,EAX ;when eax cannot be zero clear the zero flag TEST EAX,EAX ;same effect as OR EAX,EAX When used with TEST, the zero flag will be set if the bit being tested is zero. It means that there is an offset of 0 from the value in eax. php?title=X86-assembly/Instructions/test&oldid=30841" This means that parameters are pushed right to left (in this case, there are none), the "this" pointer is pushed, and then the function is called. In 16b mode on a modern CPU, probably xor eax,eax is still better, because of the many special benefits of using a In your particular case: edx = 3, eax = 0x100, temporary_address_in_CPU_during_mov = eax + edx * 4 = 0x100 + 3*4 = 0x10C. After that, the js instruction will get executed and the execution flow will jump to 0xABCD0000 if the SF is 1 or the I am trying to understand some assembly. By design, strcpy can return either -1,0 or 1 in EAX with 0 indicating both strings match. So, if we need to check Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand (source 2 operand) and sets the SF, ZF, and PF status flags according to the result. As far as the CPU is concerned, or eax, -1 depends on the previous value of the eax register, which lengthens the code's dependency chain and will significantly decrease performance compared to if you had used a mov. e. The PF flag is set to the bitwise XNOR of the least significant byte of the result, 1 if the Don't allow Tom's prose to pursuade you one way or the other. –Often used with the src1 = src2 (i. So, if we need to check whether a number in a register is even or odd, we can also do this using the TEST instruction without changing the original number. My problem is, that I would like to process a number in the EDX-EAX and write it out digit per digit, so in this case I would have to divide the number in EDX-EAX by "OR also has about twice the throughput of the MOV instruction as long as you don't mind messing up the flags. The assembly as follows, I am interested in the testl line: 000319df 8b4508 movl 0x08(%ebp), %eax 000319e2 8b4004 movl 0x04(%eax), % Retrieved from "https://www. By incidence By frequency By rank This means that near relative calls, as given above, are direct calls and near absolute calls are indirect! It’s a simple way to remember them and identify them, and also how to pull their targets out. The TEST instruction works same as the AND operation, but unlike AND instruction, it does not change the first operand. So, if %rax is initially 0, and you execute the instruction movl $5, %eax, then %rax will also take on the value 5. Current processors may be faster in doing it instead an add followed by a mul, but it is not clear given No, that's not quite right. So if you want to generate an assembly code like test eax, eax ;and eax, eax ;ZF = 1 iff EAX is zero test eax, 03h ;and eax, 03h ;ZF = 1 if both bit[1:0] are clear ;ZF = 0 if at least one of bit[1:0] is set cmp eax, 241d ;sub eax, 241d ;ZF = 1 iff EAX is 241 ;CF = 1 iff EAX < 241 Signed and unsigned tests. myEDX, EAX //Stores old EDX into struct test. Unlock your family history in the largest database of last names. Note: If you find that I'm [ EAX = 0000002B ] test al,0x10 jne RUNAWAY jmp CONTINUE If i'm correct: al = 0x2B about the only time you see test generated is for checking whether or not a register is zero do not confuse test with compare. This just sounds like an identity function is eax is zero or one. 0. It implicitly uses the EAX register as parameter and returns the result in EAX, EBX, ECX, EDX. jmp short test_eax_eax test_eax_eax: test eax,eax ret ida; disassembly; windows; Share. – command test destination, source. ; Syntax jz location je location Examples test eax, eax ; test if eax=0 jz short loc_402B13 ; if condition is This means that . Jack Klein 2006-08 In AT&T syntax $ means to treat what follows as an immediate constant rather than a memory address. Also, swapping registers that way is insane vs. Improve this question. This address arithmetic can be used itself through lea instruction, when the CPU will do the address math, but instead of loading value from memory The name "AL" still refers to bits 0-7 of the first letter-named register, "AH" to bits 8-15, and "AX" to bits 0-15; the name "EAX" now refers to all 32 bits of the register. Or well at least well enough for this assignment. You can confirm this by looking at the value of %eax in the dump above (eax=00000000). The scale of 8 means that every element is 64 bit long and this instruction only reads the low dword. zero, carry). test al,al to me looks like it checks the same lower bits and will always get the same results. JE function. 11 1 1 However, in your example, (%eax) is a memory operand; that's what parentheses mean in AT&T syntax (like square-brackets in NASM syntax). There is no opcode for mov that takes a memory location as both the source and the destination, but there are opcodes for moving a memory location Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company The CDQE instruction sign-extends a DWORD (32-bit value) in the EAX register to a QWORD (64-bit value) in the RAX register. After executing the given instructions where the value in EAX is divided by ECX, EDX stays 0, EAX becomes 0x2 (as it stores the quotient), and ECX stays the same as there is no operation on it. Don't write var ^= var, because it has zero advantage and many possible disadvantages (e. The XOR EAX,EAX simply 0's out the EAX register, it executes faster than a MOV EAX,$0 and doesn't need to fetch immediate data of 0 to load into eax It's very obvious this is the "return 0" that MSVC is optimizing EAX is the register user18640236: You can say that bit #31 of the register is the MSB of the register and the fixed-width 32-bit integer it contains. The jz instruction is a conditional jump that follows a test. Eax Surname Distribution Map. anything of 0,1,2. test %eax, %eax) to check if a value is 0 or negative. This register -> memory location is automatically used by the multiplication and division operators and normally called the extended accumulator register. The elements are indexed through EBP. However, you want to patch 2 bytes test eax, eax jnz _testlabel: Using jump instructions to control applications at the x86 level. I say be pragmatic in your approach. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company I am attempting to test if the random value generated in eax is the same as any value in an array I have allocated. the zero flag (ZF) is set to 1 if the results of an arithmetic or logical In order to use a conditional jump a condition must be tested. So, AND eax, 20. Read the value into EAX from 32-bit value at that memory address. As far as I know, "test eax eax" checks is eax == 0; than it moves "01" into al; but what does "js" mean? Why bother checking it and jump if necessary? test eax, eax js 0xABCD0000 Here, the test instruction performs a bitwise AND operation between the content of the EAX register like before. CMP subtracts the operands and sets the flags. 83F800 cmp eax, 0 09C0 or eax, eax 85C0 test eax, eax The resulting code will be. with a debugger like Olly) you could see that the 5 are actually returned in edx, while eax holds a pointer to "test". But this mov statement is tripping me up. It attempts to write the value 0x2a to memory at the address contained in %eax. mov eax, 1 test eax, eax je label2 this seems somewhat odd. Check the version number of that file via right click > properties. If Instr_("Sometest", "test") Print eax Generally this means you can use EBX ESI and EDI in normal procedures as long as you preserve them. If your application, like say, oh, a boot sector requires precious bytes, then you will use a way to remove bytes, if your program requires readability for any number of reason, use the less confusing more direct approach that makes sense (though an assembly programer Calculating values with lea is a reminiscent where this operation was either faster (as it was calculated by the circuitry doing address calculation) or smaller in code size. Value in memory at address 0x10C is 0x11. It is useful for quick tests of a register to test it for being negative or zero. TEST AL, 01H JZ EVEN_NUMBER I want to thank Dr Emu a very powerful spell caster who help me to bring my husband back to me, few month ago i have a serious problem with my husband, to the extend that he left the house, and he started dating another woman and he stayed with the woman, i tried all i can to bring him back, but all my effort was useless until the day my friend came to my house and i told her If I have a 64 bit number in the EDX-EAX, and I divide it with a relatively small number, the quotient may become a number bigger than 32 bits. x86 Recall that test eax, eax followed by je means “jump if eax is zero”, and that the x86 instruction set is well documented; if you don’t know what an instruction does, look it up! The test instruction does a logical AND-operation between the operands but does not write the result back into a register. So at that point the div operator only sets the carry flag?. The result Values in registers are stored in two's-complement format, and the highest bit corresponds to the negative sign. 16: if sa2 = '' then 004050F2 833DA09B400000 cmp dword ptr [$00409ba0],$00 Project172. (The upper half of EAX isn't directly accessible as a 16-bit register; you can shift or rotate EAX if you want to get at it. LCFI0: mov %ebp, %esp . text global _start _start: mov ecx,10 mov eax, '1' l1: mov [num], eax mov eax, 4 mov ebx, 1 push ecx mov ecx, num mov edx, 1 int 0x80 mov eax, [num] sub eax, '0' inc eax add eax, '0' pop ecx loop l1 mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section . 004013E3. EAX is the register used by IA32 calling conventions to either return an interger value or a memory address to the calling routine. So, I'm confused how this is correct. Both of the or and test instructions sets the CPU zero flag if the eax register value is set to 0, it gives us the same result as the cmp eax,0 instruction but with 1 byte less size in output code. MOV EAX,DWORD PTR DS:[ESI+EBP*8] It is usually used to extract a value from an array. (ZF=0) The opcode you are interested in is a9 01 00 00 00 standing for test eax, 1. The primary/direct reason for using something like sub $12, %esp is to reserve some space on the stack. dpr. myEDX MOV EAX, test. In your example the test eax, eax will XOR EAX, EAX The TEST Instruction. Unconditional jumps and conditional jumps. fqpxkixjqffuxuocbwtzedxoofwvcbmniivsxkqhkcvknvrptesj