????????????????????????? Architectural ??? Microprocessor - PowerPoint PPT Presentation

1 / 66
About This Presentation
Title:

????????????????????????? Architectural ??? Microprocessor

Description:

– PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 67
Provided by: Compute242
Category:

less

Transcript and Presenter's Notes

Title: ????????????????????????? Architectural ??? Microprocessor


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 DrivePath 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
  • CS0100
  • 04BA0100

7
a Example
  • -a01000500
  • 01000500 jmp 502 a 2-byte short jump
  • 01000502 jmp near 505 a 3-byte near jump
  • 01000505 jmp far 50a a 5-byte far jump

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

9
c range address
  • 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 c100l10 300
  • Both of these commands produce the following
    output (assuming DS 197F)
  • 197F0100 4D E4 197F0300
  • 197F0101 67 99 197F0301 .

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 CS100
  • cs100 10f
  • cs100 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
  • eds100 "This is the text example"
  • This string fills 24 bytes, starting at DS100

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 04BA100 through
    04BA1FF 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
  • f04ba100l100 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 CSIP 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
  • gcs7550
  • Debug.exe displays the contents of the registers
    and the status of the flags and stops the g
    subcommand.
  • To set two breakpoints, type
  • gcs7550, cs8000

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 CS100.
  • 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 BXCX 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 04BA0100, type
  • l04ba100 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 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 CS110 to CS510,
    and then copy the contents of CS10F to CS50F,
    and so on until all of the contents of CS100 to
    CS500 are copied, type
  • mcs100 110 cs500

35
n Pathexecutable
  • 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 CS5C.
  • Second, you can use n to specify command-line
    parameters and command-line options for the file
    that you are debugging.

37
n Parameter
  • Pathexecutable 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
  • CS5C File control block (FCB) for file 1
  • CS6C File control block (FCB) for file 2
  • CS80 Length of n command line (in characters)
  • CS81 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 CSIP 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
    CS143F. To run the subroutine that is the
    destination of call and then return control to
    Debug.exe, type
  • p143f
  • Debug.exe displays the results in the following
    format
  • AX0000 BX0000 CX0000 DX0000 SPFFEE BP0000
    SI0000 DI0000
  • DS2246 ES2246 SS2246 CS2246 IP1443 NV UP EI
    PL NZ AC PO NC
  • 22461442 7505 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 CS11A, the display
    will look similar to the following
  • AX0E00 BX00FF CX0007 DX01FF SP039D BP0000
    SI005C DI0000
  • DS04BA ES04BA SS04BA CSO4BA IP011A NV UP DI
    NG NZ AC PE NC
  • 04BA011A 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 CS100 through
    CS110 that contain the value 41, type
  • scs100 110 41
  • Debug.exe displays the results in the following
    format
  • 04BA0104
  • 04BA010D
  • -

53
s Examples
  • To search for the string "Ph" in the range CS100
    through CS1A0, type
  • scs100 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 CSIP 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 04BA011A, Debug.exe displays the following
    information
  • AX0E00 BX00FF CX0007 DX01FF SP039D BP0000
    SI005C DI0000
  • DS04BA ES04BA SS04BA CSO4BA IP011A NV UP DI
    NG NZ AC PE NC
  • 04BA011A 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 04BA0100 through 04BA0108, type
  • u04ba0100 0108
  • Debug.exe displays the following
  • 04BA0100 206472 AND SI72,AH
  • 04BA0103 69 DB 69
  • 04BA0104 7665 JBE 016B
  • 04BA0106 207370 AND BPDI70,DH

60
u Examples
  • To disassemble 16 (10h) bytes, beginning at
    04BA0100, type
  • u04ba100l10
  • Debug.exe displays the results in the following
    format
  • 04BA0100 206472 AND SI72,AH
  • 04BA0103 69 DB 69
  • 04BA0104 7665 JBE 016B
  • 04BA0106 207370 AND BPDI70,DH
  • 04BA0109 65 DB 65
  • 04BA010A 63 DB 63
  • 04BA010B 69 DB 69
  • 04BA010C 66 DB 66
  • 04BA010D 69 DB 69
  • 04BA010E 63 DB 63
  • 04BA010F 61 DB 61

61
w address Drive firstsector number
  • Writes a file or specific sectors to disk. Used
    without parameters, w starts from CS100.

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 BXCX 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
    CS5C.
  • Resetting BXCX before using w without parameters
    If you use the g (go), t (trace), p (proceed), or
    r (register) subcommands, you must reset the
    BXCX registers before using the w subcommand
    without parameters.

65
w Examples
  • To write the contents of memory, beginning at the
    address CS100, to the disk in drive B and start
    collecting data from the disk's logical sector
    number 37h and continue for 2Bh sectors, type
  • wcs100 1 37 2b
  • 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
Thats all 4 debug.
Write a Comment
User Comments (0)
About PowerShow.com