Questions tagged [machine-code]

Machine code is data that is directly fed into a microprocessor, being the only form that the processor is able to execute. It is the lowest possible level of abstraction, wherein all data is a raw binary stream. Machine code is barely readable by humans, which is why assembly is usually utilized instead.

Every processor or processor family has its own instruction set. This is a set of instructions the processor has been designed to execute. These instructions are binary codes and in general are not human readable, one would have to memorize the bit patterns. Assembly language is a human readable representation of the machine code where the assembly language mnemonics and following syntax attempt a one to one assembly language instruction to machine code instruction relationship. But assembly language has a fair amount of additional syntax that is not directly related to machine code or machine language.

https://en.wikipedia.org/wiki/Machine_code

The tag is used for questions related to machine code. Additional tags like and and others may also be used.

A tag specifying the architecture , , , , (and many others), is needed as the machine code for different architectures is not compatible, and the question will be difficult to answer without knowing the architecture.

766 questions
10
votes
1 answer

What is the significance of operations on the register EAX having their own opcodes?

If you look at documentation of operations like cmp, test, add, sub, and and, you will notice that operations that involve register EAX and its 16 and 8 bit variants as the first operand have a distinct opcode which is different from the "general…
Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
10
votes
1 answer

What does "CPU performs an endless jump" mean?

I was reading this: https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf And I read on page 8 the following: e9 fd ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 00 00 00 00 00 00 00 00…
Luna
  • 193
  • 1
  • 9
10
votes
2 answers

MARS disassembly of BEQ shows a number as the branch target. What does it mean?

I have copied a picture of an assignment I have on MIPS assembly. I understand (I think) what happens in the code until the line: beq $11, $0, 3 I understand that the code now makes a PC-RELATIVE branch for the address: PC+4+3*4 But I don't…
Assaf
  • 1,112
  • 4
  • 14
  • 35
10
votes
3 answers

Compiling high-level language to machine code

After reading some answers from the site and viewing some sources, I thought that the compiler converts high-level language (C++ as an example) to machine code directly as the computer itself doesn't need to convert it to assembly, it only converts…
Karim K.
  • 361
  • 2
  • 4
  • 9
10
votes
8 answers

Why aren't EXE's in binary?

Why is it that if you open up an EXE in a hex editor, you will see all sorts of things. If computers only understand binary then shouldn't there only be 2 possible symbols seen in the file? Thanks
jmasterx
  • 52,639
  • 96
  • 311
  • 557
10
votes
1 answer

Levels of Homoiconicity

This is a follow up to my previous question. I’m not convinced that Lisp code is as Homoiconic as machine code on a Von Neumann architecture. It seems obvious to me that in both cases code is represented as data, but it also seems apparent that you…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
9
votes
4 answers

In x86 assembly how can you set the zero flag (ZF) without doing a compare operation?

I have a short piece of (x86) assembly that I am trying to figure out what it does. ... 6: 81 ec 00 01 00 00 sub $0x100, %esp c: 31 c9 xor %ecx , %ecx e: 88 0c 0c mov %cl , (%esp,…
Robert
  • 37,670
  • 37
  • 171
  • 213
9
votes
2 answers

What does func means in R-Format instruction set?

I am very new to Assembly language. I was reading about MIPS architecture and I am stuck with the last field of the Register Format (R-Format). Here is its visual representation, Can anyone please help me out with what does the sixth field means…
user379888
9
votes
1 answer

Why was NOP assigned to 0x90 in x86 assembly?

Why was nop assigned to 0x90 on intel x86 assembly? Intuitively I would expect that 0x00 would map to nop (which is also xchg eax, eax at intel x86) as it is the case for ARM A32 and some other architectures.
Jonas Stein
  • 6,826
  • 7
  • 40
  • 72
9
votes
2 answers

Is it possible to decode x86-64 instructions in reverse?

I was wondering if it is possible to decode x86-64 instructions in reverse? I need this for a runtime dissembler. Users can point to a random location in memory and then should be able to scroll upwards and see what instructions came before the…
user3696459
  • 139
  • 5
9
votes
1 answer

How to force NASM to encode [1 + rax*2] as disp32 + index*2 instead of disp8 + base + index?

To efficiently do x = x*10 + 1, it's probably optimal to use lea eax, [rax + rax*4] ; x*=5 lea eax, [1 + rax*2] ; x = x*2 + 1 3-component LEA has higher latency on modern Intel CPUs, e.g. 3 cycles vs. 1 on Sandybridge-family, so disp32 +…
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
9
votes
2 answers

Combining prefixes in SSE

In SSE the prefixes 066h (operand size override) 0F2H (REPNE) and 0F3h (REPE) are part of the opcode. In non-SSE 066h switches between 32-bit (or 64-bit) and 16-bit operation. 0F2h and 0F3h are used for string operations. They can be combined so…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
9
votes
4 answers

Get size of assembly instructions

I need to read instructions one-by-one from a small code segment in memory and I have to find out the size of the instructions which I have in memory. The following is just a example of raw disassembled code to explain my problem: (gdb) disas /r…
tifa
  • 216
  • 2
  • 6
9
votes
3 answers

What does actual machine code look like at various points?

There seems to be many opinions on what machine code actually is. I've heard some say it's assembly, or binary, or hex. Is it correct to say that machine code is essentially a set of instructions for a particular processor? If so, I imagine these…
Igorio
  • 918
  • 1
  • 7
  • 17
8
votes
4 answers

How long does each machine language instruction take to execute?

Do operations like set, read, move and compare all take the same time to execute? If not: Is there any way to find out how long. Is there some name for what I mean, some specific type cpu's speed of executing the different assembly language…
xrDDDD
  • 583
  • 9
  • 23