x86-64

how to set control register 0 (cr0) bits in x86-64 using gcc assembly on linux

北战南征 提交于 2020-12-29 04:00:08
问题 I am using the following code to set the cr0 bit to disable cache. When I compile this #include <stdio.h> int main() { __asm__("pushl %eax\n\t" "mov %cr0,%eax;\n\t" "orl $(1 << 30),%eax;\n\t" "mov %eax,%cr0;\n\t" "wbinvd\n\t" "popl %eax" ); return 0; } I am getting error saying that the operands are invalid for mov. Can anyone please point me to a good gcc x86-64 guide for doing these kinds of things? Also what exactly is wrong with the above code? 回答1: Ok, so finally I wrote the following

64-BIT mode do not support PUSH and POP instructions [duplicate]

主宰稳场 提交于 2020-12-27 17:54:43
问题 This question already has answers here : Push and Pop on AMD64 [duplicate] (1 answer) Does each PUSH instruction push a multiple of 8 bytes on x64? (2 answers) Closed 3 years ago . NASM returns an error like: "instruction not supported in 64-bit mode" and I couldn't figure out what to do. The subject instruction is pop ecx and push ecx instructions. What can I use instead of them or is there an other way to fix this issue? 回答1: The general idea is that you normally push and pop full registers

64-BIT mode do not support PUSH and POP instructions [duplicate]

半世苍凉 提交于 2020-12-27 17:45:59
问题 This question already has answers here : Push and Pop on AMD64 [duplicate] (1 answer) Does each PUSH instruction push a multiple of 8 bytes on x64? (2 answers) Closed 3 years ago . NASM returns an error like: "instruction not supported in 64-bit mode" and I couldn't figure out what to do. The subject instruction is pop ecx and push ecx instructions. What can I use instead of them or is there an other way to fix this issue? 回答1: The general idea is that you normally push and pop full registers

64-BIT mode do not support PUSH and POP instructions [duplicate]

人走茶凉 提交于 2020-12-27 17:41:50
问题 This question already has answers here : Push and Pop on AMD64 [duplicate] (1 answer) Does each PUSH instruction push a multiple of 8 bytes on x64? (2 answers) Closed 3 years ago . NASM returns an error like: "instruction not supported in 64-bit mode" and I couldn't figure out what to do. The subject instruction is pop ecx and push ecx instructions. What can I use instead of them or is there an other way to fix this issue? 回答1: The general idea is that you normally push and pop full registers

How does Rust's 128-bit integer `i128` work on a 64-bit system?

人盡茶涼 提交于 2020-12-27 07:54:05
问题 Rust has 128-bit integers, these are denoted with the data type i128 (and u128 for unsigned ints): let a: i128 = 170141183460469231731687303715884105727; How does Rust make these i128 values work on a 64-bit system; e.g. how does it do arithmetic on these? Since, as far as I know, the value cannot fit in one register of a x86-64 CPU, does the compiler somehow use 2 registers for one i128 value? Or are they instead using some kind of big integer struct to represent them? 回答1: All Rust's

x86-64 instruction set, AT&T syntax, confusion regarding lea and brackets

旧街凉风 提交于 2020-12-27 06:35:44
问题 I’ve been told that lea %rax, %rdx is invalid syntax as the source needs to be in brackets, i.e lea (%rax), %rdx I think I’ve clearly misunderstood both lea and the purpose of brackets. I thought that lea %rax, %rdx would move the memory address stored in %rax, to %rdx, but apparently this is what lea (%rax), %rdx does? What confuses me is that I thought brackets signify going to an address in memory, and taking the value at that address. So by using brackets lea would be moving a value from

Why does eax contain the number of vector parameters?

时光怂恿深爱的人放手 提交于 2020-12-23 11:15:52
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0

Why does eax contain the number of vector parameters?

假装没事ソ 提交于 2020-12-23 11:14:26
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0

Why does eax contain the number of vector parameters?

余生长醉 提交于 2020-12-23 11:13:42
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0

Why does eax contain the number of vector parameters?

a 夏天 提交于 2020-12-23 11:13:01
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0