x86-64

Assembly jumps automatically to next label

北城余情 提交于 2020-01-17 10:57:22
问题 I've written a program in assembly that look like this: %macro print 1 push rbp mov rdi, %1 xor rax, rax call _printf pop rbp %endmacro section .data e db 'Equal', 0 l db 'Less than', 0 g db 'Greater than', 0 section .text global start extern _printf start: mov rax, 5 mov rbx, 5 cmp rax, rbx ; Compare 4 and 5 je _equal ; je = jump if equal cmp rax, rbx jl _less ; jl = jump if less cmp rax, rbx jg _greater ; jg = jump if greater ret _equal: print e _less: print l _greater: print g But when I

Assembly jumps automatically to next label

↘锁芯ラ 提交于 2020-01-17 10:56:49
问题 I've written a program in assembly that look like this: %macro print 1 push rbp mov rdi, %1 xor rax, rax call _printf pop rbp %endmacro section .data e db 'Equal', 0 l db 'Less than', 0 g db 'Greater than', 0 section .text global start extern _printf start: mov rax, 5 mov rbx, 5 cmp rax, rbx ; Compare 4 and 5 je _equal ; je = jump if equal cmp rax, rbx jl _less ; jl = jump if less cmp rax, rbx jg _greater ; jg = jump if greater ret _equal: print e _less: print l _greater: print g But when I

Assembly jumps automatically to next label

孤人 提交于 2020-01-17 10:56:06
问题 I've written a program in assembly that look like this: %macro print 1 push rbp mov rdi, %1 xor rax, rax call _printf pop rbp %endmacro section .data e db 'Equal', 0 l db 'Less than', 0 g db 'Greater than', 0 section .text global start extern _printf start: mov rax, 5 mov rbx, 5 cmp rax, rbx ; Compare 4 and 5 je _equal ; je = jump if equal cmp rax, rbx jl _less ; jl = jump if less cmp rax, rbx jg _greater ; jg = jump if greater ret _equal: print e _less: print l _greater: print g But when I

Assembly jumps automatically to next label

大憨熊 提交于 2020-01-17 10:56:02
问题 I've written a program in assembly that look like this: %macro print 1 push rbp mov rdi, %1 xor rax, rax call _printf pop rbp %endmacro section .data e db 'Equal', 0 l db 'Less than', 0 g db 'Greater than', 0 section .text global start extern _printf start: mov rax, 5 mov rbx, 5 cmp rax, rbx ; Compare 4 and 5 je _equal ; je = jump if equal cmp rax, rbx jl _less ; jl = jump if less cmp rax, rbx jg _greater ; jg = jump if greater ret _equal: print e _less: print l _greater: print g But when I

Calling Convention of Floats in Nasm

二次信任 提交于 2020-01-17 03:43:06
问题 So recently we learned about floating point operations and got a few questions as a homework. One of those is: "Write down the calling convention of single precision floats!". So i know about the xmm registers and know that on double precision the first input goes into xmm0 and so on. I looked up the topic on Google but couldn't find the answer. Would be nice if someone could help me on this question. 回答1: Every calling convention I'm familiar with handles single float the same as it does

Compile gcc on amd64, for running on i686, and target is mips

孤者浪人 提交于 2020-01-17 00:46:29
问题 I want to compile gcc and binutils for MIPS target. I am working on 64-bit (amd64) machine. And want to obtain binary which is able to run on i686 (not amd64) arhitecture? How should I condigure and build gcc? If I am adding --host=i686-linux-gnu to ./configure script, then it complains on absence of i686-xxxx tools. If I am adding CFLAGS=-m32, then I can build binutils, but not gcc, because of following error: g++ -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti

Compile gcc on amd64, for running on i686, and target is mips

落爺英雄遲暮 提交于 2020-01-17 00:43:06
问题 I want to compile gcc and binutils for MIPS target. I am working on 64-bit (amd64) machine. And want to obtain binary which is able to run on i686 (not amd64) arhitecture? How should I condigure and build gcc? If I am adding --host=i686-linux-gnu to ./configure script, then it complains on absence of i686-xxxx tools. If I am adding CFLAGS=-m32, then I can build binutils, but not gcc, because of following error: g++ -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti

Address-size override prefix in 64-bit or using 64-bit registers

时光总嘲笑我的痴心妄想 提交于 2020-01-16 08:39:10
问题 in Assembly Addressing (64-bit), which way is better? mov cl, BYTE [ebx + .DATA] or mov cl, BYTE [rbx + .DATA] ? the opcode for first way is : 67 8a 4b .. and the opcode for second way is : 8a 4b .. so if we use 32-bit register, we need to have a '0x67' prefix (Address-size override prefix) so i think we added an extra job !!! but i heard something about (CACHE) and it's better to use '32-bit' instead of '64-bit' so which way is better at all ? and why ? 回答1: TL:DR: you basically never want

Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+

帅比萌擦擦* 提交于 2020-01-15 07:50:28
问题 I am investigating Intel CPU atomic features on my Haswell CPU (a 4/8 core 2.3-3.9ghz i7-4790M), and am finding it really hard to construct eg. reliable mutex_lock() and mutex_unlock() operations as suggested by for instance the GCC manual: 6.53 x86-Specific Memory Model Extensions for Transactional Memory The x86 architecture supports additional memory ordering flags to mark lock critical sections for hardware lock elision. These must be specified in addition to an existing memory model to

Declaring variable-sized arrays in assembly

余生长醉 提交于 2020-01-15 05:21:07
问题 I'm writing an assembly program which I want to be able to do the (basic) following: x = 100; y = int[x] E.g. the size of y depends on the value of x. NOTE: I am using NASM instruction set on a 64 bit Ubuntu system. In assembly I know that the size of an array needs to be declared in the data section of the file e.g. myvariable resq 1000 The problem is I won't know how big to make it till I have done a previous calculation. What I really want is something like: mov rax, 100 myvariable resq