PDA

View Full Version : Tìm hiểu về ngôn ngữ ASM



freewarez
08-06-2004, 01:00
ASM data conversion (by zombie)

Data conversion instructions change data from one format to another.

A sign extension operation takes a small value and sign extends it to a larger storage format (such as byte to word).

A type conversion operation changes data from one format to another (such as signed two’s complement integer into binary coded decimal).
EXT Sign Extend; Motorola 680x0, Motorola 68300; sign extends a byte (8 bits) in a data register to a word (16 bits) or sign extends a word (16 bits) in a data register to a longword (32 bits); sets or clears flags
CVT Convert; DEC VAX; converts a signed quantity to a different signed data type, source and destination in register or memory, special rounded versions for certain floating conversions; sets or clears flags
CVTBW Convert Byte to Word; sign extend
CVTBL Convert Byte to Long; sign extend
CVTWB Convert Word to Byte; truncated
CVTWL Convert Word to Long; sign extend
CVTLB Convert Long to Byte; truncated
CVTLW Convert Long to Word; truncated
CVTBF Convert Byte to Floating; exact
CVTBD Convert Byte to Double float; exact
CVTWF Convert Word to Floating; exact
CVTWD Convert Word to Double float; exact
CVTLF Convert Long to Floating; rounded
CVTLD Convert Long to Double float; exact
CVTFB Convert Floating to Byte; truncated
CVTDB Convert Double float to Byte; truncated
CVTFW Convert Floating to Word; truncated
CVTDW Convert Double float to Word; truncated
CVTFL Convert Floating to Long; truncated
CVTRFL Convert Rounded Floating to Long; rounded
CVTDL Convert Double float to Long; truncated
CVTRDL Convert Rounded Double float to Long; rounded
CVTFD Convert Floating to Double float; exact
CVTDF Convert Double float to Floating; rounded
CBW Convert Byte to Word; Intel 80x86; sign extends a byte (8 bits) in register AL to create a word (16 bits) in the AX register; does not affect flags
CWD Convert Word to Doubleword; Intel 80x86; sign extends a word (16 bits) in register AX throughout the DX register to create a doubleword (32 bits); does not affect flags
CWDE Convert Word to Doubleword Extended; Intel 80386; sign extends a word (16 bits) in register AX to create a doubleword (32 bits) in the EAX register; does not affect flags
CDQ Convert Doubleword to Quadword; Intel 80386; sign extends a doubleword (32 bits) in register EAX to create a quadword (64 bits) in the EDX register; does not affect flags
EXTB Sign Extend Byte; Motorola 680x0, Motorola 68300; sign extends a byte (8 bits) in a data register to a longword (32 bits); sets or clears flags
MOVSX Move with Sign Extension; Intel 80x86; moves data from a register or memory to a register, with a sign extension (conversion to larger binary integer: byte to word, byte to doubleword, or word to doubleword); does not affect flags
MOVZX Move with Zero Extension; Intel 80x86; moves data from a register or memory to a register, with a zero extension (conversion to larger binary integer: byte to word, byte to doubleword, or word to doubleword); does not affect flags
MOVZ Move Zero Extended; DEC VAX; converts an unsigned integer to a larger unsigned integer, source and destination in register or memory (MOVZBW Byte to Word, MOVZBL Byte to Long, MOVZWL Word to Long); sets or clears flags
NUM Convert to Numeric; MIX; converts byte encoded character code (MIX character code) in A-register/X-register pair to numeric data in the A-register (accumulator), does not change sign, overflow possible
CHAR Convert to Characters; MIX; converts numeric data in the A-register (accumulator) into byte encoded character code (MIX character code) in A-register/X-register pair, does not change signs
PACK Pack; Motorola 680x0; converts byte encoded numeric data (such as ASCII or EBCDIC characters) into binary coded decimals using an adjustment field ($3030 for ASCII, $F0F0 for EBCDIC), either from data register to data register or memory location to memory location with predecrement of address pointers; does not modify flags
UNPK Unpack; Motorola 680x0; converts binary coded decimals into byte encoded numeric data (such as ASCII or EBCDIC characters) using an adjustment field ($3030 for ASCII, $F0F0 for EBCDIC), either from data register to data register or memory location to memory location with predecrement of address pointers; does not modify flags

freewarez
08-06-2004, 01:05
Tài liệu ASM:
http://www.woodmann.net/krobar/beginner/69.htm
http://webster.cs.ucr.edu/AoA/Windows/HTML...lStructsa2.html
http://www.woodmann.com/crackz/Tutorials/Drme2.htm
http://www.osdata.com/topic/language/asm/convert.htm
http://www.dpgraph.com/assembly.html
http://doc.ddart.net/asm/Microsoft_MASM_Pr...ers_Guide_v6.1/
================================================== ======

Data Types in Assembly
bit - smallest type that can be two values ex. 1, 2

nibble - four bits has 16 values ex. 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

byte - Most important data type - 8 bits - smallest addresable data item, bit inside are numbered from 7 - 0, 0 being low order bit and least significant, 1 being the high order bit and the most significant, contains 2 nibbles upper and lower, require 2 hex values, rages from 0 - 255.

word - contains 16 bits 0 - 15, 0 low order, 15 being high order, contains 2 bytes (low and high). Used for integer, offsets, segment values. The range is from 0 - 65,536 or signed -32,768 to 32,767.

dword - or double word, 2 words, 32bit, used maily for segmented adresses, but can also be used for 32bit integer ranging from 0 - 4,294,967,295 or signed -2,147,483,648 to 2,147,483,647, can also be used for 32bit floating point values.

Definitions
Monadic operation - means it accepts only one operand.

Signed numbers are - and +.

freewarez
08-06-2004, 01:06
Assembly Programming Language Quick Reference
Instructions
AAA - Ascii Adjust for Addition
AAD - Ascii Adjust for Division
AAM - Ascii Adjust for Multiplication
AAS - Ascii Adjust for Subtraction
ADC - Add With Carry
ADD - Arithmetic Addition
AND - Logical And
ARPL - Adjusted Requested Privilege Level of Selector (286+ PM)
BOUND - Array Index Bound Check (80188+)
BSF - Bit Scan Forward (386+)
BSR - Bit Scan Reverse (386+)
BSWAP - Byte Swap (486+)
BT - Bit Test (386+) BTC - Bit Test with Compliment (386+
BTR - Bit Test with Reset (386+)
BTS - Bit Test and Set (386+)
CALL - Procedure Call
CBW - Convert Byte to Word
CDQ - Convert Double to Quad (386+)
CLC - Clear Carry
CLD - Clear Direction Flag
CLI - Clear Interrupt Flag (disable)
CLTS - Clear Task Switched Flag (286+ privileged).
CMC - Complement Carry Flag
CMP - Compare
CMPS - Compare String (Byte, Word or Doubleword)
CMPXCHG - Compare and Exchange
CWD - Convert Word to Doubleword
CWDE - Convert Word to Extended Doubleword (386+)
DAA - Decimal Adjust for Addition
DAS - Decimal Adjust for Subtraction
DEC - Decrement.
DIV - Divide
ENTER - Make Stack Frame (80188+)
ESC - Escape
HLT - Halt CPU
IDIV - Signed Integer Division
IMUL - Signed Multiply
IN - Input Byte or Word From Port
INC - Increment
INS - Input String from Port (80188+)
INT - Interrupt
INTO - Interrupt on Overflow
INVD - Invalidate Cache (486+)
INVLPG - Invalidate Translation Look-Aside Buffer Entry (486+)
IRET/IRETD - Interrupt Return.
Jxx - Jump Instructions Table.
JCXZ/JECXZ - Jump if Register (E)CX is Zero
JMP - Unconditional Jump
LAHF - Load Register AH From Flags
LAR - Load Access Rights (286+ protected)
LDS - Load Pointer Using DS
LEA - Load Effective Address
LEAVE - Restore Stack for Procedure Exit (80188+)
LES - Load Pointer Using ES
LFS - Load Pointer Using FS (386+)
LGDT - Load Global Descriptor Table (286+ privileged)
LIDT - Load Interrupt Descriptor Table (286+ privileged)
LGS - Load Pointer Using GS (386+)
LLDT - Load Local Descriptor Table (286+ privileged)
LMSW - Load Machine Status Word (286+ privileged)
LOCK - Lock Bus
LODS - Load String (Byte, Word or Double)
LOOP - Decrement CX and Loop if CX Not Zero
LOOPE/LOOPZ - Loop While Equal / Loop While Zero
LOOPNZ/LOOPNE - Loop While Not Zero / Loop While Not Equal
LSL - Load Segment Limit (286+ protected)
LSS - Load Pointer Using SS (386+)
LTR - Load Task Register (286+ privileged)
MOV - Move Byte or Word
MOVS - Move String (Byte or Word)
MOVSX - Move with Sign Extend (386+)
MOVZX - Move with Zero Extend (386+)
MUL - Unsigned Multiply
NEG - Two's Complement Negation
NOP - No Operation (90h)
NOT - One's Compliment Negation (Logical NOT)
OR - Inclusive Logical OR
OUT - Output Data to Port.
OUTS - Output String to Port (80188+)
POP - Pop Word off Stack
POPA/POPAD - Pop All Registers onto Stack (80188+)
POPF/POPFD - Pop Flags off Stack
PUSH - Push Word onto Stack
PUSHA/PUSHAD - Push All Registers onto Stack (80188+)
PUSHF/PUSHFD - Push Flags onto Stack
RCL - Rotate Through Carry Left.
RCR - Rotate Through Carry Right
REP - Repeat String Operation
REPE/REPZ - Repeat Equal / Repeat Zero
REPNE/REPNZ - Repeat Not Equal / Repeat Not Zero
RET/RETF - Return From Procedure
ROL - Rotate Left.
ROR - Rotate Right
SAHF - Store AH Register into FLAGS
SAL - Shift Arithmetic Left / Shift Logical Left
SAR - Shift Arithmetic Right
SBB - Subtract with Borrow/Carry
SCAS - Scan String (Byte, Word or Doubleword)
SETAE/SETNB - Set if Above or Equal / Set if Not Below (386+)
SETB/SETNAE - Set if Below / Set if Not Above or Equal (386+)
SETBE/SETNA - Set if Below or Equal / Set if Not Above (386+)
SETE/SETZ - Set if Equal / Set if Zero (386+)
SETNE/SETNZ - Set if Not Equal / Set if Not Zero (386+)
SETL/SETNGE - Set if Less / Set if Not Greater or Equal (386+)
SETGE/SETNL - Set if Greater or Equal / Set if Not Less (386+)
SETLE/SETNG - Set if Less or Equal / Set if Not greater or Equal (386+)
SETG/SETNLE - Set if Greater / Set if Not Less or Equal (386+)
SETS - Set if Signed (386+)
SETNS - Set if Not Signed (386+)
SETC - Set if Carry (386+)
SETNC - Set if Not Carry (386+)
SETO - Set if Overflow (386+)
SETNO - Set if Not Overflow (386+)
SETP/SETPE - Set if Parity / Set if Parity Even (386+)
SETNP/SETPO - Set if No Parity / Set if Parity Odd (386+)
SGDT - Store Global Descriptor Table (286+ privileged)
SIDT - Store Interrupt Descriptor Table (286+ privileged)
SHL - Shift Logical Left
SHR - Shift Logical Right
SHLD/SHRD - Double Precision Shift (386+)
SLDT - Store Local Descriptor Table (286+ privileged)
SMSW - Store Machine Status Word (286+ privileged)
STC - Set Carry
STD - Set Direction Flag
STI - Set Interrupt Flag (Enable Interrupts)
STOS - Store String (Byte, Word or Doubleword)
STR - Store Task Register (286+ privileged)
SUB - Subtract
TEST - Test For Bit Pattern
VERR - Verify Read (286+ protected)
VERW - Verify Write (286+ protected)
WAIT/FWAIT - Event Wait
WBINVD - Write-Back and Invalidate Cache (486+)
XCHG - Exchange
XLAT/XLATB - Translate
XOR - Exclusive OR

JA Jumps if the first number was above the second number
JAE same as above, but will also jump if they are equal
JB jumps if the first number was below the second
JBE Same as above, but will also jump if they are equal
JNA jumps if the first number was NOT above (JBE)
JNAE jumps if TDe first number was NOT above or TDe same as (JNB)
JNB jumps if the first number was NOT below (JAE)
JNBE jumps if the first number was NOT below or the same as (JA)
JZ jumps if the two numbers were equal
JE same as JZ, just a different name
JNZ jumps if the two numbers are NOT equal
JNE same as above
JC jump if carry flag is set
Note: the jump can only be a maximum of 127 bytes in either direction.

freewarez
08-06-2004, 01:11
Assembly Language Reference
Compiled by Dr. ME!
------------------------------------
LDS


LDS Load Pointer using DS
LDS des-reg, source
Logic: DS LES, Load Pointer Using ES, is a comparable instruction that loads the
ES register rather than the DS register.


Example:


var1 dd 25,00,40,20
..
..


Before LDS


DX = 0000
DS = 11F5


LDS DX,var1


After LDS


DX = 0025
DS = 2040

------------------------------------
LES
LES Load Pointer using ES
LES des-reg, source
Logic: ES LDS, Load Pointer Using DS, is a comparable instruction that loads the
DS register rather than the ES register.

------------------------------------
LODS
LODS source_string
Logic: Accumulator

------------------------------------
LODSB
Load String Byte
LODSB
Logic: al

------------------------------------
LODSW
Load String Word
LODSW
Logic: ax LODS can use REP/REPE/REPNE/REPZ/REPNZ to move several
bytes or words

------------------------------------
STOS
STOS (store to string) moves a byte (or a word) from AL (or AX) to ES:[di], and
increments (or decrements) DI depending on the setting of DF, the direction flag
(by 1 for bytes and by 2 for words). NO OVERRIDES ARE ALLOWED. This performs the
same action (except for changing DI) as:


mov ES:[DI], ax ; or AL for bytes


The allowable forms are:


stosb
stosw
stos BYTE PTR ES:[di] ; no override allowed
stos WORD PTR ES:[di] ; no override allowed

------------------------------------
SCAS
SCAS compares AL (or AX) to the byte (or word) pointed to by ES:[di], and
increments (or decrements) DI depending on the setting of DF, the direction flag
(by 1 for bytes and by 2 for words). NO OVERRIDES ARE ALLOWED. This sets the flags
the same way as:


cmp ax, ES:[DI] ; or AL for bytes


The allowable forms are:


scasb
scasw
scas BYTE PTR ES:[di] ; no override allowed
scas WORD PTR ES:[di] ; no override allowed

------------------------------------
SET
SET destination
Logic: If condition, then destination SET Instruction Flags Explanation

SETB/SETNAE CF = 1 Set if Below/Not Above or Equal


SETAE/SETNB CF = 0 Set if Above or Equal/Not Below


SETBE/SETNA CF = 1 or Set if Below or Equal/Not Above
ZF = 1


SETA/SETNBE CF = 0 and Set if Above/Not Below or Equal
ZF = 0


SETE/SETZ ZF = 1 Set if Equal/Zero


SETNE/SETNZ ZF = 0 Set if Not Equal/Not Zero


SETL/SETNGE SF OF Set if Less/Not Greater or Equal


SETGE/SETNL SF = OF Set if Greater or Equal/Not Less


SETLE/SETNG ZF = 1 or Set if Less or Equal/Not Greater
SF OF


SETG/SETNLE ZF = 0 or
SF = OF Set if Greater/Not Less or Equal


SETS SF = 1 Set if Sign


SETNS SF = 0 Set if No Sign


SETC CF = 1 Set if Carry


SETNC CF = 0 Set if No Carry


SETO OF = 1 Set if Overflow


SETNO OF = 0 Set if No Overflow


SETP/SETPE PF = 1 Set if Parity/Parity Even


SETNP/SETPO PF = 0 Set if No Parity/Parity Odd


destination can be either a byte-long register or memory location.


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