Wednesday, July 21, 2010

Assembly instructions and the machine code of each conversion



Machine language to understand what we just focus on several concepts:

1. Machine-language instructions with opcode (OP) and the address code of two parts

|_____________ OP_______________ | __d__ | __w__ |

|_____________ OP_______________ | __s__ | __w__ | <- This format is used for immediate addressing mode


In most operating code, often used to indicate certain information in certain places:
Figure on the structure in the: w = 1 when word operation
w = 0 bytes to operate when

d values in the two-operand instruction to be effective
When d = 1 when and only for the purpose of a register operand
d = 0 from time to time and only one register for the source operands

s = 1 8-bit number immediately, but requires extended to 16 digits
s = 0 age when the operation instruction for byte / a 16-bit immediate

As the assembly instruction format of many, here I introduce some basic information, if necessary, the reader can download / access to 80x86 assembly provided OPCODES small station http://www.x86asm.com manual inspection.

2. Addressing modes of machine language, said:

| Mod | reg | r / m |
|_____|_____|_____|_____|_____|_____|_____|

reg said register means, the number does not include an immediate two-operand instructions circumstances, to require one operand in the register, the register specified by the reg field and with the opcode byte of the w phase composition determined register

mod field and r / m (register / memory) combined with field operations to determine the number of addressing another now that you download the 80x86 assembly small station (http://www.x86asm.com) OPCODES manual provided the it?
Download Well, please open the inside after decompression: opcodes.html file, and then inside the familiar form:

Now familiar with the simple:
______________________________________________________________________________
Table 1 rrr: W = 0: W = 1: reg32

000: AL: AX: EAX

001: CL: CX: ECX

010: DL: DX: EDX

011: BL: BX: EBX

100: AH: SP: ESP

101: CH: BP: EBP

110: DH: SI: ESI

111: BH: DI: EDI
______________________________________________________________________________
Table 2 rrr: Index Register
000: EAX

001: ECX

010: EDX

011: EBX

100: No Index

101: EBP

110: ESI

111: EDI
______________________________________________________________________________
Table 3 mmm: Function 11
w = 1
000: DS: [BX + SI]

001: DS: [BX + DI]

010: SS: [BP + SI]

011: SS: [BP + DI] BX

100: DS: [SI]

101: DS: [DI]

110: SS: [BP]

111: DS: [BX]
______________________________________________________________________________
Table 4
oo: Function

00: If mmm = 110, then a displacement follows the operation; otherwise, no displacement is used

01: An 8-bit signed displacement follows the opcode

10: A 16-bit signed displacement follows the opcode

11: mmm specifies a register, instead of an addressing mode
______________________________________________________________________________
The above table, you see see? Now I teach you how to use this form to the translation of machine code assembly instructions

3. Instruction format Introduction

8086 16-bit instruction format used:

________ _____________ ________ ________
| Opcode | + | mod-reg-r / m | + | displacement | + | immediate |
1 to 2 byte 0 byte 1 byte 0 to 2 0 to 2 bytes


OK! These are the basics, let's practice it:

---------------------------------------
Question:

MOV AX, 1234H corresponding machine code is: B83412

MOV EBX, 0 corresponds to the machine code is: 66BB00000000

MOV CL, 55H corresponding machine code is: B155

MOV AX, BX corresponding machine code is: 8BC3


I ask, machine code data format? Like machine instruction + operand (high stored in the address high, low stored in the address low), but in front of MOV AX, how to become a B8, do not understand this, Please advise.

PS: The above title is a users question, now I come to practice again to you to see.
---------------------------------------

Directive 1 -> MOV AX, 1234H corresponding machine code is: B83412

Solution: check -> This is the 8086 compilation of 16-bit assembly instruction format, and is the immediate addressing mode
Look-up table -> Open opcodes.html file, find the heading "Main Instructions", click the "M" letter, then the corresponding view "MOV Reg, Imm" format "OpCode" item as: 1011wrrr
Then judge -> As the register is AX, the number now is 1234H, is clearly "on the word action", so w = 1
In view of the article above "Table 1", corresponding to a value of 000 found rrr
Combined Results -> w = 1
rrr = 000
1011wrrr = 1011 1000B -> B8H
According to "3. Instruction format profile" -> B8H + | immediate (low in the former high in the post) | = B83412H

PS: "+" sign is not a "plus"

Well, the first question has been completed solution, and machine code for the B83412H

---------------------------------------

Instruction 4 -> MOV AX, BX corresponding machine code is: 8BC3

Solution: check -> This is the 8086 compilation of 16-bit assembly instruction format, and is a register addressing mode
Look-up table -> Open opcodes.html file, find the heading "Main Instructions", click the "M

"Letter, then the corresponding view" MOV Reg, Reg "format" OpCode "item as: 1000101woorrrmmm
Then judge -> As the registers are AX, BX is obviously "on the word action", so w = 1
In view of the article above, "Table 4", corresponding to oo = 11 because it is found in register addressing mode
In view of the article above "Table 1", corresponding to a value of 000 found rrr, because when the two operating

Incline is register, then the general purpose of the operands should prevail
In view of the article above "Table 3", corresponding to a value of 011 found mmm, because when both operands are registers, then usually necessary to subject the source operand
Combined Results -> w = 1
oo = 11
rrr = 000
mmm = 011
1000101woorrrmmm = 1000 1011 1100 0011 B -> 8BC3H

Okay, second question has been completed solution, and machine code for the 8BC3H
---------------------------------------

Oh, yes it is very simple bar, with 80X86 OPCODES query table everything is so simple, if you have any questions, we all come here to ask!

Remaining:

Directive 2 -> MOV EBX, 0 corresponds to the machine code is: 66BB00000000

Directive 3 -> MOV CL, 55H corresponding machine code is: B155

Everyone to practice your hand, pay attention to instruction two need to use 32-bit instruction format, please refer to 80x86 assembly language books related to the machine language part, should be explained.

Solution orders 2, please wait, or we look, the solution posted for your reference Oh!







相关链接:



Silver DVD Editor



Guide Teaching And Training Tools



CaleSoft IPod Video Converter



Best Converters AND Optimizers



Bluesea DVD To WMV



mkv Converter free



Jiangmin Response To The Letter, Said Attorney Alibaba China Lagged Far Behind The Law



convert mp4 to 3gp free



Convert mkv



Movkit Video Pack



WorldCup PDA Converter



About PGP



rmvb



No comments:

Post a Comment