hexadecimal value of opcodes
23,809
Solution 1
Here's a nice reference: http://ref.x86asm.net/coder32.html
As you can see:
-
CD
is the opcode forint
-
B0+reg
is the opcode formov reg, imm8
, wherereg
is the destination register and as you can see from this table,ah = 100b
anddx = 010b
Solution 2
Are Assembly x86 instructions:
- B4: mov ah mean move in the register ah
- B2: mov dx mean move in the register dx
- CD: int means software interrupt
I recommend you read this guide assembly x86 http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
Author by
user3500017
Updated on April 06, 2020Comments
-
user3500017 about 4 years
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
and21
I understood what turned but andB4
,B2
andCD
?-
pasztorpisti about 10 yearsThe official docs: intel.com/content/www/us/en/processors/… If you are interested only in "instruction opcodes", the bytes into which different instructions are encoded then on the previously linked site start with this document: "Manual Volume 2A: Instruction Set Reference, A-M" The site linked by an answer below (ref.x86asm.net/coder32.html) is a very good summary/overview of the intel PDFs but read the intel docs to learn the exact behavior of instructions.
-
pasztorpisti about 10 yearsBTW, if you are thinking about playing around with assembly and maybe with disassembling/reverse engineering then try the best disassembler/debugger of all times, it has a free version (5.0) that knows much less then the newer versions but even this old free version can kick the ass of any other solution: hex-rays.com/products/ida/support/download_freeware.shtml It can come handy in analyzing stuff.
-
-
Sourav Kannantha B about 3 yearssince there are 16 general purpose registers, it would require 4 bits to encode them.. isn't it?
-
Sourav Kannantha B about 3 yearsin the reference you provided, they have given opcodes and equivalent hex values. But I am not understanding how to combine them to obtain valid instruction. For eg, 0x817 corresponds to cmp, and 0x5 corresponds to reg ebp. But with this information, how can I encode
cmp dword [ebp-4] 2
. I have searching through internet for this for around 2 hrs. Help me out!!