Assembly Language Basic Instruction

Source: Internet
Author: User
Tags integer division ultraedit

Assembly Language Basic Instruction
I. Mechanical code, also known as machine code.
UltraEdit Open, edit exe file when you will see
Many of the digital 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f, these digital
is the machine code.
The EXE file must be modified by modifying the machine code when modifying the program.

Two. All compilation knowledge required for proficiency (only so much)
It is not easy to understand, you can first forcibly back, mixed face ripe, and then slowly understand
CMP a A vs. B comparison
MOV a b sends the value of a to a
RET Back to Main program
NOP no effect, English "no operation" shorthand, meaning "donothing" (Machine code 90) * * * The meaning of machine code see above
(Explanation: UltraEdit Open Edit exe file when you see 90, equivalent to assembly statement NOP)
Call subroutine
Je or jz if equal jump (machine code 74 or 0F84)
Jne or jnz if not equal jump (machine code 75 or 0F85)
JMP Unconditional Jump (machine code EB)
If JB is smaller then jump
If JA is greater then jump
If the JG is greater than the jump
Jge if it is greater than or equal to jump
If the JL is less than the jump
Jle if less than equals jumps
Pop out of the stack
Push pressure stack

Three. Common changes (machine code)
74=>75 74=>9074=>eb
75=>74 75=>9075=>eb

Jnz->nop
75->90 (corresponding machine code modification)

JNZ, JMP
EB (corresponding machine code modification)

JNZ-JZ
75->74 (normal) 0F 0f84 (special case, sometimes, the corresponding machine code modification)

Four. Different modification methods for two different situations
1. Change to JMP
Je (jne,jz,jnz) =>jmp corresponding machine code EB (Error message up to the first jump) the role of JMP is to absolutely jump, unconditionally jump, skipping the following error message

XXXXXXXXXXXX error message, for example: Wrong registration code, sorry, not registered version cannot ..., "Function not avaible Indemo" or "Command not avaible" or "Can" save in Shareware/ Demo "etc (we want to skip it and not let it appear)
。。。
。。。
Xxxxxxxxxxxx correct route

2. Change to NOP
Je (jne,jz,jnz) =>nop the corresponding machine code 90 (correct information to find the first jump) the role of NOP is to erase this jump, so that the jump is invalid, lose function, so that the program smoothly came to the correct information immediately after

Xxxxxxxxxxxx the correct information, for example: registration success, thank you for your support and so on (we hope it will not be skipped, let it appear, the program must come here smoothly)
。。。
。。。
XXXXXXXXXXXX error message (We hope not to jump here and not let it appear) they transmit data between the memory and registers, registers, and input and output ports.
1. Generic data transfer instructions.
MOV transmits word or byte.
MOVSX the first symbol extension, then transfer.
MOVZX First Zero expansion, then transfer.
Push presses the word into the stack.
Pop the word pop-up stack.
Pusha the Ax,cx,dx,bx,sp,bp,si,di into the stack in turn.
POPA the Di,si,bp,sp,bx,dx,cx,ax to pop the stack in turn.
Pushad the Eax,ecx,edx,ebx,esp,ebp,esi,edi into the stack in turn.
Popad the Edi,esi,ebp,esp,ebx,edx,ecx,eax to pop the stack in turn.
Bswap switching the order of bytes in a 32-bit register
XCHG the interchange word or byte. (at least one operand is a register, and the segment register is not available as the operand)
CMPXCHG compare and swap operands. (The second operand must be an accumulator al/ax/eax)
XADD first exchange and then accumulate. (results in the first operand)
XLAT byte look-up table conversion.
--BX points to the starting point of a 256-byte table, and AL is the index value of the table (0-255, which is
0-FFH); Return to AL for table results. ([Bx+al]->al)
2. Input and output port transfer instructions.
In I/O port input. (Syntax: In accumulator, {port number │DX})
Out of the I/O port. (Syntax: Out {port number │DX}, accumulator)
When the input/output port is specified by an immediate method, its range is 0-255; When specified by the Register DX,
Its range is 0-65535.
3. Destination address delivery instructions.
The LEA loads a valid address.
Example: LEA dx,string; Save the offset address to DX.
LDS transmits the target pointer and loads the contents of the pointer into the DS.
Example: LDS si,string; save segment Address: Offset address to ds:si.
LES transmits the target pointer and loads the contents of the pointer into ES.
Example: LES di,string; add segment Address: offset address to ESI.
The LFS transmits the target pointer and loads the pointer contents into FS.
Example: LFS di,string; add segment Address: Offset address to FSI.
LGS transmits the target pointer and loads the contents of the pointer into the GS.
Example: LGS di,string; save segment Address: Offset address to a GSI.
LSS transmits the target pointer and loads the contents of the pointer into the SS.
Example: LSS di,string; add segment Address: Offset address to SSI.
4. Flag delivery instructions.
LAHF Flag Register Transfer, mount the flag in AH.
The SAHF flags register is transmitted and the AH content is loaded into the flag register.
PUSHF flag into the stack.
Popf flag out of the stack.
PUSHD 32-bit flag into the stack.
POPD 32-bit flag out of the stack.

Second, arithmetic operation instruction
Add addition.
The ADC carries a carry addition.
INC plus 1.
ASCII code adjustment for AAA addition.
The decimal adjustment of the DAA addition.
SUB subtraction.
SBB with borrow subtraction.
DEC minus 1.
NEC negation (minus 0).
CMP comparison. (two operands are subtracted, only the flag bit is modified, the result is not echoed).
The ASCII code adjustment of AAS subtraction.
The decimal adjustment of the DAS subtraction.
MUL unsigned multiplication.
Imul integer multiplication.
Above two, results echo Ah and Al (Byte operations), or DX and ax (word arithmetic),
The ASCII code of AAM multiplication is adjusted.
DIV unsigned division.
Idiv integer division.
Above two, result loopback:
Quotient Loopback al, remainder loopback ah, (byte operation);
or quotient loopback ax, remainder loopback DX, (Word arithmetic).
The ASCII code adjustment of the AAD division.
The CBW byte is converted to a word. (Extend the byte symbol in AL to AH)
The CWD word is converted to double word. (Extend the symbols in ax to the DX)
The Cwde word is converted to double word. (Extend the word symbol in AX to EAX)
CDQ double word extension. (Extend the symbols in the EAX to edx)

Three, the logic operation instruction
And and operations.
or OR operation.
XOR is different or operation.
Not negate.
Test. (two operand and operation, only change the flag bit, do not echo the result).
SHL logical left shift.
SAL arithmetic left shift. (=SHL)
The SHR logic shifts right.
SAR arithmetic right shift. (=SHR)
ROL the loop left shift.
ROR loop right.
RCL the loop left through the rounding.
The RCR is shifted right through the carry loop.
The above eight shift instructions, the number of shifts can be up to 255 times.
When a shift is made, the operation code can be used directly. such as SHL ax,1.
When the shift >1 times, the number of shifts is given by the Register CL.
such as MOV cl,04
SHL AX,CL

Iv. sequence of instructions
Ds:si Source String Segment Register: source string variable address.
ESI Target string Segment register: Destination string variable address.
CX Repeat Count counter.
Al/ax Scan value.
D flag 0 means that the SI and di should be automatically increment in the repetitive operation; 1 indicates that the amount should be automatically reduced.
The z flag is used to control the end of a scan or comparison operation.
MOVS string Transfer.
(MOVSB transmits characters.) MOVSW transfer Word. MOVSD transmits double word. )
CMPS string comparison.
(CMPSB compare characters.) CMPSW comparison word. )
SCAS string Scan.
Compare the content of the AL or ax with the target string, and the comparison results are reflected in the flag bit.
LODs loading a string.
Load elements (words or bytes) from the source string into either Al or Ax.
(LODSB transmits characters.) LODSW transfer Word. LODSD transmits double word. )
STOs Save the string.
is the inverse process of lods.
REP repeats when cx/ecx0.
REPE/REPZ when the zf=1 or comparison result is equal, and the cx/ecx0 is repeated.
REPNE/REPNZ when zf=0 or comparison results are not equal, and cx/ecx0 is repeated.
Repc when Cf=1 and cx/ecx0 are repeated.
REPNC when Cf=0 and cx/ecx0 are repeated.

V. Procedure Transfer Instruction
1> Unconditional transfer instruction (long transfer)
JMP Unconditional Transfer Instructions
Call procedure Calls
The RET/RETF process returns.
2> Conditional transfer instruction (short transfer, 128 to +127 in distance)
OP1 loop control instruction (short transfer) (when and only if (SF XOR of) =1
Loop CX does not cycle at zero.
Loope/loopz CX is not zero and the flag is z=1 when looping.
LOOPNE/LOOPNZ CX is not zero and the flag is z=0 when looping.
JCXZ CX is shifted at zero.
The JECXZ ecx is shifted at zero.
4> Interrupt Instruction
INT Interrupt Instruction
Into overflow interrupt
IRET Interrupt Return
5> Processor Control Instructions
The HLT processor pauses until an interrupt or reset signal is present to continue.
Wait when the chip lead test is high and the CPU goes into a wait state.
ESC transitions to the outer processor.
Lock blocks the bus.
NOP empty operation.
STC place carry flag bit.
CLC clear carry flag bit.
The CMC carry flag is reversed.
STD set direction flag bit.
CLD clear direction flag bit.
STI place interrupt allow bit.
The CLI cleared interrupt allow bit.

VI. Pseudo-directive
DW definition Word (2 bytes).
PROC defines the process.
The ENDP process is complete.
SEGMENT defines a segment.
Assume establishes segment register addressing.
End of ENDS segment.
End program ends.

Assembly Language Basic Instruction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.