1 / 66

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

เครื่องมือในการพัฒนาภาษาแอสเซมบลี้. Tools. Assembly language vs. machine code Edit and debugging tools Debug, program you can use to test and debug MS - DOS executable files . http :// www . microsoft . com / resources / documentation / windows / xp / all / proddocs / en - us / debug . mspx

cyndi
Télécharger la présentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. http://www.microsoft.com/resources/documentation/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) • 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:0100 • 04BA:0100

  7. a : Example • -a 0100:0500 • 0100: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. c : 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: • c 100,10f 300 หรือ c100 L 10 300 • Both of these commands produce the following output (assuming DS = 197F): • 197F:0100 4D E4 197F:0300 • 197F:0101 67 99 197F: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

  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: • e ds: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: • f 04ba:100 L 100 42 45 52 54 41

  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: • g cs: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: • g cs: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: • h 19f 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: • i 2f8 • 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: • n file.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: • L 04ba:100 2 0f 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 remainsintact. • 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 : overlapping copy ops • 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: • m cs:100 110 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 • -n param1 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: • o 2f8 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:14427505 JNZ 144A

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

  46. q : Quit • 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: • r f • 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

More Related