Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hexadecimal value of opcodes

I created a very simple assembly program that prints the letter 'a' in DOS. I opened it in a hex editor and the result was this:

Assembly code:

mov ah, 2 
mov dx, 'a' 
int 21h 

Hex code

B4 02 B2 61 CD 21

I wanted to understand how it was generated! Like, I do not know if I'm right, but I realized that:

B4 = mov ah 
02 = 2 
B2 = mov dx 
61 = 'a' 
CD = int 
21h = 21

The 02, 61 and 21 I understood what turned but and B4, B2 and CD?

like image 638
user3500017 Avatar asked Apr 05 '14 20:04

user3500017


People also ask

Are opcodes in hexadecimal?

Opcodes are decimal and not hex.

What is opcode example?

Opcode definition A complete machine language instruction consists of an opcode and zero or more operands with which the specified operation is performed. Examples are “add memory location A to memory location B,” or “store the number five in memory location C.” “Add” and “Store” are the opcodes in these examples.

What do you mean by opcode?

In computing, an opcode (abbreviated from operation code, also known as instruction machine code, instruction code, instruction syllable, instruction parcel or opstring) is the portion of a machine language instruction that specifies the operation to be performed.

What is an opcode in assembly language?

The opcode is the instruction that is executed by the CPU and the operand is the data or memory location used to execute that instruction.


1 Answers

Here's a nice reference: http://ref.x86asm.net/coder32.html

As you can see:

  • CD is the opcode for int
  • B0+reg is the opcode for mov reg, imm8, where reg is the destination register and as you can see from this table, ah = 100b and dx = 010b
like image 62
pNre Avatar answered Oct 31 '22 15:10

pNre