News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

what is opcode?

Started by easypie, October 17, 2011, 05:58:03 AM

Previous topic - Next topic

easypie

I can't seem to find out what opcode is. I've glean through the book but no luck. Can someone point me to a page number or chapter in the AOA book?

jj2007

\masm32\help\opcodes.chm is a good start :bg

dedndave

also, the Intel Software Programmer's Manuals - available as PDF's from Intel for free   :U

FORTRANS

Hi,

   If you look at an assembly language reference, you might
see something like the following (portion from a TASM reference):


HLT     Halt

opcode  Instruction
F4      HLT

HLT stops instuction execution ...


   So the opcode is the machine language representation of an
instruction.  (Operation machine code?)

Regards,

Steve N.

hutch--

I think he is asking a different question o the ones being answered. the words OPCODE means no more than an instruction hard wired into a computer processor. It is usually just a number called in sequence by running programs. The instructions have by convention been given NAMES so they are easier to use, they are usually referred to as MNEMONICS which simply means NAMES.

A single MNEMONIC can have different OPCODES, (IE:Instruction numbers).


mov eax, eax
mov memory, eax
mov eax, memory


Each line here has the same MNEMONIC "MOV" but some mnemonics like MOV and others have more that 1 OPCODE, that is because they do different things that are SIMILAR but not the SAME.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

And to illustrate, if I place the three MOV examples in this short program:

include \masm32\include\masm32rt.inc
.data
    mem dd 0
.code
start:
    mov eax, eax
    mov mem, eax
    mov eax, mem
    exit
end start


And assemble and link it to an EXE and then disassemble the EXE, I get:

00401000                    start:
00401000 8BC0                   mov     eax,eax
00401002 A300304000             mov     [403000h],eax
00401007 A100304000             mov     eax,[403000h]
0040100C 6A00                   push    0
0040100E E801000000             call    fn_00401014
00401013 CC                     int     3
00401014                    fn_00401014:
00401014 FF2500204000           jmp     dword ptr [ExitProcess]


For the three MOV instructions the instruction opcodes are the first byte, with the values 8Bh, A3h, and A1h, and the bytes that follow are the operands. Note that opcodes can be longer than one byte.
eschew obfuscation