Sei sulla pagina 1di 10

SYSTEM PROGRAMMING LAB

COE-410

SUBMITTED BY:

AJAY DABAS 208/CO/09

INDEX :

1 2 3 4 5 6 7 8 9

EXPLORE THE VARIOUS FEATURES OF DEBUG COMMAND. USE A SAMPLE PROGRAM TO EXPLAIN THE FEATURES OF DEBUG COMMAND. DISPLAY THE ASCII CHARACTER SET. CONVERT A NUMBER FROM ASCII CHARACTER SET TO A PACKED BCD NUMBER. CONVERT A PACKED BCD NUMBER INTO ASCII CHARACTERS. FIND ADDITION OF TWO BCD NUMBERS. FIND ADDITION OF N BCD NUMBERS. FIND ADDITION OF TWO UNPACKED BCD NUMBERS. FIND ADDITION OF N 16-BIT BCD NUMBERS.

USING DEBUG TO EXECUTE 80X86 PROGRAMS: DEBUG is a utility program that allows a user to load an 80x 86 programs in to memory and execute it step by step. DEBUG displays the contents of all processor registers after each instruction executes, allowing user to determine if the code is performing the desired task. DEBUG only displays the 16-bit portion of the general purpose registers. Code view is capable of displaying the entire 32 bits. DEBUG is a very useful debugging tool. We will use DEBUG to step through number of simple programs, gaining familiarity with DEBUG commands as we do. DEBUG contains commands that can display and modify memory, assemble instructions, disassemble code already placed into memory, trace through single or multiple instructions, load registers with data, and do much more. DEBUG loads into memory like any other program, in the fist available slot. The memory space used by DEBUG for the user program begins after the end of DEBUG code. If an .EXE or. COM.

EXPLORE THE VARIOUS FEATURES OF DEBUG COMMANDS


Command mode, indicated by the presence of the DEBUG command prompt (a hyphen), is the mode that DEBUG starts in. DEBUG maintains a set of variables that it uses to store a target program's CPU registers A : Assemble Command The Assemble command (A) is used to enter assembly mode. In assembly mode, DEBUG prompts for each assembly language statement and converts the statement into machine code that is then stored in memory. The optional start address specifies the address at which to assemble the first instruction. The default start address is 100h. A blank line entered at the prompt causes DEBUG to exit assembly mode. Syntax: A [address] C: Compare Command The Compare command (C) compares two memory regions. All differences will be listed, both addresses are displayed, with their respective data bytes. -C 0100 l 2 0200 1234:0100 E9 65 1234:0200 1234:0101 01 02 1234:0201 Syntax: C range address D: Dump Command The Dump command (D), when used without a parameter, causes DEBUG to display the contents of the 128-byte block of memory starting at CS:IP if a target program is loaded, or starting at CS:100h if no target program is loaded. The optional range parameter can be used to specify a starting address, or a starting and ending address, or a starting address and a length. Syntax: D [range] #D $F000:FFF6 F: Fill command The Fill command (F) fills a memory regions with a byte pattern. To fill for example the first 8000h bytes of current data segment with pattern 55 AA, enter: -F 0 L 8000 55 AA Syntax: F range list H: Hex Command: The Hex command (H) computes the sum and difference of two hex numbers. Syntax: H value1 value2 I : Input Command The Input command (I) causes DEBUG to read and display the value from the 8-bit I/O port specified by the required port parameter. Syntax: I port

EXAMPLE OF DEBUG

0100 MOV AX, 24B6 0103 MOV DI, 85C2 0106 MOV DX, 5F93 0109 MOV SP, 1236 010C PUSH AX

010D PUSH DI 010E INT 3 DISPLAY THE STACK CONTENTS AFTER EXECUTION: -D 1230 123F

DISPLAY THE ASCII CHARACTER SET


.CODE MOV AH, 02 MOV CX,256 MOV DL,0 LP1: INT 21H INC DL LOOP LP1 MOV AH,40H INT 21H END ;SET O/P FUNCTION

CONVERT A NUMBER FROM ASCII CHARACTER SET TO BCD NUMBER


. MODEL SMALL . STACK . DATA . CODE MOV AX, 3638H MOV BX, 3030H MOV CL, 04H SHL AL, CL ROR AX, CL INT 21H END

CONVERT A BCD NUMBER INTO ASCII CHARACTERS


DATA SEGMENT PBCD DB 63H DIG1 DB ? DIG2 DB ? ASC1 DB ? ASC2 DB ? DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AL, PBCD AND AL, 0FH MOV DIG1, AL ADD AL, 30H MOV ASC1, AL MOV AL, PBCD AND AL, 0F0H MOV CL, 04H ROL AL, CL MOV DIG2, AL ADD AL, 30H MOV ASC2, AL MOV AX,4C00H INT CODE ENDS END START 21H

FIND ADDITION OF TWO BCD NUMBERS


.MODEL TINY .CODE MOV BX,1234H MOV CX,7698H MOV AL,BL ADD AL,CL DAA MOV DL,AL MOV AL,BL ADC AL,CH DAA MOV DH,AL MOV AH,4CH INT 21H END

FIND ADDITION OF N BCD NUMBERS


DATA SEGMENT ARRAY DW 0001H,0002H,0003H,0004H,0005H M DW 5H SUM DW 2 DUP(?) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV CX,M MOV AX,0 MOV SI,AX START_LOOP: ADD AX,ARRAY[SI] ADD SI,2 LOOP START_LOOP MOV SUM,AX INT 3 CODE ENDS END START

Potrebbero piacerti anche