Transcript
Page 1: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Appendix A Assembler and Linker

This course you can use any of the following software:MicroSoft version 3.0 ASSEMBLER : MASM.EXE LINKER : LINK.EXE LIBRARY MANAGEMENT : LIB.EXE UTILITY : EXE2BIN.COMBorland version 4.1 ASSEMBLER : TASM.EXE LINKER : TLINK.EXEPublic Domain (Arrow Soft) arrowsof.zip ASSEMBLER : ASM.EXE LINKER : VAL.EXE UTILITY : X2B.COMAssembling A ProgramMethod 1: assembling without a command line, just enter the assembler name:

MASM ASMSource filename [.ASM]: Input filename

[.asm]:Object filename [filename.OBJ]: Object

filename [filename.obj]:Source listing [NUL.LST]: Source listing

[NUL.lst]:Cross reference [NUL.CRF]: Cross reference

[NUL.crf]: Press Enter if you don’t want to output cross reference file, otherwise enter [drive:]name [.extension]

Press Enter if you don’t want to output listing file, otherwise enter [drive:]name [.extension]

Press Enter if you want object file name as shown, otherwise enter

Computer Science, Prince of Songkhla University

1

Page 2: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________ [drive:]name [.extension]

Enter only name of source or input filename if the extension is .asm, otherwise enter [drive:] name [.extension]

Method 2: assembling with a command line:The general format for using a command line to

assemble is

masm/tasm/asm [options] source [, [object] ][, [listing] ][, [crossref] ] [;]

There are many options (see manual for more information), we will discuss some of them: /MX Make public and external names case sensitive. /ML Make all names case sensitive. /MU Convert all names to uppercase.

Assume source file name is test.asm.

Example 1. masm test,test,test,test or masm test, , , ; or masm test,,,,will produce test.obj, test.lst, test.crf.

Example 2. masm test,test,test; or masm test, ,test;will produce test.obj, test.lst.

Example 3.masm test;will produce only test.obj.

Example 4.masm /MX test;

Computer Science, Prince of Songkhla University

2

Page 3: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Linking a ProgramMethod 1: liking without a command line, just enter the linker name:

LINK VAL Object Modules [.OBJ]: OBJ file(s): RUN File [filename.EXE]: EXE file

[filename.exe]: List File [NUL.MAP]: LST file: Libraries [.LIB]: LIB files:

Note! If there are more than one object modules use + e.g. test1.obj+test2.obj. It is the same for libraries.

Method 2: linking with a command line:The general format for using a command line to link is

link/tlink/val [options] objfile, exefile [, [mapfile] ][, [libraryfile] ] [;]

There are many options (see manual for more information).

Example 1. no library link test,test,test; or link test, , ; will produce test.exe, test.map

Example 2. There are two object files, test1.obj, test2.obj and no library. link test1+test2,test;will produce test.exe.

Computer Science, Prince of Songkhla University

3

Page 4: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________Example 3. There are two object files, test1.obj, test2.obj and one library, mylib.lib. link test1+test2,test,,mylibwill produce test.exe, test.map.

Example 4. There are two object files, test1.obj, test2.obj and two libraries, mylib1.lib, mylib2.lib. link test1+test2,test,,mylib1+mylib2will produce test.exe, test.map.Convert .EXE to .COM

exe2bin/x2b test.exe test.comor use option /t of tlink at linking time, e.g. tlink /t test;

Make a libraryExample 1. To create a new library name mylib and insert test.obj,

libLibrary name: mylibLibrary does not exist. Create? yoperations: testList file:

Example 2. To insert test1.obj and delete test.obj in mylib.lib and make as a new library nmylib.lib.

libLibrary name: myliboperations: test1-testList file: Output Library: nmylib

Note! you may use +objfile to add and –objfile to delete

Computer Science, Prince of Songkhla University

4

Page 5: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Appendix B Reserve Words

Register Names

AH CH DL EDI GS AL CL DS EDX IP AX CS DX EIP SIBH CX EAX ES SP BL DH EBP ES SSBP DI EBX ESI BX DI ECX FS Symbolic Instructions

AAA ARPL CDQ CMPSn ESCAAD BOUND CLC CWDn HLT AAM BSF CLD DAA IDIV AAS BSR CLI DAS IMUL ADC BTn CLTS DEC IN ADD CALL CMC DIV INC AND CBW CMP ENTER INSwINT JNLE LOCK POPAD SCASn INTO JNO LODSn POPF SETnn IRET JNP LOOP POPFD SGDT JA JNS LOOPE PUSH SHL JAE JNZ LOOPNE PUSHAD SHLD JB JO LOOPNZ PUSHF SHR

Computer Science, Prince of Songkhla University

5

Page 6: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________JBE JP LOOPZ PUSHFD SHRDJCXZ JPE LSL RCL SIDT JE JPO LSS RCR SLDT JECXZ JS LSS REN SMSWJG JZ LTR REP STC JGE LAHF MOV REPE STD JL LAR MOVSn REPNE STI JLE LDS MOVSX REPNZ STOSn JMP LEA MOVZX REPZ STR JNA LEAVE MUL RET SUB JNAE LES NEG RETF TEST JNB LFS NOP ROL VERR JNBE LGDT NOT ROR VERRW JNE LGS OR SAHF WAIT JNG LIDT OUTn SAL XCHG JNGE LLDT POP SAR XLAT JNL LMSW POPA SBB XOR

Directives

ALIGN ENDIF IFIDN PUBLIC .ALPHA ENDM IFNB PURGE ASSUME ENDP IFNDEF .RADIX .CODE ENDS INCLUDE RECORD COMM EQU INCLUDELIB REPT COMMENT .ERRnn IRP .SALL .CONST EVEN IRPC SEGMENT .CREF EXITM LABEL .SEQ .DATA EXTRN .LALL .SFCOND .DATA? .FARDATA .LFCOND .STACK DB .FARDATA? .LIST STRUC DD GROUP LOCAL SUBTTL DF IF MACRO .TFCOND DOSSEG IFI .MODEL TITLE DQ IF2 NAME .XALL DT IFB ORG .XCREF

Computer Science, Prince of Songkhla University

6

Page 7: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________DW IFDEF OUT .XLIST ELSE IFDIF PAGE END IFE PROC

Operators

AND HIGH NEAR SHR BYTE LE NOT SIZE COMMENT LENGTH NOTHING STACK CON LINE OFFSET THIS DUP LOW OR TYPE EQ LT PTR WIDTH FAR MASK SEG WORD GE MOD SHL XOR GT NE SHORT

Computer Science, Prince of Songkhla University

7

Page 8: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Appendix C 8086/8088 Mnemonic

___________________________________________________________________________________________mnemonic ชื่อเต็ม mnemonic

ชื่อเต็ม___________________________________________________________________________________________AAA ASCII adjust for addition JNAE Jump on not above or equalAAD ASCII adjust for division JNB Jump on not belowAAM ASCII adjust for multiplication JNBE Jump on not below or equalAAS ASCII adjust for subtraction JNC Jump on not carryADC Add with carry JNE Jump on not equalADD Add JNG Jump on not greaterAND AND JNGEJump on not greater or equalCALLCALL JNL Jump on not less thanCBW Convert byte to word JNLE Jump on not less than or equalCLC Clear carry flag JNO Jump on not overflowCLD Clear direction flag JNP Jump on not parityCLI Clear interrupt flag JNS Jon not signCMC Complement carry flag JNZ Jump on not zeroCMP Compare JO Jump on overflowCMPS Compare byte or word (of string) JP Jump on parityCMPSB Compare byte string JPE Jump on parity even

Computer Science, Prince of Songkhla University

8

Page 9: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________CMPSW Compare word string JPO Jump on parity oddCWDConvert word to double word JS Jump on signDAA Decimal adjust for addition JZ Jump on zeroDAS Decimal adjust for subtraction LAHFLoad AH with flagsDEC Decrement LDS Load pointer into DSDIV Divide LEA Load effective addressESC Escape LES Load pointer into ESHLT Halt LOCK LOCK busIDIV Integer divide LODS Load byte or word (of string)IMULInteger multiply LODSB Load byte (string)IN Input byte or word LOADSW Load word (string)INC Increment LOOP LOOPINT Interrupt LOOPE LOOP while equalINTOInterrupt on overflow LOOPNE LOOP while not equalIRET Interrupt return LOOPNZ LOOP while not zeroJA Jump on above LOOPZ LOOP while zero___________________________________________________________________________________________mnemonic ชื่อเต็ม mnemonic ชื่อเต็ม___________________________________________________________________________________________JBE JAE Jump on above or equal MOV MoveJB Jump on below MOVS Move byte or word (of string)

Computer Science, Prince of Songkhla University

9

Page 10: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________JBE Jump on below or equal MOVSB Move byte (string)JC Jump on carry MOVSW Move word (string)JCXC Jump on CX zero MUL MultiplyJE Jump on equal NEG NegateJG Jump on greater NOP No operationJGE Jump on greater or equal NOT NOTJL Jump on less than OR ORJLE Jump on less than or equal OUT Output byte or wordJMP Jump POP POPJNA Jump on not above POPFPOP flagsPUSH PUSH SHL Shift leftPUSHF PUSH flags SHR Shift rightRCL Rotate through carry left STC Set carry flagRCR Rotate through right STD Set direction flagREP Repeat STI Set interrupt flagRET Return STOS Store byte or word (of string)ROL Rotate left STOSB Store Byte (string)ROR Rotate right STOSW Store word (string)SAHF Store AH into flags SUB SubtractSAL Shift arithmetic left TESTTESTSAR Shift arithmetic right WAIT WAITABB Subtract with borrow XCHG ExchangeSCAS Scan byte or word (of string) XLATTranslateSCASB Scan byte (string) XOR Exclusive ORSCASW Scan word (string)

Computer Science, Prince of Songkhla University

10

Page 11: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Appendix D ASCII Code

7 0 0 0 0 1 1 1 1Bit 6 0 0 1 1 0 0 1 1positions 5 0 1 0 1 0 1 0 14 3 2 10 0 0 0 NUL DLE SP 0 @ P \ p0 0 0 1 SOH DC1 ! 1 A Q a q0 0 1 0 STX DC2 “ 2 B R b R0 0 1 1 ETX DC3 # 3 C S c s0 1 0 0 EOT DC4 $ 4 D T d t0 1 0 1 ENQ NAK % 5 E U e u0 1 1 0 ACK SYN & 6 F V f v0 1 1 1 BEL ETB ‘ 7 G W g w1 0 0 0 BS CAN ( 8 H X h x1 0 0 1 HT EM ) 9 I Y i y1 0 1 0 LF SUB * : J Z j z1 0 1 1 VT ESC + ; K [ k {1 1 0 0 FF FS , < L \ l |

Computer Science, Prince of Songkhla University

11

Page 12: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________1 1 0 1 CR GS - = M ] m }1 1 1 0 SO RS . > N ^ n ~1 1 1 1 SI US / ? O _ o DEL

ตารางขา้งบนแทนอักขระรหสัตัง้แต่ 00000000 ถึง 01111111 ถ้าต้องการใชทั้ง้ 8 บติ รหสัตัง้แต่ 10000000 ถึง 11111111 จะแทนอักขระพเิศษ เชน่ ใชแ้ทนอักขระภาษาไทย เป็นต้น

อักขระท่ีเป็น printable character ได้แก่อักขระ ตัง้แต่ SP (00100000) ถึง~ (0111110) นอกนัน้จะเป็นอักขระที่ใชค้วบคมุ เชน่ CR ใชแ้ทนการสิน้สดุบรรทัด ของระบบปฏิบติั

การ Unix หรอื CR กับ LF แทนการสิน้สดุบรรทัด ของระบบปฏิบติัการ DOS เป็นต้น

ASCII Code

เลขฐานสบิหก ตัวหน้า 0 1 2 3 4 5 6 7 0 NUL DLE SP 0 @ P \ p เลขฐาน 1 SOH DC1 ! 1 A Q a q สบิหก 2 STX DC2 “ 2 B R b R ตัวหลัง 3 ETX DC3 # 3 C S c s 4 EOT DC4 $ 4 D T d t 5 ENQ NAK % 5 E U e u

Computer Science, Prince of Songkhla University

12

Page 13: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________ 6 ACK SYN & 6 F V f v 7 BEL ETB ‘ 7 G W g w 8 BS CAN ( 8 H X h x 9 HT EM ) 9 I Y i y A LF SUB * : J Z j z B VT ESC + ; K [ k { C FF FS , < L \ l | D CR GS - = M ] m } E SO RS . > N ^ n ~ F SI US / ? O _ o DEL

เชน่ อักขระ 0 แทนด้วยรหสั ASCII เลขฐานสบิหก 30 อักขระ 1 แทนด้วยรหสั ASCII เลขฐานสบิหก 31 อักขระ A แทนด้วยรหสั ASCII เลขฐานสบิหก 41 อักขระ a แทนด้วยรหสั ASCII เลขฐานสบิหก 61 อักขระ SP หรอื blank แทนด้วยรหสั ASCII เลขฐานสบิหก 02 อักขระ CR แทนด้วยรหสั ASCII เลขฐานสบิหก 0D อักขระ LF แทนด้วยรหสั ASCII เลขฐานสบิหก 0A อักขระ BEL หรอื beep แทนด้วยรหสั ASCII เลขฐานสบิหก 07เป็นต้น

Computer Science, Prince of Songkhla University

13

Page 14: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

14

Page 15: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

15

Page 16: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

16

Page 17: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

17

Page 18: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

18

Page 19: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

19

Page 20: ROM-BIOSstaff.cs.psu.ac.th/iew//cs344-321/appendix.doc · Web view8086/8088 Mnemonic _____ mnemonic ช อเต ม mnemonic ช อเต ม ... ASCII เลขฐานส บหก

CS344-321 Assembly Language Programming Appendix page_______________________________________________________________________

Computer Science, Prince of Songkhla University

20


Recommended