x86-64

Printing a number in assembly NASM using printf

非 Y 不嫁゛ 提交于 2019-12-25 00:39:16
问题 I've been trying to get this to print 12345 for a while now. Can anyone provide a hint as to what I should do? It will print the three lines of text, then on the fourth line prints "age", which I'm guessing is a remnant in the stack from line 2. bits 64 global main extern printf section .text main: ; function setup push rbp mov rbp, rsp sub rsp, 32 ; lea rdi, [rel message] mov al, 0 call printf ;above code correctly prints message ;where the issue lies push rbp mov rbp, rsp ;sub rsp, 32 mov

Python ctypes how to read a byte from a character array passed to NASM

拟墨画扇 提交于 2019-12-24 20:43:47
问题 UPDATE: I solved this problem with the help of Mark Tolonen's answer below. Here is the solution (but I'm puzzled by one thing): I begin with the encoding string shown in Mark Tolonen's answer below (UTF-8): CA_f1 = (ctypes.c_char_p * len(f1))(*(name.encode() for name in f1)) With optimizations off, I always store rcx into a memory variable on entry. Later in the program when I need to use the pointer in rcx, I read it from memory. That works for a single pointer, but doesn't work for

Oracle12c Linux x86-64安装体验

烈酒焚心 提交于 2019-12-24 20:01:29
Oracle12c Linux x86-64安装体验 下载Oracle Database 12cRelease 1安装介质 官方的下载地址: 1: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html 2: https://edelivery.oracle.com/EPD/Download/get_form?egroup_aru_number=16496132 URL地址2需要先注册,然后才能登陆下载,注册登陆界面https://edelivery.oracle.com 地址1下载的文件为: linuxamd64_12c_database_1of2.zip linuxamd64_12c_database_2of2.zip 地址2下载的文件为: V38500-01_1of2.zip V38500-01_2of2.zip Oracle 12c 对系统内存的最低要求为1G,推荐2G或更大的内存, 开始安装oracle 1.添加一块新硬盘并格式化 [root@localhost ~]# cd /dev [root@localhost dev]# ls [root@localhost dev]# fdisk /dev/sdb [root@localhost dev]# mkfs

What is a valid pointer in gcc linux x86-64 C++?

余生长醉 提交于 2019-12-24 19:32:47
问题 I am programming C++ using gcc on an obscure system called linux x86-64. I was hoping that may be there are a few folks out there who have used this same, specific system (and might also be able to help me understand what is a valid pointer on this system). I do not care to access the location pointed to by the pointer, just want to calculate it via pointer arithmetic. According to section 3.9.2 of the standard: A valid value of an object pointer type represents either the address of a byte

Multicore in NASM Windows: lpParameter data are wrong on entry

无人久伴 提交于 2019-12-24 18:13:10
问题 I have code in NASM (64 bit) in Windows to run four simultaneous threads (each assigned to a separate core) on a four-core Windows x86-64 machine. The lpParameter is passed in r9 (the data variables for each thread to pass to the function). I am passing a pointer to an 8-element internal array (ThreadInfo) which contains variables to put into registers on entry to the function (variables are stored in registers for optimization purposes). All four threads call the same function. The problem

Inline assembly in C program on x86_64 linux

家住魔仙堡 提交于 2019-12-24 18:09:49
问题 I've built a short program written on C and inline assembly on my linux x86_64. It is supposed to write a string to stdout. I found it in an article on the internet: int write_call( int fd, const char * str, int len ){ long __res; __asm__ volatile ( "int $0x80": "=a" (__res):"0"(__NR_write),"b"((long)(fd)),"c"((long)(str)),"d"((long)(len)) ); return (int) __res; } void do_write( void ){ char * str = "Paragon output string.\n"; int len = strlen( str ), n; printf( "string for write length = %d

ruby postgreSQL on AMD64

折月煮酒 提交于 2019-12-24 16:17:42
问题 ---------------- EDIT ---------------- I've tried what @Duk said, and still nothing work. After trying a little more, i figured out that the problem isn't on DataMapper. In fact it's the postgreSQL adapter that fails on AMD64. I have binary distribution of PostgreSQL (the last one found on their site) and I got all the gems by doing a gem install... Someone can help me ? ---------------- ORIGINAL ---------------- Following the "Get Started" from DataMapper website, i ran across this example :

Actual long double precision does not agree with std::numeric_limits

情到浓时终转凉″ 提交于 2019-12-24 16:01:37
问题 Working on Mac OS X 10.6.2, Intel, with i686-apple-darwin10-g++-4.2.1, and compiling with the -arch x86_64 flag, I just noticed that while... std::numeric_limits<long double>::max_exponent10 = 4932 ...as is expected, when a long double is actually set to a value with exponent greater than 308, it becomes inf--ie in reality it only has 64bit precision instead of 80bit. Also, sizeof() is showing long doubles to be 16 bytes, which they should be. Finally, using <limits.h> gives the same results

How does RIP-relative addressing perform compared to mov reg, imm64?

偶尔善良 提交于 2019-12-24 14:28:03
问题 It is known fact that x86-64 instructions do not support 64-bit immediate values (except for mov). Hence, when migrating code from 32 to 64 bits, an instruction like this: cmp rax, addr32 cannot be replaced with the following: cmp rax, addr64 Under these circumstances, I'm considering two alternatives: (a) using a scratch register for loading the constant or (b) using rip-relative addressing. The two approaches look like this: mov r11, addr64 ; scratch register cmp rax, r11 ptr64: dq addr64 .

Which exception can be generated when subtracting ESP or RSP register? (stack growing)

☆樱花仙子☆ 提交于 2019-12-24 14:03:20
问题 I'm trying to understand how exactly memory pages for stack is allocated/assigned. I wrote the following proof-of-concept C-code which obviously causes segmentation fault (on x86_64 Linux): #include <string.h> int main() { char a; memset( (&a - 4444444), 0, 3333333 ); return 0; } The following fragment of assembly code (AT&T syntax) is generated by gcc from above C-program: subq $16, %rsp leaq -1(%rbp), %rax subq $4444444, %rax movl $3333333, %edx movl $0, %esi movq %rax, %rdi call memset If