x86-64

Is CMOVcc considered a branching instruction?

笑着哭i 提交于 2020-08-20 07:27:40
问题 I have this memchr code that I'm trying to make non-branching: .globl memchr memchr: mov %rdx, %rcx mov %sil, %al cld repne scasb lea -1(%rdi), %rax test %rcx, %rcx cmove %rcx, %rax ret I'm unsure whether or not cmove is a branching instruction. Is it? If so, how do I rearrange my code so it doesn't branch? 回答1: No, it's not a branch, that's the whole point of cmovcc . It's an ALU select that has a data dependency on both inputs, not a control dependency . (With a memory source, it

Can constant non-invariant tsc change frequency across cpu states?

不问归期 提交于 2020-08-20 03:45:01
问题 I used to benchmark Linux System Calls with rdtsc to get the counter difference before and after the system call. I interpreted the result as wall clock timer since TSC increments at constant rate and does not stop when entering halt state. The Invariant TSC concept is described as The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. Can a constant non-invariant tsc change frequency when changing state from C0 (operating) to C1 (halted)? My current view is that it

Can constant non-invariant tsc change frequency across cpu states?

不问归期 提交于 2020-08-20 03:44:31
问题 I used to benchmark Linux System Calls with rdtsc to get the counter difference before and after the system call. I interpreted the result as wall clock timer since TSC increments at constant rate and does not stop when entering halt state. The Invariant TSC concept is described as The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. Can a constant non-invariant tsc change frequency when changing state from C0 (operating) to C1 (halted)? My current view is that it

what does “mov offset(%rip), %rax” do?

冷暖自知 提交于 2020-08-18 06:51:40
问题 Does rax get offset plus the address of this instruction, or the next? From a microcode point of view it might be easier if the answer was the next instruction. 回答1: The next. That's a general rule on x86 (see also branches). In Intel's manual volume 2 section 2.2.1.6 RIP-Relative Addressing: A new addressing form, RIP-relative (relative instruction-pointer) addressing, is implemented in 64-bit mode. An effective address is formed by adding displacement to the 64-bit RIP of the next

Reading a single-key input on Linux (without waiting for return) using x86_64 sys_call

时光毁灭记忆、已成空白 提交于 2020-08-15 12:54:17
问题 I want to make linux just take 1 keystroke from keyboard using sys_read, but sys_read just wait until i pressed enter. How to read 1 keystroke ? this is my code: Mov EAX,3 Mov EBX,0 Mov ECX,Nada Mov EDX,1 Int 80h Cmp ECX,49 Je Do_C Jmp Error I already tried using BIOS interrupt but it's failed (Segmentation fault), I want capture number 1 to 8 input from keyboard. Thanks for the advance Sorry for bad english 回答1: Syscalls in 64-bit linux The tables from man syscall provide a good overview

Reading a single-key input on Linux (without waiting for return) using x86_64 sys_call

。_饼干妹妹 提交于 2020-08-15 12:53:55
问题 I want to make linux just take 1 keystroke from keyboard using sys_read, but sys_read just wait until i pressed enter. How to read 1 keystroke ? this is my code: Mov EAX,3 Mov EBX,0 Mov ECX,Nada Mov EDX,1 Int 80h Cmp ECX,49 Je Do_C Jmp Error I already tried using BIOS interrupt but it's failed (Segmentation fault), I want capture number 1 to 8 input from keyboard. Thanks for the advance Sorry for bad english 回答1: Syscalls in 64-bit linux The tables from man syscall provide a good overview

Making a system call in GAS and using variables in .data section and accessing them for a system call inside another sub-routine

筅森魡賤 提交于 2020-08-10 20:47:27
问题 Here is the code example that I have written using GAS syntax for 64 bit intel assembly. When the code is run the expectation is to print out the string: Inside the _print subroutine. #This example is a an example to call a subroutine .global _start .section .text _start: call _print _exit: #exit call mov $60, %rax xor %rdi, %rdi syscall _print: #set up the stack frame push %rbp mov %rsp, %rbp # write syscall's parameter set up mov std_out_fd, %rdi mov $message, %rsi movq message_size, %rdx

Making a system call in GAS and using variables in .data section and accessing them for a system call inside another sub-routine

霸气de小男生 提交于 2020-08-10 20:43:26
问题 Here is the code example that I have written using GAS syntax for 64 bit intel assembly. When the code is run the expectation is to print out the string: Inside the _print subroutine. #This example is a an example to call a subroutine .global _start .section .text _start: call _print _exit: #exit call mov $60, %rax xor %rdi, %rdi syscall _print: #set up the stack frame push %rbp mov %rsp, %rbp # write syscall's parameter set up mov std_out_fd, %rdi mov $message, %rsi movq message_size, %rdx

source not found (initsect.cpp)

喜欢而已 提交于 2020-08-10 20:13:08
问题 I am trying to learn Assembly(MASM x64), and I am currently learning conditional jumps. So I wrote such a code .data .code main proc mov rax, 1 begin: cmp eax, 10 add rax, 1 jl begin main endp end Now I started a debugging process to see that it works(as there is no other way to check if something works) and at the line jl begin the debugger started to drag me the whole way through some files called exe_common.inl, file_mode.cpp, back to exe_common.inl, matherr.cpp, again back to exe_common

What cause segment fault after function call in assembly x64 [duplicate]

主宰稳场 提交于 2020-08-09 17:52:25
问题 This question already has answers here : Return from jump to main (1 answer) Nasm segmentation fault on RET in _start (1 answer) call subroutines conditionally in assembly (3 answers) How does $ work in NASM, exactly? (1 answer) Difference between JUMP and CALL (5 answers) Closed yesterday . My OS: Linux debian 4.19.0-9-amd64 #1 SMP Debian x86_64 GNU/Linux Compiler: NASM version 2.14 I try play with conditional jumps, function calling and comparing expressions. I wrote something simple, and