x86-64

How do I interpet this x86_64 assembly opcode?

别来无恙 提交于 2020-12-02 05:55:26
问题 Looking at some assembly code for x86_64 on my Mac, I see the following instruction: 48 c7 c0 01 00 00 00 movq $0x1,%rax But nowhere can I find a reference that breaks down the opcode. It seems like 48c7 is a move instruction, c0 defines the %rax register, etc. So, where can I find a reference that tells me all that? I am aware of http://ref.x86asm.net/, but looking at 48 opcodes, I don't see anything that resembles a move. 回答1: Actually, mov is 0xc7 there; 0x48 is, in this case, a long mode

Can a C compiler generate an executable 64-bits where pointers are 32-bits?

谁说我不能喝 提交于 2020-12-01 09:02:18
问题 Most programs fits well on <4GB address space but needs to use new features just available on x64 architecture. Are there compilers/platforms where I can use x64 registers and specific instructions but preserving 32-bits pointers to save memory? Is it possible do that transparently on legacy code? What switch to do that? OR What changes on code is it necessary to get 64-bits features while keep 32-bits pointers? 回答1: A simple way to circumvent this is if you'd have only few types for your

Can a C compiler generate an executable 64-bits where pointers are 32-bits?

别说谁变了你拦得住时间么 提交于 2020-12-01 09:02:09
问题 Most programs fits well on <4GB address space but needs to use new features just available on x64 architecture. Are there compilers/platforms where I can use x64 registers and specific instructions but preserving 32-bits pointers to save memory? Is it possible do that transparently on legacy code? What switch to do that? OR What changes on code is it necessary to get 64-bits features while keep 32-bits pointers? 回答1: A simple way to circumvent this is if you'd have only few types for your

Function parameters transferred in registers on 64bit OS?

送分小仙女□ 提交于 2020-11-30 12:24:04
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

☆樱花仙子☆ 提交于 2020-11-30 12:21:14
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

梦想与她 提交于 2020-11-30 12:21:10
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

ⅰ亾dé卋堺 提交于 2020-11-30 12:19:21
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Loading a register from a “db 0” doesn't load a 0 into EAX?

旧街凉风 提交于 2020-11-29 10:56:38
问题 I've been bashing my head against the wall for over an hour and I can't understand why the below doesn't work. If I change b: db 1 to b: db 0 then it should print 10, otherwise it should print 0. Instead, the program always prints 10. I've been writing a project that writes assembly and this is one of the unit test that fails and I just don't get it. It has to be something simple. extern printf, exit section .bss section .data b: db 1 x: dd 5 y: dd 5 z: dd 0 int_pattern: db "%i", 10, 0 global

Loading a register from a “db 0” doesn't load a 0 into EAX?

无人久伴 提交于 2020-11-29 10:54:41
问题 I've been bashing my head against the wall for over an hour and I can't understand why the below doesn't work. If I change b: db 1 to b: db 0 then it should print 10, otherwise it should print 0. Instead, the program always prints 10. I've been writing a project that writes assembly and this is one of the unit test that fails and I just don't get it. It has to be something simple. extern printf, exit section .bss section .data b: db 1 x: dd 5 y: dd 5 z: dd 0 int_pattern: db "%i", 10, 0 global

Function that takes a char array and 2 indices; swapping the chars in those indices

邮差的信 提交于 2020-11-29 10:24:54
问题 This is my function prototype: char* swap(char* array, int index1, int index2); This is my assembly code: segment .text global swap swap: mov r14,[rdi+rsi] mov r15,[rdi+rdx] mov [rdi+rsi],r15 ;this line segfaults mov [rdi+rdx],r14 mov rax,rdi ret The lines mov [rdi+rsi],r15 and mov [rdi+rdx],r14 give me a segfault; I'm not sure where I'm going wrong The calling function: #include <stdio.h> #include <stdlib.h> extern char* swapLetters(char* str, int indexA, int indexB); int main() { char* st=