x86-64

What's 'new' in a 'new' processor when viewed from programmer's point

只愿长相守 提交于 2021-01-28 09:27:34
问题 I have recently been interested in understanding low level computing. I understand that today's widely used computers follow x86/x86-64 architecture. To my understanding, architecture, more specifically Instruction Set Architecture (ISA) is the set of instructions that the programmer is able to issue to the CPU. The first question, Is the ISA keeps evolving or remains the same? I think that it keeps evolving (meaning new instructions keeps getting added/previous instructions modified?) but

In this x86-64 instruction encoding documentation, what's the use of having 8, 16, 32, 64 bit GPRs? [duplicate]

放肆的年华 提交于 2021-01-28 07:37:10
问题 This question already has answers here : The advantages of using 32bit registers/instructions in x86-64 (2 answers) Intel X86 Assembly: How to tell many bits wide is an argument? (1 answer) x86 find out operand size of instruction given only the hex machine code? (2 answers) Why is default operand size 32 bits in 64 mode? (1 answer) 64 bit assembly, when to use smaller size registers (5 answers) Closed 3 months ago . I'm learning (slowly and painfully) about x86-64 instructions, and found

Writing a putchar in Assembly for x86_64 with 64 bit Linux?

旧城冷巷雨未停 提交于 2021-01-28 06:10:27
问题 I am trying to use the write syscall in order to reproduce the putchar function behavior which prints a single character. My code is as follows, asm_putchar: push rbp mov rbp, rsp mov r8, rdi call: mov rax, 1 mov rdi, 1 mov rsi, r8 mov rdx, 1 syscall return: mov rsp, rbp pop rbp ret 回答1: From man 2 write , you can see the signature of write is, ssize_t write(int fd, const void *buf, size_t count); It takes a pointer ( const void *buf ) to a buffer in memory. You can't pass it a char by value,

Can we use non-temporal mov instructions on heap memory?

天涯浪子 提交于 2021-01-28 05:08:27
问题 In Agner Fog's "Optimizing subroutines in assembly language - section 11.8 Cache control instructions," he says: "Memory writes are more expensive than reads when cache misses occur in a write-back cache. A whole cache line has to be read from memory, modified, and written back in case of a cache miss. This can be avoided by using the non-temporal write instructions MOVNTI, MOVNTQ, MOVNTDQ, MOVNTPD, MOVNTPS . These instructions should be used when writing to a memory location that is unlikely

x86 explanation, number of function arguments and local variables

*爱你&永不变心* 提交于 2021-01-28 04:15:11
问题 The C ABI for the x86-64 system is as follows: Registers rdi, rsi, rdx, rcx, r8, r9 are used to pass arguments in that order. The stack is used for the 7th argument onward. The return value uses the rax register. The rsp register contains the stack pointer. How many function arguments are defined in the blow function bloop ? I think there is only one function argument, rdi . is this correct? How many local variables (not arguments) are declared in the below function bloop ? I think there is

How would you explain this disassembly listing?

…衆ロ難τιáo~ 提交于 2021-01-28 04:13:57
问题 I have a simple function in C language, in separate file string.c: void var_init(){ char *hello = "Hello"; } compiled with: gcc -ffreestanding -c string.c -o string.o And then I use command objdump -d string.o to see disassemble listing. What I got is: string.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <var_init>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 8d 05 00 00 00 00 lea 0x0(%rip),%rax # b <var_init+0xb> b: 48 89 45 f8 mov %rax,-0x8(%rbp) f: 90 nop

Where are the OSX (XNU) syscalls actually documented?

ぃ、小莉子 提交于 2021-01-28 02:06:37
问题 I'm looking through the syscalls.master file here but it isn't at all documented. Does documentation for the syscalls exist? If not, why not? By documentation I mean an actual explanation of what each syscall does and the meanings of the arguments it takes. 回答1: Apple's position is that the system libraries are the API and stable ABI, syscalls are not. They discourage their direct use, as they can change from release to release of the OS. So, the best documentation you'll see is the man pages

The most correct way to refer to 32-bit and 64-bit versions of programs

青春壹個敷衍的年華 提交于 2021-01-27 20:32:23
问题 This question is about terminology for 32-bit vs. 64-bit x86. If I have 2 directories with source code of the same program - one for 32-bit Windows and another for 64-bit Windows, what will be the more correct names for these folders: x86-64 and x64 ? or IA-32 and x64 ? I already have read some web resources, but can't understand. Just for the record: https://superuser.com/questions/179919/x86-vs-x64-why-is-32-bit-called-x86 Difference between x86, x32, and x64 architectures? https://en

Can I get a thread's stack address from pthread_self()

纵饮孤独 提交于 2021-01-27 20:23:45
问题 I want to get the stack address of a thread through some function to which we can pass pthread_self() . Is it possible? The reason I am doing this is because I want to write my own assigned thread identifier for a thread somewhere in its stack. I can write near the end of the stack (end of the stack memory and not the current stack address. We can ofcourse expect the application to not get to the bottom of the stack and therefore use space from there). In other words, I want to use the thread

What does 'callq *(%rax)' mean?

混江龙づ霸主 提交于 2021-01-27 18:53:56
问题 I'm in a gdb session to analyze a postmortem crash. I'm looking at disassemble output for a function and I see this: => 0x00007f8d354aed52 <+50>: callq *(%rax) The => indicates that this was the instruction called at the time of the crash. So I got a seg fault calling the function at *(%rax) . I'm pretty new to assembly. I see that parens around a register mean to deference (get the value at) that address. Thus (%rax) means to get the value of the pointer currently stored in %rax . What does