Questions tagged [instructions]
Questions about instructions of real CPUs, VMs or compiler IRs.
494
questions
0
votes
0answers
28 views
How are control signals known when the fetch cycle differs across instructions?
If the first cycle of each instruction is not the same (ie not all instructions have the same fetch cycle), then how does the processor know what the control signals should be for the first cycle?
I ...
0
votes
3answers
37 views
What exactly does a MIPS lw instruction do?
Help! I am new to assembly and I am trying to find out what this command does
lw %t5, 100($t8)
Also I understand that the left is the destination and the right is the source
lw Reg.Dest, Offset(Reg....
4
votes
1answer
47 views
Why does 8-bit MUL combine into AX but 16 and 32-bit MUL leave their result split between [E]DX:[E]AX?
MUL CL CL is BYTE size and it equals to AX = AL * CL
MUL BX BX is WORD size and it equals to DX:AX = AX * BX
MUL EBX EBX is DWORD size and it equals to EDX:EAX = EAX * EBX
I want to know why the 8-...
1
vote
1answer
37 views
memory stack: sub 20 from esp
I am having trouble grasping the answer in this stackoverflow thread.
https://stackoverflow.com/a/1395646
In the middle of the answer it says Most function prologs look something like:...
As I ...
0
votes
0answers
35 views
What does a period do after the first parameter of an adr instruction in arm64 assembly? [duplicate]
There's this instruction I found in a source:
adr x0, .
And I've never seen a dot used there, it's usually an address, so what does it do?
2
votes
2answers
70 views
What exactly is a machine instruction?
The user's program in main memory consists of machine instructions and
data. In contrast, the control memory holds a fixed microprogram that
cannot be altered by the occasional user. The microprogram ...
0
votes
1answer
22 views
Determining the source of Qemu guest instructions when using in_asm
I'm trying to gather statistics about the percentage of library code that is used vs executed. To do this I'm invoking Qemu-user with the -d in_asm flag. I log this to a file and get a sizeable file ...
0
votes
0answers
42 views
What does 'lretq' instruction do?
I saw 'lretq' instruction being used in a codebase, but it isn't listed in amd64 instruction manual. What does this instruction do?
1
vote
1answer
121 views
Why are there no NAND, NOR and XNOR instructions in X86?
They're one of the simplest "instructions" you could perform on a computer (they're the first ones I'd personally implement)
Performing NOT(AND(x, y)) doubles execution time AND dependency ...
1
vote
1answer
52 views
Is it specified what happens when the stack pointer is pushed on x64?
I am programming in assembly on x64, and I intend on pushing an address within the stack. I intend on writing push %rsp, however, as this instruction changes the value of %rsp, I am not sure what ...
0
votes
0answers
28 views
getelementptr llvm ir instruction arguments
I'm working on a toy compiler and I'm trying to generate llvm ir bytecode and the exe compiling it with clang.
I've a simple question: I searched on google some information about the getelementptr, ...
0
votes
0answers
20 views
Does the execution order of instructions matter if the register-states are the same?
The effect an executed instruction has depends on the current registers it is working with. For example, an instruction that adds the content of 2 registers has the same effect when the content of the ...
1
vote
0answers
41 views
Why does the push DWORD instruction equalize on 8 bytes? [duplicate]
Wrote shellcode:
BITS 64
xor rax, rax
push rax
push dword "n/sh"
push dword "//bi"
mov rdi, rsp
push rax
mov rdx, rsp
push rdi
mov rsi, rsp
mov al, 59
syscall
When code execution ...
1
vote
1answer
55 views
Why does qemu sometimes count more and sometimes less instructions than ptrace?
I want compare registers after each execution of an instruction with the register dumps made by qemu.
Therefore i wrote a program that uses ptrace to iterate through each executed instruction of a ...
2
votes
0answers
47 views
What is the XOP prefix in an instruction?
I've been reading through some source code recently and this caught my eye particularly:
/**
* Decodes the `XOP`-prefix.
*
* @param context A pointer to the `ZydisDecoderContext` struct.
* @...
-1
votes
2answers
64 views
how does str/ldr knows the register size?
aarch64 use str/ldr to store/load register into memory:
str q0, [dst]
str x0, x1, [dst]
In the example above, q0/q1 is 128bit, as well as x1/x0 is 64bit, but how does str/ldp knows the the size of ...
0
votes
0answers
36 views
What accounts for most of the integer multiply instructions?
The majority of integer multiplications don't actually need multiply:
Floating-point is, and has been since the 486, normally handled by dedicated hardware.
Multiplication by a constant, such as for ...
3
votes
2answers
200 views
What instructions does qemu trace?
I wrote the following piece of code that steps through /bin/ls and counts its instructions:
#include <stdio.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h&...
0
votes
1answer
41 views
c++ Hold instructions for a later time
I am trying to design a UIDraw method. I want to declare what UI elements to draw in the main Draw method But then Have a separate UIDraw Method later in the code. So I need a way to store ...
1
vote
0answers
93 views
The execution process of the instruction and the realization in gem5?
I am learning the running process of the program on gem5. And read some books. But I am still confused about the parts in the program execution. Is my understanding below correct?
First, the computer ...
-2
votes
1answer
52 views
Question regarding converting assembly to c — specifically what the movzbl instruction does? [duplicate]
I am trying to figure out what this in assembly would mean in C:
movq 16(%rdi), %rdx
movq 16(%rsi), %rax
movzbl (%rdx), %edx
I am mostly confused about what the movzbl (%rdx), %edx will do. Thanks!
1
vote
1answer
83 views
Find the INDEX of element having max. absolute value using AVX512 instructions
I'm a newbie for coding using AVX512 instructions. My machine is Intel KNL 7250. I am trying to use AVX512 instructions to find the INDEX of the element having maximum absolute value, which double ...
1
vote
1answer
57 views
What does the “set” instruction do in AVR assembly?
I am trying to understand the following assembly code, but have been unsuccessful with the "set" instruction in the following code.
2: dec CTR
brne 3f
set
Googling Assembly Set ...
1
vote
1answer
170 views
Why does x86 only have 1 form of conditional move, not immediate or 8-bit? [closed]
I've noticed that the Conditional Move instruction is less extensible than the normal mov. For example, it doesn't support immediates and doesn't support the low-byte of a register.
Out of curiosity, ...
0
votes
2answers
301 views
“Illegal instruction (core dumped)” on tensorflow >1.6
I am trying to run import tensorflow on various tensorflow version. The one that I really want to use is 1.13.1.
My CPU is INTEL Xeon Scalable GOLD 6126 - 12 Cores (24 Threads) 2.60GHz.
I've already ...
0
votes
1answer
100 views
What are the operands of C.LUI instruction(compressed subset of RISC-V)?
In the RISC-V mannual for this instructions is written:
C.LUI loads the non-zero 6-bit immediate field into bits 17ā12 of the destination register, clearsthe bottom 12 bits, and sign-extends bit 17 ...
-1
votes
2answers
553 views
Why opcode is 6-bit long in MIPS 32 bit Architecture
Below is Data transfer instruction format for 32-bit ARM and MIPS architecture. 32-bit ARM architecture have 4 bit opcode because there are 16 registers (2^4=16).32-bit MIPS architecture have 6 bit ...
1
vote
3answers
196 views
How to use C.ADDI4SPN and C.ADDI16SP instructions (compressed subset) of RISC-V architecture?
I can't figure out how to call these two instructions in a proper way. The first operand of the first instruction C.ADDI4SPN should be a register, and the second one, if I'm right, should be a number ...
0
votes
0answers
79 views
Is movq faster than mov on x64-64 architecture? [duplicate]
Agner Fog's instruction tables for Skylake show these two instructions:
MOV r32/64,m 1 1 p23 2 0.5
MOVQ r64,mm/x 1 1 p0 2 1
where each instruction has 1 micro-op in the fused domain, 1 micro-op in ...
3
votes
1answer
266 views
Does RISC-V compressed instructions subset (RVC) always assemble into 32-bit instrucions in binary file?
I am confused. When I assemble compressed instruction subset in the binary file I get the 32-bit instruction, but I thought I would get 16-bit instructions because RVC subset is encoded with 16-bits. ...
-2
votes
1answer
198 views
What is the difference between “instruction” and “operation” terms?
Definitions:
Instruction is just atomic parts of assembly language like
MOV EAX, EBX
Now let's say we have the following code written in C++ language:
int a = 1;
int b = a + 3;
Here = and + ...
3
votes
2answers
81 views
Is it legal to have same register as operands in one instruction?
For example, below is a X86-64 instruction:
movq (%rdi),%rdi
It reads the content (pointed by %rdi) and set this content to %rdi, which is valid in sequential logic?
Or do we have to assign it to a ...
0
votes
1answer
126 views
Opcodes:hexadecimal assembly instructions
The page at http://ref.x86asm.net/coder64.html#xF0 gives various hexadecimal opcodes.
In my Visual studio dissambly, i have
FF E0 jmp rax
I just found pasting 'jmp rax' and ...
0
votes
0answers
41 views
Getting dependence types of RAW, WAR, WAW from instruction numbers
I have this question which asks me to find the dependence types RAW, WAR, WAW, based on these instruction numbers, and I have the answer in the table, but I can't remember how to arrive at this answer....
0
votes
0answers
140 views
In MIPS assembly, how to branch to a label if the user input is not an integer? [duplicate]
I have a small block of code that tests if the user input is within a range of integers and jump to a label to print an error message if it's out of bounds.
pr: la $a0, prompt # load address ...
2
votes
1answer
79 views
Understanding cmpxchg8b/cmpxchg16b operation
The SDM text for this instruction has the following block:
This instruction can be used with a LOCK prefix to allow the instruction to be executed atomically. To simplify the interface to
the ...
0
votes
1answer
50 views
Why I can't use virtual register variables in instruction composition?
I am trying to utilize instruction composition to make my LLVM IR code more readable, by performing multiple operations at once. I have four virtual register variables that I want to add together and ...
2
votes
1answer
135 views
RISC-V instruction to write dirty cache line to next level of cache
Are there any RISC-V instructions to write-back dirty cache line to next level of cache, or to main memory, like clwb in x86 or cvac in ARMv8-A?
I want to ensure commit to non-volatile persistent ...
0
votes
1answer
43 views
Are data and instructions segregated in the data bus in modified Harvard architectures?
In a modified Harvard architecture, both data and instructions (code) are stored together in DRAM and in L2 cache, while being separate at the L1 level. They are also both transferred from DRAM to ...
-1
votes
1answer
124 views
How to execute ARM binary instructions?
let's say I have a file full of ARM processor instructions which are already represented as bytes. What is the best way to execute them directly with qemu-arm?
Thanks!
0
votes
1answer
44 views
how does CF(Carry flag) get set according to the computation t = a-b where a and b are unsigned integers
I'm new to x64-64, just a question on how does CF get set? I was reading a textbook which says:
CF: Carry flag is used when most recent operation generated a carry out of the most significant bit. ...
1
vote
1answer
86 views
why use 32-bit register when the data type is 64-bit?
I was reading a textbook that has an exercise that generates assembly code based on C code:
C code:
long arith(long x, long y, long z)
{
long t1 = x ^ y;
long t2 = z * 48;
long t3 = t1 & ...
0
votes
0answers
54 views
How are individual instructions and their input operands stored in memory?
Are the individual processor instructions simply the first "x amount of"bits and then the input operands just some other "x amount of"bits adjacent and contiguous after the ...
2
votes
2answers
110 views
Instructions to copy the low byte from an int to a char: Simpler to just do a byte load?
I was reading a text book and it has an exercise that write x86-64 assembly code based on C code
//Assume that the values of sp and dp are stored in registers %rdi and %rsi
int *sp;
char *dp;
*dp = (...
1
vote
2answers
184 views
can we move content from smaller register to larger register
For example, can we do:
movl %eax,%rdx // l means 32 bits while rdx is 64 biregister
so if we move 32 bits content of %eax to %rdx, then only the low order 32 bits of %rdx get updated?
0
votes
0answers
99 views
Verilog. Trying to expand Datapath and Decoder with 3-AluControl bits for multiplication and bltz MIPS instructions
I currently am doing a assignment for my university on verilog, where we need to implement a single-cycle MIPS processor. Issue is, we are only given 3 Control-Bits on the ALU, just my group has no ...
-1
votes
1answer
322 views
load 32 bit immediate value in RISCV memory
I am trying to store a 32 bit immediate value in a riscv memory location.The corresponding code is
lui x13,0x12345
addi x13,x13,0x678 // 32 bit value- 12345678
lui x11, 0x1c010 // address ...
3
votes
1answer
57 views
Execute operations of the same instruction separately in an OoO processor
Imagine that we have an instruction which has been divided into 3 micro-operations, and we have an out-of-order processor. My question is: these 3 uops must be executed sequentially or can the ...
0
votes
0answers
15 views
instruction counts using perf tool [duplicate]
I've run two executables which are the same but the only difference between them is statically linked and dynamically liked.
At first, I saw dynamically linked executable shows much higher the ...
0
votes
1answer
168 views
Assembly move instruction seems to be useless [duplicate]
I'am trying to learn assembly. I disassembled a simple C program and debugged it with gdb. But one thing I've noticed is that values are moved very frequent.
0x0000555555555231 <+0>: ...