assembly

cmp je/jg how they work in assembly

十年热恋 提交于 2021-01-20 09:33:08
问题 I would like to understand how cmp and je/jg work in assembly. I saw few examples on google but I am still little bit confused. Below I have shown a part of assembly code that I am trying to convert to C language and the corresponding C code. Is it implemented in the right way or do I have a wrong understanding of how cmp works? cmp $0x3,%eax je A cmp $0x3,%eax jg B cmp $0x1,%eax je C int func(int x){ if(x == 3) goto A; if (x >3) goto B; if(x == 1) goto C; A: ...... B: ...... C: ...... 回答1:

cmp je/jg how they work in assembly

谁都会走 提交于 2021-01-20 09:32:47
问题 I would like to understand how cmp and je/jg work in assembly. I saw few examples on google but I am still little bit confused. Below I have shown a part of assembly code that I am trying to convert to C language and the corresponding C code. Is it implemented in the right way or do I have a wrong understanding of how cmp works? cmp $0x3,%eax je A cmp $0x3,%eax jg B cmp $0x1,%eax je C int func(int x){ if(x == 3) goto A; if (x >3) goto B; if(x == 1) goto C; A: ...... B: ...... C: ...... 回答1:

Restrict a routine to use a limited set of registers

倖福魔咒の 提交于 2021-01-20 09:32:47
问题 Using compiler option, is it possible to restrict a routine from using certain set of registers? For example: Restrict a routine to use only R0-R8; Purpose: If some compiler option available, then I could ensure certain routines (like Interrupt Service Routines) to use only limited register set, and thus do limited Context Save & Restore. 回答1: When this was last discussed, the consensus was that it is not possible on a function-by-function basis. There are ways to restrict register use

x64 assembly, ret register and variables

冷暖自知 提交于 2021-01-20 08:16:29
问题 I'm relatively new to x64 assembly and im using it in conjunction with VS2010. I'm struggling to get a handle on the return values from a proc and I can't really find quality documentation for beginners. .data MyByte db 10 .code GetValueFromASM proc mov rax, 28 mov rbx , 19 lea rax, MyByte mov rax, 10 mov eax, 11 mov ecx, 100 ret GetValueFromASM endp end The Ret instruction is printing out the value of eax in my c++ front end, is there some sort of default return register or can you specify

x64 assembly, ret register and variables

半腔热情 提交于 2021-01-20 08:16:19
问题 I'm relatively new to x64 assembly and im using it in conjunction with VS2010. I'm struggling to get a handle on the return values from a proc and I can't really find quality documentation for beginners. .data MyByte db 10 .code GetValueFromASM proc mov rax, 28 mov rbx , 19 lea rax, MyByte mov rax, 10 mov eax, 11 mov ecx, 100 ret GetValueFromASM endp end The Ret instruction is printing out the value of eax in my c++ front end, is there some sort of default return register or can you specify

Iterating through an array in NASM assembly code

女生的网名这么多〃 提交于 2021-01-20 07:30:14
问题 So I'm currently taking an assembly language class and we are trying to create and sort an array from input. I can get the sorting logic just fine, but I'm having a great deal of trouble trying to iterate through the array. For further clarification of what the following code does, we are supposed to read in integers from the command line. The number 0 delimits the end of user input, and then the sorting method is called. That works fine, it's the array iteration that is not working. Here is

Why do the addresses in my assembler dump differ from the addresses of registers?

隐身守侯 提交于 2021-01-20 06:58:30
问题 I have a very basic program that I compiled with gcc -m32 -g -o hello32.out hello.c When I run disassemble main in gdb I get the following output: 0x0000051d <+0>: lea ecx,[esp+0x4] 0x00000521 <+4>: and esp,0xfffffff0 0x00000524 <+7>: push DWORD PTR [ecx-0x4] 0x00000527 <+10>: push ebp 0x00000528 <+11>: mov ebp,esp 0x0000052a <+13>: push ebx 0x0000052b <+14>: push ecx 0x0000052c <+15>: sub esp,0x10 0x0000052f <+18>: call 0x420 <__x86.get_pc_thunk.bx> 0x00000534 <+23>: add ebx,0x1aa4

Does a Length-Changing Prefix (LCP) incur a stall on a simple x86_64 instruction?

核能气质少年 提交于 2021-01-20 04:49:33
问题 Consider a simple instruction like mov RCX, RDI # 48 89 f9 The 48 is the REX prefix for x86_64. It is not an LCP. But consider adding an LCP (for alignment purposes): .byte 0x67 mov RCX, RDI # 67 48 89 f9 67 is an address size prefix which in this case is for an instruction without addresses. This instruction also has no immediates, and it doesn't use the F7 opcode (False LCP stalls; F7 would be TEST, NOT, NEG, MUL, IMUL, DIV + IDIV). Assume that it doesn't cross a 16-byte boundary either.

Does a Length-Changing Prefix (LCP) incur a stall on a simple x86_64 instruction?

浪尽此生 提交于 2021-01-20 04:48:03
问题 Consider a simple instruction like mov RCX, RDI # 48 89 f9 The 48 is the REX prefix for x86_64. It is not an LCP. But consider adding an LCP (for alignment purposes): .byte 0x67 mov RCX, RDI # 67 48 89 f9 67 is an address size prefix which in this case is for an instruction without addresses. This instruction also has no immediates, and it doesn't use the F7 opcode (False LCP stalls; F7 would be TEST, NOT, NEG, MUL, IMUL, DIV + IDIV). Assume that it doesn't cross a 16-byte boundary either.

Does a Length-Changing Prefix (LCP) incur a stall on a simple x86_64 instruction?

落爺英雄遲暮 提交于 2021-01-20 04:47:11
问题 Consider a simple instruction like mov RCX, RDI # 48 89 f9 The 48 is the REX prefix for x86_64. It is not an LCP. But consider adding an LCP (for alignment purposes): .byte 0x67 mov RCX, RDI # 67 48 89 f9 67 is an address size prefix which in this case is for an instruction without addresses. This instruction also has no immediates, and it doesn't use the F7 opcode (False LCP stalls; F7 would be TEST, NOT, NEG, MUL, IMUL, DIV + IDIV). Assume that it doesn't cross a 16-byte boundary either.