Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

Similar documents
Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

untitled

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_06

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20

Microsoft PowerPoint - C15_LECTURE_NOTE_06

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

Windows XP

幻灯片 1

Microsoft Word - template.doc

PowerPoint Presentation

Microsoft PowerPoint - os_4.ppt

1.ai

穨control.PDF

untitled

els0xu_zh_nf_v8.book Page Wednesday, June, 009 9:5 AM ELS-0/0C.8

Microsoft PowerPoint - CA_02 Chapter5 Part-I_Single _V2.ppt

Bus Hound 5

K7VT2_QIG_v3

Microsoft PowerPoint - C15_LECTURE_NOTE_11

Chn 116 Neh.d.01.nis

Guide to Install SATA Hard Disks

2/80 2

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

Microsoft PowerPoint - Lecture7II.ppt

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

EK-STM32F

Microsoft PowerPoint - STU_EC_Ch08.ppt

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

TX-NR3030_BAS_Cs_ indd

<4D F736F F F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E BBCE6C8DDC4A3CABD5D>

AL-M200 Series

入學考試網上報名指南

Microsoft Word - HC20138_2010.doc

IP505SM_manual_cn.doc

Microsoft PowerPoint - STU_EC_Ch04.ppt

<4D F736F F D20C7B6C8EBCABDCFB5CDB3C9E8BCC6CAA6B0B8C0FDB5BCD1A75FD1F9D5C22E646F63>

1 CPU

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

CC213

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

epub83-1

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP

2015 Chinese FL Written examination

HCD0174_2008

CANVIO_AEROCAST_CS_EN.indd

目 录

Gerotor Motors Series Dimensions A,B C T L L G1/2 M G1/ A 4 C H4 E

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2

Microsoft Word - HSK使用手册.doc

Panaboard Overlayer help

untitled

LSC操作说明

DR2010.doc

EC51/52 GSM /GPRS MODEN

WinMDI 28

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

Microsoft Word - ChineseSATII .doc

ch_code_infoaccess

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

Tel:

lan03_yen

Gerolor Motors Series Dimensions A,B C T L L G1/2 M8 G1/ A 4 C H4 E

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1

Untitled-3

快乐蜂(Jollibee)快餐连锁店 的国际扩张历程

ARM JTAG实时仿真器安装使用指南

KDC-U5049 KDC-U4049 Made for ipod, and Made for iphone mean that an electronic accessory has been designed to connect specifically to ipod, or iphone,

Preface This guide is intended to standardize the use of the WeChat brand and ensure the brand's integrity and consistency. The guide applies to all d

從篤加有二「區」談當代平埔文化復振現相

Microsoft PowerPoint - Eisenstein_ABET_Presentation_Beijing_Oct_2007-Chinese.ppt [兼容模式]

IP TCP/IP PC OS µclinux MPEG4 Blackfin DSP MPEG4 IP UDP Winsock I/O DirectShow Filter DirectShow MPEG4 µclinux TCP/IP IP COM, DirectShow I

投影片 1

Oracle 4

Logitech Wireless Combo MK45 English

Microsoft Word - CX VMCO 3 easy step v1.doc

ICD ICD ICD ICD ICD

Some experiences in working with Madagascar: installa7on & development Tengfei Wang, Peng Zou Tongji university

C++ 程式設計

untitled

Chapter 2

Edge-Triggered Rising Edge-Triggered ( Falling Edge-Triggered ( Unit 11 Latches and Flip-Flops 3 Timing for D Flip-Flop (Falling-Edge Trigger) Unit 11

MATLAB 1

Microsoft Word - 先玉335 copy.doc

Microsoft Word RCE MP_Year Book.doc

科学计算的语言-FORTRAN95

國 立 政 治 大 學 教 育 學 系 2016 新 生 入 學 手 冊 目 錄 表 11 國 立 政 治 大 學 教 育 學 系 博 士 班 資 格 考 試 抵 免 申 請 表 論 文 題 目 申 報 暨 指 導 教 授 表 12 國 立 政 治 大 學 碩 博 士 班 論

3 (s05q6) The diagram shows the velocity-time graph for a lift moving between floors in a building. The graph consists of straight line segments. In t

TI 3 TI TABLE 4 RANDBIN Research of Modern Basic Education

國家圖書館典藏電子全文

SuperMap 系列产品介绍

ebook140-9

Chapter 9: Objects and Classes

untitled

IP Access Lists IP Access Lists IP Access Lists

第1章 簡介

Transcription:

MACHINE LANGUAGE CODING AND THE DEBUG SOFTWARE DEVELOPMENT PROGRAM OF THE PC General instruction format for machine code 611 37100 微處理機原理與應用 Lecture 04-4 MACHINE LANGUAGE CODING AND THE DEBUG SOFTWARE DEVELOPMENT PROGRAM OF THE PC 4.2 Encoding a Complete Program in Machine Code Contents of Memory 4.5 Input and Output of Data Byte 1 specification Opcode field (6-bits) Specifies the operation to be performed Register direction bit (D-bit) 1 the register operand is a destination operand 0 the register operand is a source operand Data size bit (W-bit) 1 16-bit data size 0 8-bit data size 611 37100 微處理機原理與應用 Lecture 04-2 611 37100 微處理機原理與應用 Lecture 04-5 THE DEBUG, A SOFTWARE DEVELOPMENT PROGRAM FOR THE PC 4.6 Hexadecimal Addition and Subtraction Machine Language Program 4.8 Assembling Instructions with the Assemble Command with the TRACE and GO command 4.10 Debugging a Program Byte 2 specification Mode (MOD) field (2-bits) Together with R/M field to specify the second operand Register (REG) field (3-bit) Identifies the register for the first operand Register/Memory (R/M) field (3-bit) Register (REG) field encoding 611 37100 微處理機原理與應用 Lecture 04-3 611 37100 微處理機原理與應用 Lecture 04-6 1

Byte 2 specification MOD field and R/M field encoding XOR CL, [1234H] Encode the above instruction in machine code OPCODE = 001100 (for XOR), D = 1 (dest.), W = 0 (8-bit) This leads to BYTE 1 = 00110010 2 = 32 16 In byte 2 the destination operand, specified by REG, is CL REG = 001, MOD = 00, R/M = 110 Therefore, BYTE 2 = 00001110 2 = 0E 16 BYTE 3 = 34 16 BYTE 4 = 12 16 XOR CL, [1234H] = 320E3412 16 611 37100 微處理機原理與應用 Lecture 04-7 611 37100 微處理機原理與應用 Lecture 04-10 MOV BL, AL Encode the above instruction in machine code OPCODE = 100010 (for MOV), D = 0 (source), W = 0 (8-bit) This leads to BYTE 1 = 10001000 2 = 88 16 In byte 2 the source operand, specified by REG, is AL REG = 000, MOD = 11, R/M = 011 Therefore, BYTE 2 = 11000011 2 = C3 16 MOV BL, AL = 88C3 16 ADD [BX][DI]+1234H, AX Encode the above instruction in machine code OPCODE = 000000 (for ADD), D = 0 (source), W = 1 (16-bit) This leads to BYTE 1 = 00000001 2 = 01 16 In byte 2 the destination operand, specified by REG, is AX REG = 000, MOD = 10, R/M = 001 Therefore, BYTE 2 = 10000001 2 = 81 16 BYTE 3 = 34 16 BYTE 4 = 12 16 ADD [BX][DI]+1234H, AX = 01813412 16 611 37100 微處理機原理與應用 Lecture 04-8 611 37100 微處理機原理與應用 Lecture 04-11 ADD AX, [SI] Encode the above instruction in machine code OPCODE = 000000 (for ADD), D = 1 (dest.), W = 1 (16-bit) This leads to BYTE 1 = 00000011 2 = 03 16 In byte 2 the destination operand, specified by REG, is AX REG = 000, MOD = 00, R/M = 100 Therefore, BYTE 2 = 00000100 2 = 04 16 ADD AX, [SI] = 0304 16 611 37100 微處理機原理與應用 Lecture 04-9 Additional one-bit field and their functions Field Value Function S V Z 0 1 0 1 0 1 Instructions that involve a segment register (SR-field) Register SR 611 37100 微處理機原理與應用 Lecture 04-12 No sign extension Sign extend 8-bit immediate data to 16 bits if W=1 Shift/rotate count is one Shift/rotate count is specified in CL register Repeat/loop while zero flag is clear Repeat/loop while zero flag is set ES CS SS DS 00 01 10 11 2

MOV WORD PTR [BP][DI]+1234H, 0ABCDH Encode the above instruction in machine code This example does not follow the general format From Fig. 3-1 MOV -> 1100011W, and W = 1 for word-size data BYTE 1 = 11000111 2 = C7 16 BYTE 2 = (MOD)000(R/M) = 10000011 2 = 83 16 BYTE 3 = 34 16 BYTE 4 = 12 16 BYTE 5 = CD 16 BYTE 6 = AB 16 MOV WORD PTR [BP][DI]+1234H, 0ABCDH = C7833412CDAB 16 4.2 Encoding a Complete Program in Machine Code Encode the block move program in Fig. 4-6(a) and show how it would be stored in memory starting at address 200 16. MOV AX, 2000H ;LOAD AX REGISTER MOV DS, AX ;LOAD DATA SEGMENT ADDRESS MOV SI, 100H ;LOAD SOURCE BLOCK POINTER MOV DI, 120H ;LOAD DESTINATION BLOCK POINTER MOV CX, 10H ;LOAD REPEAT COUNTER NXTPT: MOV AH, [SI] ;MOVE SOURCE BLOCK ELEMENT TO AH MOV [DI], AH ;MOVE ELEMENT FROM AH TO DEST. BLOCK INC SI ;INCREMENT SOURCE BLOCK POINTER INC DI ;INCREMENT DESTINATION BLOCK POINTER DEC CX ;DECREMENT REPEAT COUNTER JNZ NXTPT ;JUMP TO NXTPT IF CX NOT EQUAL TO ZERO NOP ;NO OPERATION 611 37100 微處理機原理與應用 Lecture 04-13 611 37100 微處理機原理與應用 Lecture 04-16 MOV [BP][DI]+1234H, DS Encode the above instruction in machine code This example does not follow the general format From Fig. 3-6 MOV -> 10001100, and the instruction is 10001100(MOD)0(SR)(R/M)(DISP) From Fig. 4-5 we find that for DS, the SR = 11 Therefore, the instruction is coded as MOV [BP][DI]+1234H, DS =10001100100110110011010000010010 2 =8C9B3412 16 4.2 Encoding a Complete Program in Machine Code 611 37100 微處理機原理與應用 Lecture 04-14 611 37100 微處理機原理與應用 Lecture 04-17 4.2 Encoding a Complete Program in Machine Code Steps in encoding a complete assembly program: Identify the general machine code format (Fig. 3-6) Evaluate the bit fields (Fig. 4-2,4-3,4-4,4-5) Express the binary-code instruction in hexadecimal form To execute the program, the machine code of the program must be stored in the code segment of memory. The first byte of the program is stored at the lowest address. 4.2 Encoding a Complete Program in Machine Code 611 37100 微處理機原理與應用 Lecture 04-15 611 37100 微處理機原理與應用 Lecture 04-18 3

Using DEBUG, the programmer can issue commands to the microcomputer. Loading the DEBUG program C:\DEBUG Six kinds of information are entered as part of a command: A command letter An address A register name A file name A drive name Data 611 37100 微處理機原理與應用 Lecture 04-19 Syntax for the REGISTER (R) command R [REGISTER NAME] -R AX ( ) AX 0000 :_ :00FF ( ) _ 611 37100 微處理機原理與應用 Lecture 04-22 ;This alter the content of AX The DEBUG program command set Verify the initialized state of the 8088 by examining the contents of its registers with the Register command -R ( ) 611 37100 微處理機原理與應用 Lecture 04-20 611 37100 微處理機原理與應用 Lecture 04-23 An initial state when with the loading of DEBUG 0100 IP 1342 CS 1342 DS 1342 SS 1342 ES 0000 AX 0000 BX 0000 CX 0000 DX FFEE SP 0000 BP 0000 SI 0000 DI 0040 Flags 8088/8086 MPU 611 37100 微處理機原理與應用 Lecture 04-21 00000 16 Memory 13420 16 Active code segment, data segment, stack segment, and extra segment (64 K bytes) FFFFF 16 Register mnemonics for the R command Symbol AX BX CX DX SI DI SP BP CS DS SS ES F IP Accumulator register Base register Count register Data register Source index register Destination index register Stack pointer register Base pointer register Code segment register Data segment register Stack segment register Extra segment register Flag register Instruction pointer 611 37100 微處理機原理與應用 Lecture 04-24 Register 4

Status flag notations Flag Meaning Set Reset OF Overflow OV NV DF Direction DN UP IF Interrupt EI DI SF Sign NG PL ZF Zero ZR NZ AF Auxiliary carry AC NA The commands provided for use in examining and modifying the memory: DUMP ENTER FILL MOVE COMPARE SERACH PF Parity PE PO CF Carry CY NC 611 37100 微處理機原理與應用 Lecture 04-25 611 37100 微處理機原理與應用 Lecture 04-28 Issue commands to the DEBUG program on the PC that causes the value in BX to be modified to FF00 16 and then verify that this new value is loaded into BX. -R BX ( ) BX 0000 :FF00 ( ) -R BX ( ) BX FF00 :_ ( ) _ DUMP Command (D) The DUMP command allows us to examine the contents of a memory location or a block of consecutive memory location. D [ADDRESS] -D ( ) -D 1342:100 ( ) -D DS:100 ( ) -D 100 ( ) 611 37100 微處理機原理與應用 Lecture 04-26 611 37100 微處理機原理與應用 Lecture 04-29 Use the Register command to set the parity flag to even parity. Verify that the flag has been changed. -R F ( ) NV UP EI PL NZ NA PO NC -PE ( ) -R F ( ) NV UP EI PL NZ NA PE NC - ( ) DUMP Command (D) 611 37100 微處理機原理與應用 Lecture 04-27 Address of the first byte of data 611 37100 微處理機原理與應用 Lecture 04-30 16 bytes of data per line, 128 bytes per dump ASCII version of the memory data 5

Issue a dump command to display the contents of the 32 bytes of memory located at offset 0300 16 through 031F 16 in the current data segment. -D 300 31F ( ) Start a data entry sequence by examining the contents of address DS:100 and then, without entering new data, depress the - key. What happen? -E DS:100 ( ) 1342:0100 FF. _ Entering - causes the display of previous byte storage location. 611 37100 微處理機原理與應用 Lecture 04-31 611 37100 微處理機原理與應用 Lecture 04-34 Use the Dump command to examine the 16 bytes of memory just below the top of the stack. -D SS:FFEE FFFD ( ) Enter ASCII data to the memory. -E DS:200 ASCII ( ) -E DS:200 ASCII ( ) 611 37100 微處理機原理與應用 Lecture 04-32 611 37100 微處理機原理與應用 Lecture 04-35 ENTER Command (E) E ADDRESS [LIST] -E DS:100 FF FF FF FF FF ( ) -E DS:100 ( ) -1342:0100 FF. _ ( ) (Return to end) -E DS:100 ( ) -1342:0100 FF. _ (Space bar to continue) -1342:0100 FF. FF._ FILL Command (F) The FILL command fills a block of consecutive memory locations all with the same data. F STARTING_ADDRESS ENDING_ADDRESS LIST -F 100 11F 22 ( ) 611 37100 微處理機原理與應用 Lecture 04-33 611 37100 微處理機原理與應用 Lecture 04-36 6

Initialize all storage locations in the block of memory from DS:120 through DS:13F with the value 33 16 and the block of storage locations from DS:140 to DS:15F with the value 44 16. -F 120 13F 33 ( ) -F 140 15F 44 ( ) COMPARE Command (C) The COMPARE command allows us to compare the contents of two blocks of data to determine if they are or are not the same. C START_ADDRESS END_ADDRESS DEST_ADDRESS -C 100 10F 120 ( ) 611 37100 微處理機原理與應用 Lecture 04-37 611 37100 微處理機原理與應用 Lecture 04-40 MOVE Command (M) The MOVE command allows us to copy a block of data from one part of memory to another part. COMPARE Command (C) M START_ADDRESS END_ADDRESS DEST_ADDRESS -M 100 11F 200 ( ) Results produced when unequal data are found with a COMPARE command 611 37100 微處理機原理與應用 Lecture 04-38 611 37100 微處理機原理與應用 Lecture 04-41 Fill each storage location in the block of memory from address DS:100 through DS:11F with the value 11 16. Then copy this block of data to a destination block starting at DS:160. -F 100 11F 11 ( ) -M 100 11F 160 ( ) SEARCH Command (S) The SEARCH command can be used to scan through a block of data in memory to determine whether or not it contains specific data. C START_ADDRESS END_ADDRESS LIST -S 100 17F 33 ( ) 611 37100 微處理機原理與應用 Lecture 04-39 611 37100 微處理機原理與應用 Lecture 04-42 7

SEARCH Command (S) 4.6 Hexadecimal Addition and Subtraction HEXADECIMAL Command (H) The HEXADECIMAL command provides the ability to add and subtract hexadecimal numbers. H NUM1 NUM2 -H ABC0 0FFF ( ) BBBF 9BC1 -H BBBF A ( ) BBC9 BBB5 *Both number and results are limited to four hexadecimal digits. 611 37100 微處理機原理與應用 Lecture 04-43 611 37100 微處理機原理與應用 Lecture 04-46 4.5 Input and Output of Data INPUT Command (I) The INPUT command read data from an input port of the 64K byte-wide ports of 8088 I/O. I ADDRESS 4.6 Hexadecimal Addition and Subtraction Use the H command to find the negative of the number 0009 16. -H 0 9 ( ) 0009 FFF7 -I 61 ( ) 4D FFF7 16 is the negative of 9 16 expressed in 2 s complement form. The contents of the port ant I/O address 0061 16 are 4D 16 611 37100 微處理機原理與應用 Lecture 04-44 611 37100 微處理機原理與應用 Lecture 04-47 4.5 Input and Output of Data OUTPUT Command (O) The OUTPUT command write data to an input port of the 64K byte-wide ports of 8088 I/O. O ADDRESS BYTE -O 61 4F ( ) 4.6 Hexadecimal Addition and Subtraction If a byte of data is located at physical address 02A34 16 and the data segment register contains 0150 16, what value must be loaded into the source index register such that DS:SI points to the byte storage location? -H 2A34 1500 ( ) 3F34 1534 This command causes the value 4F 16 to be written into the byte-wide output port at address 0061 16 This shows that SI must be loaded with the value 1534 16. 611 37100 微處理機原理與應用 Lecture 04-45 611 37100 微處理機原理與應用 Lecture 04-48 8

An example to load an instruction MOV BL, AL The machine code is 88C3 16 -E CS:100 88 C3 ( ) -D CS:100 101 ( ) 1342:0100 88 C3 WRITE Command (W) The WRITE command gives the ability to save data stored in memory on a diskette. W [START_ADDRESS [DRIVE START_SECTOR NUM_SECTOR] ] -W CS:200 1 10 1 ( ) -W 200 1 10 1 ( ) Drive B 1 Sector = 512 Byte * Be caution in saving program in a disk, especially the hard drive. 611 37100 微處理機原理與應用 Lecture 04-49 611 37100 微處理機原理與應用 Lecture 04-52 UNASSEMBLE Command (U) The UNASSEMBLE command converts machine code instructions to their equivalent assembly language source statement. U [STARTING_ADDRESS [ENDING_ADDRESS] ] -U CS:100 101 ( ) 1342:0100 88C3 MOV BL, AL LOAD Command (L) The LOAD command gives the ability to reload memory from a diskette. L [START_ADDRESS [DRIVE START_SECTOR NUM_SECTOR] ] -L CS:300 1 10 1 ( ) The reloading of the instruction can be verified by U command -U CS:300 301 ( ) 1342:300 301 ADD AX, [SI] 611 37100 微處理機原理與應用 Lecture 04-50 611 37100 微處理機原理與應用 Lecture 04-53 Use a sequence of commands to load, verify loading, and unassemble the machine code instruction 0304H. Load the instruction at address CS:200. -E CS:200 03 04 ( ) -D CS:200 201 ( ) -U CS:200 201 ( ) ADD AX, [SI] Enter the machine code of the block move program. The program is to be loaded into memory starting at address CS:100. Verify, unassemble, and save the code. -E CS:100 B8 00 20 8E D8 BE 00 01 BF 20 01 B9 10 00 8A 24 88 25 46 ( ) -D CS:100 117( ) -U CS:100 117( ) -W CS:100 1 100 1 ( ) 611 37100 微處理機原理與應用 Lecture 04-51 611 37100 微處理機原理與應用 Lecture 04-54 9

Reload a program into memory. -N A:BLK.1 ( ) ; Give a file name in disk A -L CS:100 ( ) ; Load the program name BLK.1 in disk A C:\DOS>REN A:BLK.1 BLK.EXE ( ) ; Rename the file C:\DOS>DEBUG A:BLK.EXE ( ) ; Load the program directly C:\DOS>A:BLK.EXE ( ) ; Run the program 611 37100 微處理機原理與應用 Lecture 04-55 611 37100 微處理機原理與應用 Lecture 04-58 NAME Command (N) The NAME command, along with the WRITE command, gives the ability to save a program on the diskette under a file name. N FILE NAME The BX, CX registers must be updated to identify the size of the program that is to be saved in the file. After BX, CX registers have been initialized, the write command is used to saved the program. To reload the program, the command sequence is N FILE NAME L [STARTING ADDRESS] 611 37100 微處理機原理與應用 Lecture 04-56 4.8 Assembling Instructions with the Assemble Command ASSEMBLE Command (A) The ASSEMBLE command let us automatically assemble the instructions of a program. A [STARTING_ADDRESS] 611 37100 微處理機原理與應用 Lecture 04-59 -A CS:100 ( ) 1342:0100 _ 1342:0100 ADD [BX+SI+1234], AX ( ) 1342:0104 _ -D CS:100 103 ( ) Save a machine code program into a file. -N A:BLK.1 ( ) ; Give a file name in disk A -R CX ( ) ; Give a program size of 18 16 bytes CX XXXX :18 -R BX ( ) BX XXXX :0 ( ) W CS:100 ( ) ; Save the program in disk A 4.8 Assembling Instructions with the Assemble Command Assemble a complete program with the ASSEMBLE command. -A CS:200 ( ) 0B35:0200 MOV AX, 2000 ( ) 0B35:0203 MOV DS, AX ( ) 0B35:0205 MOB SI, 100 ( )........ 0B35:0217 NOP ( ) 0B35:0218 ( ) 611 37100 微處理機原理與應用 Lecture 04-57 611 37100 微處理機原理與應用 Lecture 04-60 10

4.8 Assembling Instructions with the Assemble Command Assemble a program with ASSEMBLE command Load and trace a program. -L CS:100 1 10 1 ( ) -U 100 101 ( ) -R AX ( ) AX 0000 :1111 ( ) -R SI ( ) SI 0000 :1234 ( ) -E DS:1234 22 22 ( ) -T =CS:100 ( ) 611 37100 微處理機原理與應用 Lecture 04-61 611 37100 微處理機原理與應用 Lecture 04-64 4.8 Assembling Instructions with the Assemble Command Unassemble a program with UNASSEMBLE command 611 37100 微處理機原理與應用 Lecture 04-62 611 37100 微處理機原理與應用 Lecture 04-65 TRACE Command (T) The TRACE command provides the programmer with the ability to execute the program one instruction at a time. T [=STARTING_ADDRESS] [NUMBER] -T =CS:100 ( ) -T ( ) GO Command (G) The GO command is typically used to run programs that are already working or to execute programs in the later stages or debugging. G [=STARTING_ADDRESS [BREAKPOINT_ADDRESS_LIST] ] -G =CS:200 217 ( ) -G =CS:100 ( ) -T =CS:100 3 ( ) -G ( ) 611 37100 微處理機原理與應用 Lecture 04-63 611 37100 微處理機原理與應用 Lecture 04-66 11

Use GO command to execute a program and examine the result. -N A:BLK.EXE ( ) ; Define the program file to be loaded -L CS:200 ( ) ; Load the program at CS:200 -R DS ( ) DS 1342 :2000 ( ) ; Define the data segment address -F DS:100 10F FF ( ) ; Fill memory with FF -F DS:120 12F 00 ( ) ; Fill memory with 00 -R DS ( ) DS 2000 :1342 ; Store data segment with 1342 16 611 37100 微處理機原理與應用 Lecture 04-67 611 37100 微處理機原理與應用 Lecture 04-70 Use GO command to execute a program and examine the result. (continued) -R ( ) ; Show data register status -U CS:200 217 ( ) ; Unassemble the program -G =CS:200 20E ( ) ; Execute the program to CS:20E -G =CS:20E 215 ( ) ; Execute the program to CS:215 -D DS:100 10F ( ) ; Display memory at DS:100 -D DS:120 12F ( ) ; Display memory at DS:120 -G =CS:215 217 ( ) ; Execute the program to CS:217 -D DS:100 10F ( ) ; Display memory at DS:100 -D DS:120 12F ( ) ; Display memory at DS:120 611 37100 微處理機原理與應用 Lecture 04-68 611 37100 微處理機原理與應用 Lecture 04-71 4.10 Debugging a Program 611 37100 微處理機原理與應用 Lecture 04-69 Errors in a program are also referred to as bugs; the process of removing them is called debugging. Two types of errors Syntax error Execution error A syntax error is an error caused by not following the rules for coding or entering an instruction. These types of errors are typically identified by the microcomputer and signaled to user with an error message In the DEBUG environment, the TRACE command is usually used to debug execution errors. 611 37100 微處理機原理與應用 Lecture 04-72 12

4.10 Debugging a Program Review of the DEBUG commands 611 37100 微處理機原理與應用 Lecture 04-73 13