x86-64

32 bit operating system but x64 processor?

半世苍凉 提交于 2019-12-12 05:48:46
问题 Is it possible to have "32 bit operating system" running on "64 bit processor" ? What happens when I target my runtime in .net to x-64 and my OS is 32 bit ? One more to add "by the way what is meant by 32 bit OS (vs 32 bit processor)" ? 回答1: Yes; the x64 processor is just an extension of x86, which is a 32-bit processor. It will not run. It means the OS contains code for running on a 32-bit processor. 来源: https://stackoverflow.com/questions/9816282/32-bit-operating-system-but-x64-processor

inline assembly not showing output

喜欢而已 提交于 2019-12-12 04:24:08
问题 i am compiling this program in cygwin 64 bit windows, no output, compiles correctly #include <unistd.h> int main(void) { const char hello[] = "Hello World!\n"; const size_t hello_size = sizeof(hello); ssize_t ret; asm volatile ( "movl $1, %%eax\n\t" "movl $1, %%edi\n\t" "movq %1, %%rsi\n\t" "movl %2, %%edx\n\t" "syscall" : "=a"(ret) : "g"(hello), "g"(hello_size) : "%rdi", "%rsi", "%rdx", "%rcx", "%r11" ); return 0; } 回答1: Michael's comment does correctly define the problem. But as an

Rotation or Shifting with x86/x64 Assembly

妖精的绣舞 提交于 2019-12-12 04:15:13
问题 I have function that I'm writing in assembly and I want to be sure what is going to give me the best throughput. I have a 64bit value in RAX and I need to get the top most byte and perform some operations on it and I was wondering what is the best way of going about this. shr rax, 56 ; This will get me the most significant byte in al. However, is this more effective than... rol rax, 8 and rax, r12 ; I already have the value 255 in r12 The reason why I'm asking is that on some architectures,

Use a particular register for a variable in LLVM

旧城冷巷雨未停 提交于 2019-12-12 03:07:28
问题 I am writing an LLVM pass which modifies the LLVM bitcode. For one variable, I want it to use a register, say R15 on x86. How can I instruct LLVM to use this register when generating machine code? Can this be instructed at the bitcode level? 回答1: You can use inline assembler to model this requirement. There is no way to "tie" specific variable to register. 来源: https://stackoverflow.com/questions/9897726/use-a-particular-register-for-a-variable-in-llvm

Segmentation fault assembly i386:x86_64

六月ゝ 毕业季﹏ 提交于 2019-12-12 02:57:52
问题 I'm working on i386:x86_64 and I'm writing a simple program to start a shell. Bellow is my assembly. .section .data .section .text .globl _start _start: xor %rax, %rax mov $70, %al xor %rbx, %rbx xor %rcx, %rcx int $0x80 jmp ender starter: pop %rbx xor %rax, %rax mov %al, 0x07(%rbx) mov %rbx, 0x08(%rbx) mov %rax, 0x0c(%rbx) mov $11, %al lea 0x08(%rbx), %rcx lea 0x0c(%rbx), %rdx int $0x80 ender: call starter .string "/bin/sh" The problem is that I keep getting a segmentation fault. When I use

assembly .set directive gives error invalid operands (.data and *UND* sections)

旧城冷巷雨未停 提交于 2019-12-12 02:35:35
问题 I am learning to write a bootloader. As a part of experiment, I want to be able to print hexadecimal values as strings. I wrote following assembly code which doesn't entirely implement hex to string functionality. However, I expected following code to at least assemble correctly. $ cat print_bios.S .file "print_bios.S" .section .data .hex_str: .ascii "xxxxxxxxxxxxxxxx" .set hex_size, .-hex_str .section .text .global .hex_to_string hex_to_string: push %rbp mov %rsp, %rbp /* * leave speace for

How to make it work in x86-64 assembly?

ぃ、小莉子 提交于 2019-12-12 02:06:43
问题 Recently I'm learning assembly and now i have some confusion. I learned it from Professional Assembly language. My System's arch: #uname -m x86_64 This is my code: .section .data output: .asciz "This is section %d\n" .section .text .globl _start _start: pushq $1 pushq $output call printf addq $8, %rsp call overhere pushq $3 pushq $output call printf addq $8, %rsp pushq $0 call exit overhere: pushq %rbp movq %rsp, %rbp pushq $2 pushq $output call printf addq $8, %rsp movq %rbp, %rsp popq %rbp

x86-64 Arrays Inputting and Printing

妖精的绣舞 提交于 2019-12-12 01:59:15
问题 I'm trying to input values into an array in x86-64 Intel assembly, but I can't quite figure it out. I'm creating an array in segement .bss. Then I try to pass the address of the array along to another module by using r15. Inside that module I prompt the user for a number that I then insert into the array. But it doesn't work. I'm trying to do the following segment .bss dataArray resq 15 ; Array that will be manipulated segment .text mov rdi, dataArray ; Store memory address of array so the

Memory allocation and addressing in Assembly

放肆的年华 提交于 2019-12-12 01:23:05
问题 I am trying to learn assembly and there a couple of instructions whose purpose I do not fully understand. C code #include <stdio.h> int main(int argc, char* argv[]) { printf("Argument One - %s\n", argv[1]); return 0; } Assembly .section __TEXT,__text,regular,pure_instructions .build_version macos, 10, 14 .intel_syntax noprefix .globl _main ## -- Begin function main .p2align 4, 0x90 _main: ## @main ## %bb.0: push rbp mov rbp, rsp sub rsp, 32 lea rax, [rip + L_.str] mov dword ptr [rbp - 4], 0

Reading CF, PF, ZF, SF, OF

孤人 提交于 2019-12-11 23:29:38
问题 I am writing a virtual machine for my own assembly language, I want to be able to set the carry, parity, zero, sign and overflowflags as they are set in the x86-64 architecture, when I perform operations such as addition. Notes: I am using Microsoft Visual C++ 2015 & Intel C++ Compiler 16.0 I am compiling as a Win64 application. My virtual machine (currently) only does arithmetic on 8-bit integers I'm not (currently) interested in any other flags (e.g. AF) My current solution is using the