Computers implement an instruction set architecture that define the set of action the hardware the should be capable of performing. These machine instructions provide the necessary components for programs to be written and executed.
Questions tagged [machine-instruction]
67 questions
5
votes
0 answers
How do I convert MachineInstr to MCInst in LLVM?
I want this conversion (from MachineInstr to MCInst) in a MachineFunctionPass.
I know that X86MCInstLower converts the MachineInstr to MCInst. However, initializing X86MCInstLower requires an instance of X86AsmPrinter. X86AsmPrinter is in itself…

soham
- 1,508
- 6
- 30
- 47
5
votes
6 answers
What C++ code compiles down to the x86 REP instruction?
I'm copying elements from one array to another in C++. I found the rep movs instruction in x86 that seems to copy an array at ESI to an array at EDI of size ECX. However, neither the for nor while loops I tried compiled to a rep movs instruction in…

securelsh
- 63
- 1
- 6
3
votes
0 answers
Result reshuffling during instruction selection
In an LLVM backend, during instruction selection, my input looks something like this:
t17: i16,ch = load t16:1, t2, undef:i16
I'd like to select an opcode that has some extra result as well, i.e. replace the above with something like
t17: i16, _:…

Cactus
- 27,075
- 9
- 69
- 149
3
votes
2 answers
How to execute machine instructions placed on the stack
I have a return value in my previous stack frame that points towards a buffer in my subsequent stack frame. How can I get machine instructions, placed in the buffer, to execute?
Is this even possible? From what I understand about the stack this is…

Kendall Weihe
- 111
- 1
- 1
- 9
2
votes
1 answer
How to read the direction bit and source or destination of an assembly instruction
So I'm working on some code (for x86) where I need to get the source or destination point of an instruction. For this I need the direction bit which says whether ModRM or REG is the destination or source. Also I need to be able to handle immediate…

Jesus Ramos
- 22,940
- 10
- 58
- 88
2
votes
1 answer
aesimc instruction gives incorrect result
I'm trying to implement AES cryptography using the AES machine instructions (basing it on Intel's white paper) available on my Sandy Bridge. Unfortunately, I've come to a halt in the phase of generating the round keys for decryption. Specifically,…

Morten Kristensen
- 7,412
- 4
- 32
- 52
2
votes
1 answer
Pipelining gate 2015
Consider the sequence of machine instructions given below:
MUL R5, R0, R1
DIV R6, R2, R3
ADD R7, R5, R6
SUB R8, R7, R4
In the above sequence, R0 to R8 are general purpose registers. In the instructions shown, the first register stores the result…

vinayak jadhav
- 21
- 3
2
votes
1 answer
what does machine value type "other" mean in llvm SDnodes
I am trying to understand more deeply the instruction selection process in llvm and for that I am debuging step-by-step the CodeGenAndEmitDAG function. I have printed a small function (see below) just before the combine step - the first step in the…

yehudahs
- 2,488
- 8
- 34
- 54
2
votes
1 answer
"Read a byte from an I/O port" vs. "Read a byte from an address of memory"?
For simplifying discussion, I assume there is only one executing thread. The following are just my wild speculations:
1, If the CPU reads a byte from an address of memory, then it can repeatedly read the same value from the same address.
2, If the…

xmllmx
- 39,765
- 26
- 162
- 323
2
votes
1 answer
Does an I/O instruction cycles depend on the device's speed?
For example,
in al, 8
If the device at port 8 is very slow, then does CPU have to wait for completion of the instruction in?
Thanks!

xmllmx
- 39,765
- 26
- 162
- 323
2
votes
3 answers
Do 16 bit register pairs make a machine 16 bit?
I have been working on a fictional retro virtual machine for xbox since January (I am not at all copying 0x10c, infact my project is older. just putting this out there incase some notch fanboys read this) and it has 6 general purpose registers.…

Sloan Fitzgerald
- 197
- 2
- 7
1
vote
1 answer
Transform a stack using Java Virtual Machine Instruction Set
I need to transform 654321 into 654321321, using only DUP2_X1, POP, DUP_X2, POP2. I have a really difficult time with the DUP. Can anyone help?
I tried to go like this: 654321 DUP2_X1 654654321, then POP goes to 65465432, then DUP_X2 we'd have…

Alex
- 21
- 5
1
vote
2 answers
How computer CPU executes a Software Application
I am extending the question asked on What happens when a computer program runs? and from the discussion on Stanford CS101 site Software: Running Programs. CS101 site quotes
The machine code defines a set of individual instructions. Each
machine…

user2979872
- 413
- 1
- 9
- 20
1
vote
1 answer
Help with clock cycles
I am having a hard time understanding clock cycles. Here is the problem, I am given a program that has two instructions X and Y and I know that X is run 20% of the time and requires 8 clock cycles and the other instruction Y is run 80% of the time…

bangkockFighter
- 11
- 1
1
vote
1 answer
Extracting MachineBasicBlock from Branch Instruction
The branch instruction contains labels which are the names of the basicblocks that it might jump to. Given that, is there a way to extract a MachineBasicBlock object from a branching instruction? for example:
for(MachineBasicBlock &BB : MF){
…

CodeHoarder
- 272
- 1
- 11