x86-64

Printing floating point numbers from x86-64 seems to require %rbp to be saved

你。 提交于 2019-12-01 14:09:23
When I write a simple assembly language program, linked with the C library, using gcc 4.6.1 on Ubuntu, and I try to print an integer, it works fine: .global main .text main: mov $format, %rdi mov $5, %rsi mov $0, %rax call printf ret format: .asciz "%10d\n" This prints 5, as expected. But now if I make a small change, and try to print a floating point value: .global main .text main: mov $format, %rdi movsd x, %xmm0 mov $1, %rax call printf ret format: .asciz "%10.4f\n" x: .double 15.5 This program seg faults without printing anything . Just a sad segfault. But I can fix this by pushing and

Why are some Haswell AVX latencies advertised by Intel as 3x slower than Sandy Bridge?

随声附和 提交于 2019-12-01 14:08:50
问题 In the Intel intrinsics webapp, several operations seem to have worsened from Sandy Bridge to Haswell. For example, many insert operations like _mm256_insertf128_si256 show a cost table like the following: Performance Architecture Latency Throughput Haswell 3 - Ivy Bridge 1 - Sandy Bridge 1 - I found this difference puzzling. Is this difference because there are new instructions that replace these ones or something that compensates for it (which ones)? Does anyone know if Skylake changes this

Why does Apple use R8l for the byte registers instead of R8b?

跟風遠走 提交于 2019-12-01 13:07:13
I saw this in Making Code 64-Bit Clean topic ╔═════════════════════╤══════════════════════════════════════════════════════╗ ║ Register name │ Description ║ ╠═════════════════════╪══════════════════════════════════════════════════════╣ ║ R8 │ A 64-bit register. ║ ╟─────────────────────┼──────────────────────────────────────────────────────╢ ║ R8d │ A 32-bit register containing the bottom half of R8. ║ ╟─────────────────────┼──────────────────────────────────────────────────────╢ ║ R8w │ A 16-bit register containing the bottom half of R8d. ║ ╟─────────────────────┼───────────────────────────────

movq and 64 bit numbers

孤者浪人 提交于 2019-12-01 13:04:21
问题 When I write to a register, everything is fine, movq $0xffffffffffffffff, %rax But I get Error: operand size mismatch when I write to a memory location, movq $0xffffffffffffffff, -8(%rbp) Why is that? I see in compiled C code that in asm these numbers are split in two and two movl instructions show up. Maybe you can tell me where the mowq and other instructions are documented. 回答1: Why is that? Because MOV r64, imm64 is a valid x86 instruction, but MOV r/m64, imm64 is not (there's no encoding

run 32 bit assembly on 64 bit processor with mac os x

夙愿已清 提交于 2019-12-01 12:20:26
问题 I have a problem with running 32 bit assembly on my 64 bit mac running os x 10.9.5. I also have NASM 2.11.08 installed. I am currently reading Assembly Language Step by Step by Jeff Duntemann. In the book he specifies instructions for 32 bit assembly on a linux operating system. How can I run this program on my 64 bit mac os x computer. ; eatsyscall.asm SECTION .data ; Section containing initialised data EatMsg: db "Eat at Joes!",10 EatLen: equ $-EatMsg SECTION .bss ; Section containing

run 32 bit assembly on 64 bit processor with mac os x

元气小坏坏 提交于 2019-12-01 12:13:40
I have a problem with running 32 bit assembly on my 64 bit mac running os x 10.9.5. I also have NASM 2.11.08 installed. I am currently reading Assembly Language Step by Step by Jeff Duntemann. In the book he specifies instructions for 32 bit assembly on a linux operating system. How can I run this program on my 64 bit mac os x computer. ; eatsyscall.asm SECTION .data ; Section containing initialised data EatMsg: db "Eat at Joes!",10 EatLen: equ $-EatMsg SECTION .bss ; Section containing uninitialized data SECTION .text ; Section containing code global _start ; Linker needs this to find the

Error moving a constant byte value into %ebx

雨燕双飞 提交于 2019-12-01 11:11:29
I'm working through Computer Systems, A Programmer's Perspective (3rd edition), and Practice Problem 3.3 contains the following line: movb $0xF, (%ebx) I'm supposed to find out what's wrong with this line of x86-64 assembly, and the answer key states: "Cannot use %ebx as address register", which doesn't make sense to me. My understanding is that this line intends to copy 0xF to a location in main memory, however %ebx is a 32-bit register, memory addresses are 64 bits wide on 64-bit machines, and so %ebx cannot hold a memory address, therefore it cannot be dereferenced (dereferencing is what

Linux's security measures against executing shellcode

点点圈 提交于 2019-12-01 11:07:10
I'm learning the basics of computer security and I'm trying to execute some shellcode I've written. I followed the steps given here http://dl.packetstormsecurity.net/papers/shellcode/own-shellcode.pdf http://webcache.googleusercontent.com/search?q=cache:O3uJcNhsksAJ:dl.packetstormsecurity.net/papers/shellcode/own-shellcode.pdf+own+shellcode&cd=1&hl=nl&ct=clnk&gl=nl $ cat pause.s xor %eax,%eax mov $29,%al int $0x80 $ as -o pause.o pause.s $ ld -o pause pause.o ld: warning: cannot find entry symbol _start; defaulting to <<some address here>> $ ./pause ^C $ objdump -d ./pause pause: file format

Position Independent Code pointing to wrong address

左心房为你撑大大i 提交于 2019-12-01 10:59:03
I have a small example program written in NASM(2.11.08) targeting the macho64 architecture. I'm running OSX 10.10.3: bits 64 section .data msg1 db 'Message One', 10, 0 msg1len equ $-msg1 msg2 db 'Message Two', 10, 0 msg2len equ $-msg2 section .text global _main extern _printf _main: sub rsp, 8 ; align lea rdi, [rel msg1] xor rax, rax call _printf lea rdi, [rel msg2] xor rax, rax call _printf add rsp, 8 ret I'm compiling and linking using the following command line: /usr/local/bin/nasm -f macho64 test2.s ld -macosx_version_min 10.10.0 -lSystem -o test2 test2.o When I do an object dump on the

Dump the contents of TLB buffer of x86 CPU

喜欢而已 提交于 2019-12-01 10:33:09
Is it possible to get list of translations (from virtual pages into physical pages) from TLB (Translation lookaside buffer, this is a special cache in the CPU). I mean modern x86 or x86_64; and I want to do it in programmatic way, not by using JTAG and shifting all TLB entries out. The linux kernel has no such dumper, there is page from linux kernel about cache and tlb: https://www.kernel.org/doc/Documentation/cachetlb.txt "Cache and TLB Flushing Under Linux." David S. Miller There was an such TLB dump in 80386DX (and 80486, and possibly in "Embedded Pentium" 100-166 MHz / " Embedded Pentium