x86-64

Error Raised When Attempting to Assign Value At Index of Array With x86 Assembly GNU GAS

倾然丶 夕夏残阳落幕 提交于 2020-01-15 03:46:33
问题 I am using x86 GNU assembly with GCC and am attempting to implement the Assembly equivalent of the following c/c++ : int x[10]; x[0] = 5; However, when I attempt to run (with command ./a.out ) my Assembly code below (after first compiling with the gcc filename.s ), the error Segmentation fault: 11 is printed to the console: .data x:.fill 10 index:.int 0 .text .globl _main _main: pushq %rbp movq %rsp, %rbp subq $16, %rsp lea x(%rip), %rdi mov index(%rip), %rsi; movl $5, %eax; movl %eax, (%rdi,

Intel x86_64 Assembly: What is good way to convert 32bit integer to 64bit int?

萝らか妹 提交于 2020-01-15 03:46:10
问题 As title says. My way to do this: ; eax holds 32bit integer sal rax, 32 sar rax, 32 ;after operation int is converted (rax holds the same value on 64 bits) Is there more elegant/better/faster way to do this?? 回答1: TL;DR : movsxd , or for the eax special-case, cdqe . Like I explained in one of your previous questions, you can answer these yourself by looking at compiler output. It's really easy to write a function that sign-extends an integer, then go look up the instruction it uses in the

Why does this simple assembly program work in AT&T syntax but not Intel syntax?

我怕爱的太早我们不能终老 提交于 2020-01-14 14:12:06
问题 What's wrong with this code (Running on x86_64 Linux)? .intel_syntax .text .globl _start _start: mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, 14 syscall mov rax, 60 mov rdi, 0 syscall .data msg: .ascii "Hello, world!\n" When I run it: $ clang -o hello_intel hello_intel.s -nostdlib && ./hello_intel No output. Let's strace it: $ strace ./hello_intel execve("./hello_intel", ["./hello_intel"], [/* 96 vars */]) = 0 write(1, 0x77202c6f6c6c6548, 14) = -1 EFAULT (Bad address) exit(0) = ? +++ exited

Why does this simple assembly program work in AT&T syntax but not Intel syntax?

耗尽温柔 提交于 2020-01-14 14:09:27
问题 What's wrong with this code (Running on x86_64 Linux)? .intel_syntax .text .globl _start _start: mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, 14 syscall mov rax, 60 mov rdi, 0 syscall .data msg: .ascii "Hello, world!\n" When I run it: $ clang -o hello_intel hello_intel.s -nostdlib && ./hello_intel No output. Let's strace it: $ strace ./hello_intel execve("./hello_intel", ["./hello_intel"], [/* 96 vars */]) = 0 write(1, 0x77202c6f6c6c6548, 14) = -1 EFAULT (Bad address) exit(0) = ? +++ exited

How to compile assembly whose entry point is not main with gcc?

自古美人都是妖i 提交于 2020-01-14 12:55:51
问题 .text .globl _start _start: pushq %rbp movq %rsp,%rbp movq $2, %rax leaveq retq I'm compiling with -nostdlib : [root@ test]# gcc -nostdlib -Wall minimal.S &&./a.out Segmentation fault What's wrong here? BTW,is it possible to make the entry point other names than main and _start ? 回答1: As @jaquadro mentions, you can specify the entry point on the command line to the linker (or use a link script): gcc -Wall -Wextra -nostdlib -Wl,-eMyEntry minimal.S && ./a.out The reason your program segfaults

Unauthorized Access Exception in Windows 7

风格不统一 提交于 2020-01-14 11:58:53
问题 I have an application which reads a license file when it starts up. My install creates the folder in Program Files for the application, creates the license folder and puts the license file in there. However when I try and run the application, it needs to read/update the license file. When I try and do that I get an "Unauthorized Access Exception". I am logged on as an administrator and I'm running the program manually. Any idea why I cannot access that file even though the path is correct?

Unauthorized Access Exception in Windows 7

删除回忆录丶 提交于 2020-01-14 11:58:52
问题 I have an application which reads a license file when it starts up. My install creates the folder in Program Files for the application, creates the license folder and puts the license file in there. However when I try and run the application, it needs to read/update the license file. When I try and do that I get an "Unauthorized Access Exception". I am logged on as an administrator and I'm running the program manually. Any idea why I cannot access that file even though the path is correct?

Using 8-bit registers in x86-64 indexed addressing modes

强颜欢笑 提交于 2020-01-14 09:42:12
问题 Is it possible to use the 8-bit registers ( al, ah, bl, bh, r8b ) in indexed addressing modes in x86-64? For example: mov ecx, [rsi + bl] mov edx, [rdx + dh * 2] In particular, this would let you use the bottom 8-bits of a register as a 0-255 offset, which could be useful for some kernels. I poured over the Intel manuals and they aren't explicit on the matter, but all the examples they give only have 32-bit or 64-bit base and index registers. In 32-bit code I only saw 16 or 32-bit registers.

Using 8-bit registers in x86-64 indexed addressing modes

安稳与你 提交于 2020-01-14 09:42:08
问题 Is it possible to use the 8-bit registers ( al, ah, bl, bh, r8b ) in indexed addressing modes in x86-64? For example: mov ecx, [rsi + bl] mov edx, [rdx + dh * 2] In particular, this would let you use the bottom 8-bits of a register as a 0-255 offset, which could be useful for some kernels. I poured over the Intel manuals and they aren't explicit on the matter, but all the examples they give only have 32-bit or 64-bit base and index registers. In 32-bit code I only saw 16 or 32-bit registers.

data movement error clarification

两盒软妹~` 提交于 2020-01-13 07:21:29
问题 I'm currently solving problem 3.3 from 3rd edition of Computer System: a programmer's perspective and I'm having a hard time understanding what these errors mean... movb $0xF, (%ebx) gives an error because ebx can't be used as address register movl %rax, (%rsp) and movb %si, 8(%rbp) gives error saying that theres a mismatch between instruction suffix and register I.D. movl %eax, %rdx gives an error saying that destination operand incorrect size why can't we use ebx as address register? Is it