1 เครื่องมือในการพัฒนาภาษา แอสเซมบลี้. 2 Tools Assembly language vs. machine code Edit and debugging tools Debug, program you can use to test and debug.

Slides:



Advertisements
Similar presentations
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Advertisements

Registers of the 8086/ /2002 JNM.
SOFTWARE ARCHITECTURE OF THE 8088 AND 8086 MICROPROCESSORS
Lab6 – Debug Assembly Language Lab
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
80x86 Processor Architecture
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
The 8086 Microprocessor The 8086, announced in 1978, was the first 16-bit microprocessor introduced by Intel Corporation 8086 is 16-bit MPU. Externally.
Chapter 2 Software Tools and Assembly Language Syntax.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
An Introduction to 8086 Microprocessor.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
Chapter 3 Examining Computer Memory and Executing Instructions.
Types of Registers (8086 Microprocessor Based)
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
Faculty of Engineering, Electrical Department,
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Debuggers A program needed when writing any type of code Displays the contents of memory Lets you view registers and variables and see how they change.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Khaled A. Al-Utaibi  I/O Ports  I/O Space VS Memory Space  80x86 I/O Instructions − Direct I/O Instructions − Indirect I/O Instructions.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Internal Programming Architecture or Model
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
Intel 8086 MICROPROCESSOR ARCHITECTURE
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
SOFTWARE ARCHITECTURE OF THE 8088 AND 8086 MICROPROCESSORS
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
ΜComputer Structure μProcessor Memory Bus System I/O Ports.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Microprocessor and Assembly Language
UNIT Architecture M.Brindha AP/EIE
Introduction to 8086 Microprocessor
Assembly Language Programming Part 3
8086 Microprocessor.
Computer Organization & Assembly Language Chapter 3
Instruction Execution Cycle
Instruksi Set Prosesor 8088
ADDRESSING MODES.
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
Microprocessor and Assembly Language
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
CS 301 Fall 2001 – Chapter 3 Slides by Prof. Hartman, following “IBM PC Assembly Language Programming” by Peter Abel 9/17/2018.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Symbolic Instruction and Addressing
Introduction to Assembly Language
Intel 8088 (8086) Microprocessor Structure
DEBUG.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
Microprocessor and Assembly Language
8051 ASSEMBLY LANGUAGE PROGRAMMING
Unit-I 80386DX Architecture
Chapter 6 –Symbolic Instruction and Addressing
Presentation transcript:

1 เครื่องมือในการพัฒนาภาษา แอสเซมบลี้

2 Tools Assembly language vs. machine code Edit and debugging tools Debug, program you can use to test and debug MS-DOS executable files. on/windows/xp/all/proddocs/en-us/debug.mspx on/windows/xp/all/proddocs/en-us/debug.mspx Compiler X86 : Assembly language : TASM, MASM C, Basic

3 DEBUG Starts Debug.exe, a program you can use to test and debug MS-DOS executable files. Used without parameters, debug starts Debug.exe and the debug prompt appears, which is represented by a hyphen (-). Syntax debug [[Drive:][Path] FileName [parameters]]

4 Debug Subcommands a (assemble)c (compare)d (dump) a e (enter)f (fill)g (go) h (hexadecimal)i (input)l (load) m (move) n (name)o (output) p (proceed)q (quit)r (register) s (search)t (trace) u(unassemble) w (write) xa, xd (allocate / deallocate expanded memory) xm, xs (map / display expanded memory pages)

5 a address Assembles 8086/8087/8088 mnemonics directly into memory. Used without parameters, a starts assembling where it last stopped. address : Specifies the location where you type assembly-language mnemonics. Use hexadecimal values for address and type each value without the trailing h character. address is a two-part designation, containing either an alphabetic segment register or a four-digit segment address with an offset value. You can omit the segment register or segment address.

6 a address CS is the default segment for the following debug subcommands: a, g, l, t, u, and w. DS is the default segment for all other subcommands. All numeric values are in hexadecimal format. You must include a colon between the segment name and the offset value. The following are valid addresses: CS: BA:0100

7 a : Example -a0100: :0500 jmp 502 ; a 2-byte short jump 0100:0502 jmp near 505 ; a 3-byte near jump 0100:0505 jmp far 50a ; a 5-byte far jump

8 c range address Compares two portions of memory. Syntax c range address

9 Parameters range : Required. Specifies the starting and ending addresses, or the starting address and length, of the first area of memory you want to compare. address : Required. Specifies the starting address of the second area of memory you want to compare.

10 c : Example To compare the block of memory from 100h through 10Fh with the block of memory from 300h through 30Fh, type: c100,10f 300 or c100l Both of these commands produce the following output (assuming DS = 197F): 197F:0100 4D E4 197F: F: F:0301 ….

11 d [range] Displays the contents of a range of memory addresses. Used without parameters, d displays the contents of 128 bytes, starting at the end of the address range specified in the previous d subcommand. range : Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents you want to display.

12 d [range] Specifying valid range entries Use range with a debug subcommand to specify a range of memory. You can choose one of the following formats for range: a starting address and an ending address, or a starting address and the length (denoted by l) of the range. For example, both of the following syntaxes specify a 16-byte range beginning at CS:100: cs:100 10f cs:100 l 10 (XP does not support this format)

13 e address [list] Enters data into memory at the address you specify. address : Required. Specifies the first memory location where you want to enter data. list : Specifies the data you want to enter into successive bytes of memory.

14 e address [list] Using the address parameter If you specify a value for address without specifying a value for the optional list parameter, Debug.exe displays the address and its contents, repeats the address on the next line, and waits for your input.

15 e address [list] Using the list parameter If you specify values for the list parameter, the e subcommand sequentially replaces the existing byte values with the values from the list. If an error occurs, no byte values are changed. List values can be either hexadecimal byte values or strings. You separate values by using a space, a comma, or a tab character. You must enclose strings within single quotation marks (that is, 'string') or double quotation marks (that is, "string").

16 e : Example The following is an example of a string entry: eds:100 "This is the text example" This string fills 24 bytes, starting at DS:100

17 f range list Fills addresses in the specified memory area with values you specify. Parameters range : Required. Specifies the starting and ending addresses, or the starting address and length, of the memory area you want to fill. list : Required. Specifies the data you want to enter

18 f : Examples To fill memory locations 04BA:100 through 04BA:1FF with five specific values… (for example, 42, 45, 52, 54, 41) and repeat the five values until Debug.exe fills all of the 100h bytes, type: f04ba:100l

19 g [=address] [breakpoints] Runs the program currently in memory. Used without parameters, g starts running at the current address in the CS:IP registers.

20 g : Parameters address : Specifies the address in the program currently in memory where you want to begin running the program. breakpoints : Specifies 1 to 10 temporary breakpoints that you can set as part of the g subcommand.

21 g : Examples To run the program currently in memory up to the breakpoint address 7550 in the CS segment, type: gcs:7550 Debug.exe displays the contents of the registers and the status of the flags and stops the g subcommand. To set two breakpoints, type: gcs:7550, cs:8000

22 h value1 value2 Performs hexadecimal arithmetic on two parameters that you specify. value1 : Required. Represents any hexadecimal number in the range 0 through FFFFh. value2 : Required. Represents a second hexadecimal number in the range 0 through FFFFh.

23 h : Examples Type: h19f 10a Debug.exe performs the calculations and displays the following result: 02A9 0095

24 i port Reads and displays one byte value from the port you specify. port : Required. Specifies the input port by address. The address can be a 16-bit value.

25 i : Examples Type: i2f8 If the byte value at the port is 42h, Debug.exe reads the byte and displays the value as follows: 42

26 L [address] [Drive] [FirstSector] [number] Loads a file or the contents of specific disk sectors into memory. Used without parameters, the l subcommand loads the file you specified on the debug command line into memory, beginning at address CS:100. Debug.exe also sets the BX and CX registers to the number of bytes loaded. If you did not specify a file on the debug command line, the file loaded is the one you most recently specified by using the n (name) subcommand.

27 L [address] [Drive] [FirstSector] [number] address : Specifies the memory location where you want to load the file or the sector contents. If you do not specify address, Debug.exe uses the current address in the CS register. Drive : Specifies the drive that contains the disk from which specific sectors are to be read. This value is numeric: 0 = A, 1 = B, 2 = C, and so on.

28 L [address] [Drive] [FirstSector] [number] FirstSector : Specifies the hexadecimal number of the first sector from which you want to load contents. number : Specifies the hexadecimal number of consecutive sectors from which you want to load contents. Use Drive, FirstSector, and number only if you want to load the contents of specific sectors instead of loading the file specified on the debug command line or in the most recent n (name) subcommand.

29 L [address] [Drive] [FirstSector] [number] To load the contents of the number of bytes specified in the BX:CX registers from a disk file, use the following syntax: l [address] To bypass the file system and directly load specific sectors, use the following syntax: l [address] [Drive] [FirstSector] [number]

30 L : Example To load File.com, type: nfile.com l Debug.exe loads the file and displays the debug prompt. To load the contents of 109 (6Dh) sectors from drive C, beginning with logical sector 15 (0Fh), into memory beginning at address 04BA:0100, type: l04ba: f 6d

31 m range address Copies the contents of a block of memory to another block of memory. range : Required. Specifies the starting and ending addresses, or the starting address and the length of the memory area whose contents you want to copy. address : Required. Specifies the starting address of the location to which you want to copy the contents of range.

32 m : Copying data If the addresses in the block that you are copying do not have new data written to them, the original data remains intact. However, if the destination block already contains data (as it might in an overlapping copy operation), that data is overwritten. (Overlapping copy operations are those in which part of the destination block overlaps part of the source block.)

33 m : Performing overlapping copy operations The m subcommand performs overlapping copy operations without losing data at the destination addresses. The contents of addresses that will be overwritten are copied first. If data is to be copied from higher addresses to lower addresses, the copy operation begins at the source block's lowest address and progresses toward the highest address. Conversely, if data is to be copied from lower addresses to higher addresses, the copy operation begins at the source block's highest address and progresses toward the lowest address.

34 m : Examples To copy the contents of address CS:110 to CS:510, and then copy the contents of CS:10F to CS:50F, and so on until all of the contents of CS:100 to CS:500 are copied, type: mcs: cs:500

35 n [Path][executable] Specifies the name of an executable file for a debug l (load) or w (write) subcommand, or specifies parameters for the executable file that you are debugging. Used without parameters, n clears the current specifications.

36 n : Usage You can use the n subcommand in two ways. First, you can use it to specify a file to be used by a later l (load) or w (write) subcommands. If you start Debug.exe without naming a file to be debugged, you must use the command n FileName before you can use l to load the file. The file name is correctly formatted for a file control block (FCB) at CS:5C. Second, you can use n to specify command-line parameters and command-line options for the file that you are debugging.

37 n : Parameter [Path][executable] : Specifies the location and name of the executable file you want to test. [FileParameters] : Specifies parameters and command-line options for the executable file you are testing.

38 Memory areas The following table lists the four areas of memory that can be affected by the n command. Memory location Contents CS:5C : File control block (FCB) for file 1 CS:6C : File control block (FCB) for file 2 CS:80 : Length of n command line (in characters) CS:81 : Beginning of n command-line characters

39 n : Examples In this example, run debug and load the program Prog.com for debugging. To specify two parameters for Prog.com and run the program, type: debug prog.com nparam1 param2 g In this case, the g (go) subcommand runs the program as if you typed the following command at the command prompt: prog param1 param2

40 o port byte-value Sends the value of a byte to an output port. Parameters port : Required. Specifies the output port by address. The port address can be a 16-bit value. byte-value : Required. Specifies the byte value you want to direct to port.

41 o : Examples To send the byte value 4Fh to the output port at address 2F8h, type: o2f8 4f

42 p [=address] [number] Executes a loop, a repeated string instruction, a software interrupt, or a subroutine. Or, traces through any other instruction. Used without parameters, p lists the registers and their current values. If the instruction at the specified address is not a loop, a repeated string instruction, a software interrupt, or a subroutine, the p subcommand works the same way as the t (trace) subcommand.

43 p : Parameters address : Specifies the location of the first instruction to execute. If you do not specify an address, the default address is the current address specified in the CS:IP registers. number : Specifies the number of instructions to execute before returning control to Debug.exe. The default value is 1.

44 p : Examples In this example, the program that you are testing contains a call command instruction at address CS:143F. To run the subroutine that is the destination of call and then return control to Debug.exe, type: p=143f Debug.exe displays the results in the following format: AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=2246 ES=2246 SS=2246 CS=2246 IP=1443 NV UP EI PL NZ AC PO NC 2246: JNZ 144A

45 p : Warning You cannot use the p subcommand to trace through read-only memory (ROM).

46 q Stops the Debug.exe session, without saving the file currently being tested, and returns to the command prompt.

47 r [Register] Displays or alters the contents of one or more CPU registers. Used without parameters, the r command displays the contents of all registers and flags in the register storage area, the status of all flags, and the decoded form of the instruction at the current location.

48 r : Usage If you specify a register, Debug.exe displays the 16-bit value of that register in hexadecimal notation and displays a colon as the prompt. If you want to change the value contained in the register, type a new value and press ENTER. Otherwise, press ENTER to return to the debug prompt.

49 r : Examples If the current location is CS:11A, the display will look similar to the following: AX=0E00 BX=00FF CX=0007 DX=01FF SP=039D BP=0000 SI=005C DI=0000 DS=04BA ES=04BA SS=04BA CS=O4BA IP=011A NV UP DI NG NZ AC PE NC 04BA:011A CD21 INT 21 To view only the status of the flags, type: rf Debug.exe displays the information in the following format: NV UP DI NG NZ AC PE NC - _ Type one or more valid flag values in any order, with or without spaces. For example: nv up di ng nz ac pe nc - pleicy

50 Flag name Set Clear Overflow ov / nv Direction dn (decrement) / up (increment) Interrupt ei (enabled) / di (disabled) Sign ng (negative) / pl (positive) Zero zr / nz Auxiliary Carry ac / na Parity pe (even) / po (odd) Carry cy / nc

51 s range list Searches a range of addresses for a pattern of one or more byte values. Parameters range : Required. Specifies the beginning and ending addresses of the range you want to search. list : Required. Specifies the pattern of either one or more byte values or a string on which you are searching.

52 s : Examples To find all addresses in the range CS:100 through CS:110 that contain the value 41, type: scs: Debug.exe displays the results in the following format: 04BA: BA:010D -

53 s : Examples To search for the string "Ph" in the range CS:100 through CS:1A0, type: scs:100 1a0 "Ph"

54 t [=address] [number] Executes one instruction and displays the contents of all registers, the status of all flags, and the decoded form of the instruction that is executed. Used without parameters, t begins tracing at the address specified by your program's CS:IP registers.

55 t : Parameters address : Specifies the address at which Debug.exe is to start tracing instructions. number : Specifies the number of instructions to be traced. This value must be a hexadecimal number. The default value is 1.

56 t : Tracing instructions in read-only memory The t subcommand uses the hardware trace mode of the 8086 or 8088 microprocessor. Therefore, you can also trace instructions stored in read-only memory (ROM).

57 t : Examples If the position of the instruction in the program is 04BA:011A, Debug.exe displays the following information: AX=0E00 BX=00FF CX=0007 DX=01FF SP=039D BP=0000 SI=005C DI=0000 DS=04BA ES=04BA SS=04BA CS=O4BA IP=011A NV UP DI NG NZ AC PE NC 04BA:011A CD21 INT 21

58 u [range] Disassembles bytes and displays their corresponding source statements, including addresses and byte values. The disassembled code looks like a listing for an assembled file. Used without parameters, u disassembles 20h bytes (the default number), beginning at the first address after the address displayed by the previous u subcommand.

59 u : Examples To display only the information for the specific addresses 04BA:0100 through 04BA:0108, type: u04ba: Debug.exe displays the following: 04BA: AND [SI+72],AH 04BA: DB 69 04BA: JBE 016B 04BA: AND [BP+DI+70],DH

60 u : Examples To disassemble 16 (10h) bytes, beginning at 04BA:0100, type: u04ba:100l10 Debug.exe displays the results in the following format: 04BA: AND [SI+72],AH 04BA: DB 69 04BA: JBE 016B 04BA: AND [BP+DI+70],DH 04BA: DB 65 04BA:010A 63 DB 63 04BA:010B 69 DB 69 04BA:010C 66 DB 66 04BA:010D 69 DB 69 04BA:010E 63 DB 63 04BA:010F 61 DB 61

61 w [address] [Drive] [firstsector] [number] Writes a file or specific sectors to disk. Used without parameters, w starts from CS:100.

62 w : Parameters address : Specifies the beginning memory address of the file, or portion of the file, you want to write to a disk file. Drive : Specifies the drive that contains the destination disk. This value is numeric: 0 = A, 1 = B, 2 = C, and so on. firstsector : Specifies the hexadecimal number of the first sector to which you want to write. number : Specifies the number of sectors to which you want to write.

63 w : Usage To write the contents of the number of bytes specified in the BX:CX registers to a disk file, use the following syntax: w [address] To bypass the file system and directly write to specific sectors, use the following syntax: w [address] [Drive] [firstsector] [number]

64 w : Usage Specifying the name of the disk file You must specify the name of the disk file either when you start Debug.exe or in the most recent n (name) subcommand. Both of these methods properly format a file name for a file control block at address CS:5C. Resetting BX:CX before using w without parameters If you use the g (go), t (trace), p (proceed), or r (register) subcommands, you must reset the BX:CX registers before using the w subcommand without parameters.

65 w : Examples To write the contents of memory, beginning at the address CS:100, to the disk in drive B and start collecting data from the disk's logical sector number 37h and continue for 2Bh sectors, type: wcs: b Writing to specific sectors is extremely risky because it bypasses the Windows XP file handler. The disk's file structure can be damaged if you type the wrong values.

66 That’s all 4 debug.