Questions tagged [instructions]

Questions about instructions of real CPUs, VMs or compiler IRs.

Questions about instructions of real CPUs such as ARM and x86, virtual machines such as Java, or compiler internal representations such as LLVM.

512 questions
122
votes
8 answers

`testl` eax against eax?

I am trying to understand some assembly. The assembly as follows, I am interested in the testl line: 000319df 8b4508 movl 0x08(%ebp), %eax 000319e2 8b4004 movl 0x04(%eax), %eax 000319e5 85c0 testl %eax, %eax …
maxpenguin
  • 4,709
  • 6
  • 26
  • 21
120
votes
16 answers

Are there any smart cases of runtime code modification?

Can you think of any legitimate (smart) uses for runtime code modification (program modifying it's own code at runtime)? Modern operating systems seem to frown upon programs that do this since this technique has been used by viruses to avoid…
83
votes
1 answer

C code loop performance [continued]

This question continues on my question here (on the advice of Mystical): C code loop performance Continuing on my question, when i use packed instructions instead of scalar instructions the code using intrinsics would look very similar: for(int…
Ricky
  • 1,633
  • 2
  • 19
  • 22
45
votes
4 answers

How does x86 pause instruction work in spinlock *and* can it be used in other scenarios?

The pause instruction is commonly used in the loop of testing spinlock, when some other thread owns the spinlock, to mitigate the tight loop. It's said that it is equivalent to some NOP instructions. Could somebody tell me how exactly it works for…
Infinite
  • 2,848
  • 4
  • 23
  • 31
41
votes
3 answers

C code loop performance

I have a multiply-add kernel inside my application and I want to increase its performance. I use an Intel Core i7-960 (3.2 GHz clock) and have already manually implemented the kernel using SSE intrinsics as follows: for(int i=0; i
Ricky
  • 1,633
  • 2
  • 19
  • 22
34
votes
4 answers

What is the 0x10 in the "leal 0x10(%ebx), %eax" x86 assembly instruction?

What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else? leal 0x10(%ebx), %eax Can someone please clarify? This is x86 assembler on a Linux box.
Tony The Lion
  • 57,181
  • 57
  • 223
  • 390
33
votes
4 answers

IL Instructions not exposed by C#

What IL instructions are not exposed by C#? I'm referring to instructions like sizeof and cpblk - there's no class or command that executes these instructions (sizeof in C# is computed at compile time, not at runtime AFAIK). Others? EDIT: The reason…
YellPika
  • 2,834
  • 1
  • 25
  • 29
27
votes
1 answer

Difference between movq and movabsq in x86-64

I'm a newcomer here and just starting to study assembly language. So please correct me if I'm wrong, or if this post doesn't make any sense I will delete. I'm talking about data movement instructions in the x86-64 Intel architecture. I have read…
IgNite
  • 490
  • 1
  • 5
  • 14
24
votes
5 answers

How is x86 instruction cache synchronized?

I like examples, so I wrote a bit of self-modifying code in c... #include #include // linux int main(void) { unsigned char *c = mmap(NULL, 7, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE| …
Will
  • 1,879
  • 1
  • 17
  • 34
23
votes
6 answers

MOVing between two memory addresses

I'm trying to learn assembly (so bear with me) and I'm getting a compile error on this line: mov byte [t_last], [t_cur] The error is error: invalid combination of opcode and operands I suspect that the cause of this error is simply that its not…
Justin
  • 80,106
  • 47
  • 208
  • 350
21
votes
1 answer

JVM instruction ALOAD_0 in the 'main' method points to 'args' instead of 'this'?

I am trying to implement a subset of Java for an academic study. Well, I'm in the last stages (code generation) and I wrote a rather simple program to see how method arguments are handled: class Main { public static void main(String[] args) { …
ArjunShankar
  • 21,354
  • 5
  • 57
  • 78
19
votes
2 answers

Why can an executable run on both Intel and AMD processors?

How is it that an executable can work on both AMD and Intel systems. Aren't AMD's and Intel's instruction sets different? How does the executable work on both? How exactly do they compile the files to work like that. And what exactly is the role of…
16
votes
1 answer

difference between conditional instructions (cmov) and jump instructions

I'm confused where to use cmov instructions and where to use jump instructions in assembly? From performance point of view: What is the difference in both of them? Which one is better? If possible, please explain their difference with an…
jigglypuff
  • 189
  • 1
  • 8
16
votes
4 answers

How exactly do executables work?

I know that executables contain instructions, but what exactly are these instructions? If I want to call the MessageBox API function for example, what does the instruction look like? Thanks.
Alon Gubkin
  • 53,054
  • 52
  • 181
  • 282
15
votes
1 answer

What are the semantics of ADRP and ADRL instructions in ARM assembly?

ADRP Address of 4KB page at a PC-relative offset. ADRL Load a PC-relative address into a register. It is similar to the ADR instruction. ADRL can load a wider range of addresses than ADR because it generates two data processing…
Holmes.Sherlock
  • 1,693
  • 1
  • 20
  • 29
1
2 3
34 35