x86-64

Why isn't the text colored when using the 0Eh 10h interrupt?

折月煮酒 提交于 2019-11-29 17:57:48
I'm using the 10h interrupt with AH as 0Eh to output "Hello World!" The text is ouputted but its not colored. I'm running it on qemu-system-x86_64, assembling with NASM, and my code is as follows: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax mov si, text_string ; Put string position into SI call print_string ; Call our string-printing routine jmp $ ; Jump here - infinite loop! text_string db 'Hello World!', 0 print_string: ;

Logarithm in C++ and assembly

…衆ロ難τιáo~ 提交于 2019-11-29 17:06:13
Apparently MSVC++2017 toolset v141 (x64 Release configuration) doesn't use FYL2X x86_64 assembly instruction via a C/C++ intrinsic, but rather C++ log() or log2() usages result in a real call to a long function which seems to implement an approximation of logarithm (without using FYL2X ). The performance I measured is also strange: log() (natural logarithm) is 1.7667 times faster than log2() (base 2 logarithm), even though base 2 logarithm should be easier for the processor because it stores the exponent in binary format (and mantissa too), and that seems why the CPU instruction FYL2X

Write a jump command to a x86-64 binary file

亡梦爱人 提交于 2019-11-29 16:49:27
I'm debugging a Mac OS X 64bit app with GDB. I see that jumping over a chunk of code solves all my problems. But: How can I patch the executable file to implement the jump? I want the app to automatically jump to a defined point in the code without the debugger. This is what I want to do: At address 0x1000027a9 (given by the debugger) jump to address 0x100003b6e . I'm trying very hard to do it via HexEdit, but with no success. I read anywhere about jmp to absolute addresses opcodes ( FF seems the right opcode, but it's a call, not a jump...) but nothing works. Bad access, segfault. How can I

Segfault on movq instruction?

和自甴很熟 提交于 2019-11-29 16:45:05
Consider the following short program. int main(){ asm("movq 0x5F5E100, %rcx;" "startofloop: ; " "sub 0x1, %rcx; " "jne startofloop; "); } This program compiles fine, but when it is run, it segfaults on the initial movq instruction. I must be missing something obvious, but I hope someone here can point it out for me. I am running on Debian 8, with kernel 3.16.0-4-amd64, in case that is relevant. For future reference, this is what the compiler generated. main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 #APP # 2 "asm_fail.c"

Why cant i sys_write from a register? [duplicate]

 ̄綄美尐妖づ 提交于 2019-11-29 16:14:21
This question already has an answer here: What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code? 1 answer ; NASM push 30 ; '0' mov rax, 4 ; write mov rbx, 1 ; stdout mov rcx, rsp ; ptr to character on stack mov rdx, 1 ; length of string = 1 int 80h The code above does not print anything to stdout. It works when i give it a ptr to a character in section .data . What am i doing wrong? amd64 uses a different method for system calls than int 0x80 , although that might still work with 32-bit libraries installed, etc. Whereas on x86 one would do: mov eax, SYSCALL_NUMBER mov ebx,

How Get arguments value using inline assembly in C without Glibc?

帅比萌擦擦* 提交于 2019-11-29 15:59:39
How Get arguments value using inline assembly in C without Glibc? i require this code for Linux archecture x86_64 and i386 . if you know about MAC OS X or Windows , also submit and please guide. void exit(int code) { //This function not important! //... } void _start() { //How Get arguments value using inline assembly //in C without Glibc? //argc //argv exit(0); } New Update https://gist.github.com/apsun/deccca33244471c1849d29cc6bb5c78e and #define ReadRdi(To) asm("movq %%rdi,%0" : "=r"(To)); #define ReadRsi(To) asm("movq %%rsi,%0" : "=r"(To)); long argcL; long argvL; ReadRdi(argcL); ReadRsi

32 bit ActiveX Control in a 64 bit .NET App

假如想象 提交于 2019-11-29 15:29:56
I'm creating a C#.Net application which I want to be able to compile for "All CPUs". I also want to include a specific ActiveX control in the UI of this app, but the ActiveX control I'm trying to use does not support 32 bit. Is there some trick or work around I can use to use get this control to work? What about embedding the ActiveX control in a Web-browser control? Would this even work? You have to run the ActiveX control in a separate 32-bit process. That's going to be difficult, it would have its own window that isn't going to be part of the UI of your 64-bit process. Although it is

Does printf require additional stack space on the x86-64? [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-11-29 15:01:41
This question already has an answer here: Printing floating point numbers from x86-64 seems to require %rbp to be saved 1 answer While I know it is best to use compiler intrinsics, and for that matter, printf_chk , and also to put data in .rodata sections, I'm looking at gaining a deeper understanding of assembly language and am interested in compact code. There is something about printf I don't understand. I know where to put the parameters, and I know how to use %al for varargs, but it appears to be requiring additional stack space that I cannot account for. This short program .text .globl

How to get this simple assembly to run?

▼魔方 西西 提交于 2019-11-29 14:51:54
This is my first ever attempt at programming with assembly. I'm using a 64 bit Mac OS. I'm also using NASM. I've done a lot of looking around for a solution, but I can't find anything that works for my machine. Can anyone help me solve this problem? Here is the code and error, thanks! hello.asm global start section .text start: mov rax, 1 mov rdi, 1 mov rsi, message mov rdx, 13 syscall mov eax, 60 xor rdi, rdi syscall message: db "Hello, World", 10 my attempt at executing: nasm -f macho64 hello.asm -o hello.o ld -arch i386 -o hello hello.o ./hello the error ld: warning: -macosx_version_min not

How many clock cycles does cost AVX/SSE exponentiation on modern x86_64 CPU?

微笑、不失礼 提交于 2019-11-29 14:43:38
How many clock cycles does cost AVX/SSE exponentiation on modern x86_64 CPU? I am about: pow(x, y) = exp(y*log(x)) I.e. do both exp() and log() AVX x86_64 instructions require certain known number of cycles? exp(): _mm256_exp_ps() log(): _mm256_log_ps() Or the number of cycles may vary depending on the exponential degree, is there the maximum number of cycles can cost exponentiation? The x86 SIMD instruction set (i.e. not x87), at least up to AVX2, does not include SIMD exp , log , or pow with the exception of pow(x,0.5) which is the square root. There are SIMD math libraries however which are