x86-64

Microarchitectural zeroing of a register via the register renamer: performance versus a mov?

非 Y 不嫁゛ 提交于 2020-01-12 03:24:05
问题 I read on a blog post that recent X86 microarchitectures are also able to handle common register zeroing idioms (such as xor-ing a register with itself) in the register renamer; in the words of the author: "the register renamer also knows how to execute these instructions – it can zero the registers itself." Does anybody know how this works in practice? I know that some ISAs, like MIPS, contain an architectural register that is always set to zero in hardware; does this mean that internally,

Compilers: Understanding assembly code generated from small programs

不羁的心 提交于 2020-01-12 01:46:09
问题 I'm self-studying how compilers works. I'm learning by reading the disassembly of GCC generated code from small 64-bit Linux programs. I wrote this C program: #include <stdio.h> int main() { for(int i=0;i<10;i++){ int k=0; } } After using objdump I get: 00000000004004d6 <main>: 4004d6: 55 push rbp 4004d7: 48 89 e5 mov rbp,rsp 4004da: c7 45 f8 00 00 00 00 mov DWORD PTR [rbp-0x8],0x0 4004e1: eb 0b jmp 4004ee <main+0x18> 4004e3: c7 45 fc 00 00 00 00 mov DWORD PTR [rbp-0x4],0x0 4004ea: 83 45 f8

Python安装

淺唱寂寞╮ 提交于 2020-01-11 14:31:48
1,先去Python官网(https://www.python.org/)上下载你自己想要的版本 python官网有几个下载文件,有什么区别? Python 3.6.0a1 - 2016-05-17 Download Windows x86 web-based installer Download Windows x86 executable installer Download Windows x86 embeddable zip file Download Windows x86-64 web-based installer Download Windows x86-64 executable installer Download Windows x86-64 embeddable zip file x86是32位,x86-64是64位。 可以通过下面3种途径获取python: web-based installer 是需要通过联网完成安装的 executable installer 是可执行文件(*.exe)方式安装 embeddable zip file 嵌入式版本,可以集成到其它应用中 (python下载时也可以下载zip的版本(Windows x86-64 embeddable zip file),但是下载后有时发现会出现很多dll文件丢失情况,还需要去重新修复这些问题

How is Stack memory allocated when using 'push' or 'sub' x86 instructions?

廉价感情. 提交于 2020-01-11 11:09:49
问题 I have been browsing for a while and I am trying to understand how memory is allocated to the stack when doing for example: push rax Or moving the stack pointer to allocate space for local variables of a subroutine: sub rsp, X ;Move stack pointer down by X bytes What I understand is that the stack segment is anonymous in the virtual memory space,i.e., not file backed. What I also understand is that the kernel will not actually map an anonymous virtual memory segment to physical memory until

How is Stack memory allocated when using 'push' or 'sub' x86 instructions?

半城伤御伤魂 提交于 2020-01-11 11:08:10
问题 I have been browsing for a while and I am trying to understand how memory is allocated to the stack when doing for example: push rax Or moving the stack pointer to allocate space for local variables of a subroutine: sub rsp, X ;Move stack pointer down by X bytes What I understand is that the stack segment is anonymous in the virtual memory space,i.e., not file backed. What I also understand is that the kernel will not actually map an anonymous virtual memory segment to physical memory until

What is the aligment requirements for sys_brk

一曲冷凌霜 提交于 2020-01-11 10:42:29
问题 I'm using sys_brk syscall to dynamically allocate memory in the heap. I noticed that when acquiring the current break location I usually get value similar to this: mov rax, 0x0C mov rdi, 0x00 syscall results in rax 0x401000 The value usually 512 bytes aligned. So I would like to ask is there some alignment requirements on the break value? Or we can misalign it the way we want? 回答1: The kernel does track the break with byte granularity. But don't use it directly for small allocations if you

Why segmentation cannot be completely disable?

走远了吗. 提交于 2020-01-11 05:45:07
问题 According to AMD manual segmentation can not be disabled. My question is why, why it's impossible? Another question, it says that 64-bit disables it, what does that mean? Is segmentation completly disabled on 64-bit mode? AMD Manual: https://s7.postimg.cc/hk15o6swr/Capture.png 回答1: Introduction In 64-bit mode, whenever a non-null segment selector is loaded into any of the segment registers, the processor automatically loads the corresponding segment descriptor in the hidden part of the

What is the compatible subset of Intel's and AMD's x86-64 implementations?

假装没事ソ 提交于 2020-01-11 03:08:07
问题 While learning x86-64 assembly, I came across my first incompatibility between Intel 64 and AMD64 implementations of "x86-64": Why does syscall compile in NASM 32 bit output while popa does not compile in 64 bit? syscall is valid in the compatibility mode of one but not the other. Is there a better way of finding out those incompatibilities besides carefully reading both manuals and comparing them, which is error prone and duplicates my manual reading effort when aiming for portability? For

x86-64的调用约定,忽略__stdcall、__cdecl、__fastcall、_thiscal

青春壹個敷衍的年華 提交于 2020-01-10 14:07:14
在设计调用约定时,x64 体系结构利用机会清除了现有 Win32 调用约定(如 __stdcall、__cdecl、__fastcall、_thiscall 等)的混乱。在 Win64 中,只有一个本机调用约定 而 __cdecl 之类的修饰符都被编译器忽略。除此之外,减少调用约定行为还为可调试性带来了好处。 如下图: 源文件声明调用约定,可以是编译时出现如下警告 参考:: x86 x64下调用约定浅析 来源: CSDN 作者: DADA2ndTIAN 链接: https://blog.csdn.net/zsj1126/article/details/103835774

Calling convention on x64

依然范特西╮ 提交于 2020-01-10 02:57:18
问题 I saw in several places that Microsoft calling conventions for x64 platforms were narrowed down to just one: Caller cleans stack ( cdecl ), and parameters are passed in a combination of stack and registers (I am not going into the exact details here). I assume that if this is the calling convention of the OS, then probably all other compilers targeting Windows (e.g. mingw-w64) follow it, too. Is this calling convention true also on other major platforms ( x64 Linux, etc.)? Or does Linux still