Debug Commands: 1. Introduction To Dos Debug Command and Masm

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 38

1. INTRODUCTION TO DOS DEBUG COMMAND AND MASM.

DEBUG COMMANDS

COMMAND -r
CHARACTER
Format/Formats -r <ENTER> -r reg <Enter>
old contents: New contents
Functions Displays all Registers and flags Display specified register contents and
modify with the entered new contents.

COMMAND -d
CHARACTER
Format/Formats -d <ENTER> -d SEG:OFFSET1
OFFSET2<ENTER>
Functions Display 128 memory locations of Display memory contents in SEG from
RAM starting from the current OFFSET1 to OFFSET2.
display pointer.

COMMAND -e
CHARACTER
Format/Formats -e <ENTER> -e SEG:OFFSET1 <ENTER>
Functions Enter Hex data at current display Enter data at SEG: OFFSET1 byte by
pointer SEG: OFFSET. byte. The memory pointer is to be
incremented by space key, data entry is
to be completed by pressing the
<ENTER> key.

COMMAND -f
CHARACTER
Format/Formats -f SEG: OFFSET1 PFFSET2 -f SEG: OFFSET1 OFFSET2 BYTE1,
BYTE <ENTER> BYTE2, BYTE3<ENTER>
Functions Fill the memory area starting Fill the memory area as above with the
from SEG: OFFSET1 to sequence BYTE1, BYTE2,BYTE3,etc.
OFFSET2 by the byte BYTE.

COMMAND -a
CHARACTER
Format/Formats -a <ENTER> -a SEG: OFFSET <ENTER>
Functions Assemble from the current CS: Assemble from the entered instruction
IP. from SEG: OFFSET address.
COMMAND -u
CHARACTER
Format/Formats -u <ENTER> -u SEG: OFFSET <ENTER>
Functions Unassemble from the current CS: Unassemble from the entered
IP. instruction from SEG: OFFSET
address.

COMMAND -g
CHARACTER
Format/Formats -g <ENTER> -g =OFFSET <ENTER>
Functions Execute from the current CS: IP. Execute from the OFFSET in the
By modifying CS and IP using R current CS.
command this can be used for any
address.

COMMAND -s
CHARACTER
Format/Formats -s SEG: OFFSET1 to OFFSET2 -s SEG: OFFSET <ENTER>
BYTE/BYTES <ENTER>
Functions Unassemble from the current CS: Searches a BYTE or string of BYTES
IP. separated by ‘,’ in the memory block
SEG: OFFSET1 to OFFSET2, and
displays all the offsets at which the
byte or string of bytes is found.

COMMAND -q
CHARACTER
Format/Formats -q <ENTER>
Functions Quit the DEBUG and return to
DOS.

COMMAND -t
CHARACTER
Format/Formats -t SEG: OFFSET <ENTER>
Functions Trace the program execution by
single stepping starting from the
address SEG: OFFSET.
COMMAND -m
CHARACTER
Format/Formats -m SEG: OFFSET1 OFFSET2
NB <ENTER>
Functions Move NB bytes from OFFSET1
to OFFSET2 to segment SEG.

COMMAND -c
CHARACTER
Format/Formats -c SEG: OFFSET1 OFFSET2 NB
<ENTER>
Functions Copy NB bytes from OFFSET1
to OFFSET2 to segment SEG.

COMMAND -n
CHARACTER
Format/Formats -n FILENAME.EXE <ENTER>
Functions Set Filename pointer to
FILENAME.

COMMAND -l
CHARACTER
Format/Formats -l <ENTER>
Functions Load the file FILENAME.EXE as
set by the –n command in the
RAM and set the CS: IP at the
address at which the file is
loaded.
2. W. A. P. FOR ADDITION/SUBTRACTION OF TWO NUMBERS.

data segment

a db 20h
b db 10h
c db ?
d db ?

data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov al,a
mov bl,b
add al,bl
mov c,al
mov al,00h

mov al,a
mov bl,b
sub al,bl
mov d,al

mov ah,4ch
int 21h
code ends

end start
3. W. A. P. FOR MULTIPLICATION/DIVISION OF TWO NUMBERS.
data segment

a db 20h
b db 10h
c db ?
d db ?

data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov al,a
mov bl,b
mul al,bl
mov c,al
mov al,00h

mov al,a
mov bl,b
div al,bl
mov d,al

mov ah,4ch
int 21h
code ends

end start
4. W.A.P. FOR ADDITION OF N(TEN) SERIES OF NUMBER STORE IN
DATA SEGMENT.

data segment

numlist db 10h,20h,30h,40h,50h,60h,70h,80h,90h,99h
count equ 10h
result dw 01h

data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov cx,count
xor ax,ax
xor bx,bx
mov si,offset numlist

again: mov bl,[si]


add ax,bx
inc si
dec cx
jnz again
mov di,offset result
mov [di],ax
mov ah,4ch
int 21h
code ends

end start
5. W.A.P. TO FIND OUT MINIMUM/MAXIMUM NUMBER FROM GIVEN
SERIES OF NUMBER.

;to find minimum number

data segment

list db 11h,45h,26h,05h,78h
count EQU 04h
result db ?

data ends

code segment
assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
mov cl,count
mov si,offset list
xor ax,ax
mov al,[si]

again:cmp al,[si+1]
jl next
mov al,[si+1]

next:inc si
dec cl
jnz again

mov bl,al
mov si,bl
mov ax,4c00h
int 21h

code ends
end start

maximum
data segment

list db 10h,20h,30h,40h,50h
count equ 05h
largest dw 01h
data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov si,offset list
mov cl,count
mov al,[si]

again: cmp al,[si+1]


jnl next
mov al,[si+1]

next: inc si
dec cl
jnz again
mov si,offset largest
mov [si],al
mov ah,4ch
int 21h
code ends

end start
6. W.A.P. TO FIND OUT NUMBER OF EVEN/ODD NUMBER FROM
GIVEN SERIES OF NUMBER.
; to find even or odd no. in given series

data segment

list db 10h,20h,31h,42h,53h,89h,78h,90h,12h
count EQU 09h
result1 db ?
result2 db ?

data ends

code segment
assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
mov cl,count
mov si,offset list
xor ax,ax
xor bx,bx
xor dx,dx

again:mov al,[si]
ror al,01h
jc odd1
inc bl
jmp next

odd1:inc dl

next:inc si
dec cl
jnz again

mov result1,bl
mov result2,dl
mov ax,4c00h
int 21h

code ends
end start
7. W.A.P. TO FIND OUT NUMBER OF POSITIVE/NEGATIVE NUMBER
FROM GIVEN SERIES OF NUMBER.

data segment

list dw 2579h,0a500h,0c009h,0159h,0b900h
count equ 05h

data ends

code segment

assume cs:code,ds:data

start: xor bx,bx


xor dx,dx
mov ax,data
mov ds,ax
mov cl,count
mov si,offset list

again: mov ax,[si]


shl ax,01
jc neg
inc bx
jmp next

neg: inc dx
next: add si,02
dec cl
jnz again

mov ah,4ch
int 21h

code ends
end start
8. W.A.P. TO ARRANGE ARRAY OF GIVEN NUMBER IN ASCENDING
/DESCENDING ORDER.

data segment

values db 87h,56h,42h
result db ?

data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
initial:lea bx,values
mov dl,00h
mov cl,02h
check: mov al,[bx]
inc bx
mov ah,[bx]
cmp al,ah
jc nxtbyt
mov ch,[bx]
mov [bx],al
dec bx
mov [bx],ch
inc bx
mov dl,01h
nxtbyt: dec cl
jnz check
mov dh,dl
ror dh,1
jc initial
int 3

code ends
end start
decendeing

data segment

values db 87h,56h,42h
result db ?

data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
initial:lea bx,values
mov dl,00h
mov cl,02h
check: mov al,[bx]
inc bx
mov ah,[bx]
cmp al,ah
jc nxtbyt
mov ch,[bx]
mov [bx],al
dec bx
mov [bx],ch
inc bx
mov dl,01h
nxtbyt: dec cl
jz check
mov dh,dl
ror dh,1
jc initial
int 3

code ends
end start
9. W.A.P. TO CHECK THE PARITY OF GIVEN NUBER.
10. W.A.P. TO SEPARATE NIBBLE OF GIVEN 16-BIT NUMBER.
;to separate hexadecimal no. into four nibbles

data segment
num dw 3425h
no1 db ?
no2 db ?
no3 db ?
no4 db ?
data ends

code segment
assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
mov ax,num
and ax,000fh
mov no1,al
mov bx,num
and bx,00f0h
mov cl,04h
ror bx,cl
mov no2,bl
mov dx,num
and dx,0f00h
mov cl,08h
ror dx,cl
mov no3,dl
mov ax,num
and ax,0f000h
mov cl,04h
rol ax,cl
mov no4,al

mov ax,4c00h
int 21h
code ends
end start
11. W.A.P. TO PERFORM BCD ADDITION.
;to perform BCD addition

data segment

no1 EQU 91h


no2 EQU 52h
result db ?

data ends

code segment

assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov bl,no1
xor ax,ax
mov al,no2
add al,bl
daa
mov result,al
jnc next
inc [result+1]

next:mov ax,4c00h
int 21h

code ends
end start
12. (A)W.A.P. FOR BCD TO SEVEN SEGMENT CODE CONVERSION
USING LOOK UP TABLE METHOD

;to convert bcd 0to9 to their equivalent seven segment codes

data segment
codes db 03h,9fh,25h,0dh,99h,49h,41h,1fh,01h,0fh
inport db 05h
outport db 01h dup(?)

data ends

code segment

assume cs:code,ds:data

start:

mov ax,data
mov ds,ax
lea bx,codes
mov al,inport
xlat ;translate bcd in seven segment
mov outport,al
mov ax,4c00h
int 21h

code ends
end start
(B)W.A.P. FOR BINARY TO GRAY CODE CONVERSION USING
LOOK UP TABLE METHOD
13. (A)W.A.P. FOR THE ADDITION OF TWO 3X3 MATRICES.THE
MATRICES ARE STORED IN THE FORM OF LISTS(ROW
WISE).STORE THE RESULT IN THE THIRD LIST.

data segment

dim equ 09h


mat1 db 01,02,03,04,05,06,07,08,09
mat2 db 01,02,03,04,05,06,07,08,09
rmat3 db ?

data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov cx,dim
mov si,offset mat1
mov di,offset mat2
mov bx,offset rmat3
next: xor ax,ax
mov al,[si]
add al,[di]
mov word ptr [bx],ax
inc si
inc di
add bx,02
loop next
mov ah,4ch
int 21h
code ends
end start
(B)W.A.P. FOR THE MULTIPLICATION OF TWO 3X3 MATRICES.THE
MATRICES ARE STORED IN THE FORM OF LISTS(ROW
WISE).STORE THE RESULT IN THE THIRD LIST.
data segment

rocol equ 03h


mat1 db 05h,09h,0ah,03h,02h,07h,03h,09h,09h
mat2 db 09h,07h,02h,01h,0h,0dh,07h,06h,02h
pmat3 db ?

data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov ch,rocol
mov bx,offset pmat3
mov si,offset mat1
nextrow:mov di,offset mat2
mov cl,rocol
nextcol:mov dl,rocol
mov bp,0000h
mov ax,0000h
sahf
next_ele:mov al,[si]
mul byte ptr[di]
add bp,ax
inc si
add di,03
dec dl
jnz next_ele
sub di,08
sub si,03
mov [bx],bp
add bx,02
dec cl
jnz nextcol
add si,03
dec ch
jnz nextrow
mov ah,4ch
int 21h

code ends
end start
14. (A) W.A.P.TO CONVERT FROM BCD TO ASCII USING PROCEDURE.

;to convert bcd into ascii

data segment

no db 17h
ascii db ?
ascii1 db ?

data ends

code segment

assume cs:code,ds:data

start:
mov ax,data
mov ds,ax
mov si,offset no
mov al,[si]
and al,0fh
mov bl,al
xor ax,ax
mov al,[si]
and al,0f0h
mov al,cl
mov cl,04h
ror al,cl
mov dl,30d
add bl,dl
add al,dl
mov ascii1,al
mov ascii,bl
mov ax,4c00h
int 21h

code ends
end start
(B) W.A.P.TO CONVERT FROM BINARY TO ASCII USING PROCEDURE.
(C ) W.A.P.TO CONVERT FROM BCD TO BINARY USING FAR
PROCEDURE.
;to comvert bcd into binary

data segment

bcd db 17h
bin db ?

data ends

stack_seg segment

dw 100 dup(0)
top_stack label word

stack_seg ends

code segment

assume cs:code,ds:data,ss:stack_seg

start:
mov ax,data
mov ds,ax
mov ax,stack_seg
mov ss,ax
mov sp,top_stack
mov al,bcd
call bcd_bin
mov bin,al
jmp exit

bcd_bin proc near

pushf
push bx
push cx
push bp
mov bl,al
and bl,0fh
and al,0f0h
mov cl,04h
ror al,cl
mov bh,0ah
mul bh
add al,bl
pop bp
pop cx
pop bx
popf
ret

bcd_bin endp
exit:mov ax,4c00h
int 21h

code ends
end start
15. W.A.P. TO FIND THE FACTORIAL OF THE GIVEN NUMBER.

data segment

input db 04h
result dw ?

data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov ax,0001h
mov bl,input
again: mul bl
dec bl
jnz again
mov result,ax
int 3
code ends
end start
16. W.A.P FOR COPY A STRING FROM ONE LOCATION TO ANOTHER
LOCATION IN MEMORY.

assume cs:code, ds:data

data segment
sourcestrt equ 2000h
deststrt equ 3000h
count equ 0fh
data ends

code segment
start: mov ax,data
mov ds,ax
mov es,ax
mov si,sourcestrt
mov di,deststrt
mov cx,count
cld
rep movsw
mov ah,4ch
int 21h

code ends
end start
17. W.A.P. FOR CAMPARISION OF TWO STRING WHETHER IT IS
EQUAL OR NOT?

data segment

s1 db 'ankit','$'
s2 db 'maduri','$'
a1 db 'compared','$'
a2 db 'notcompared','$'

data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov si,offset s1
mov di,offset s2
cld
mov cx,06h
back: mov al,[si]
mov ah,[di]
inc si
inc di
dec cx
jz done
cmp ah,al
je back
jmp terminate

done: mov ah,09h


mov dx,offset a1
int 21h
jmp en

terminate: mov ah,09h


mov dx,offset a2
int 21h

mov ax,4c00h
en: int 21h
code ends
end start
18. W.A.P. TO DISPLAY MESSAGE”THE STUDY OF MICROPROCESSOR
IS INTERESTING” ON THE CRT SCREEN OF COMPUTER.

data segment
msg db 'THE STUDY OF MICROPROCESSOR IS INTERESTING$'
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax

mov ah,09h
lea dx,msg
int 21h

mov ah,4ch
int 21h

code ends
end start
19. W.A.P. TO REVERSE THE GIVEN STRING.

data segment
msg db 'Welcome to My world$'
len equ ($-msg)
msg2 db len dup('$')
data ends

code segment

assume cs:code, ds:data

start: mov ax, data


mov ds,ax
lea si,msg
mov bx,len-1
mov cx,bx
dec bx
lea di, msg2
add si,bx

back: mov al,[si]


mov [di],al
dec si
inc di

loop back

mov ah,09h
lea dx,msg2
int 21h
mov ah,4ch
int 21h

code ends
end start
20. W.A.P. TO CHECK WHEATHER STRING IS PALINDROM OR NOT ?

data segment
s1 db 'nammam','$'
a1 db 'pelindrome','$'
a2 db 'not pelindrom','$'
data ends

code segment

assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov si,offset s1
mov di,offset s1
add di,06h
mov cx,03h

uper: cmp si,di


jz done
inc si
dec di
dec cx
jnz uper
mov ah,09h
mov dx,offset a1
int 21h
jmp en

done: mov ah,09h


mov dx,offset a2
int 21h

en: mov ax,4ch


int 21h

code ends
end start
21. W.A.P TO CONVERT LOWERCASE TO UPPERCASE.

data segment
str1 db 'svapnil$'
str2 db 8 dup('$')
data ends

code segment

assume cs:code, ds:data, es:data

start: mov ax,data


mov ds,ax
mov es,ax
mov cl,07h
mov dx,0000h
lea si,str1
lea di,str2
again: mov bl,[si]
and bl, 11011111b
mov [di],bl
inc si
inc di
dec cl
jnz again

mov ah,09h
lea dx,str2
int 21h

mov ah,4ch
int 21h

code ends
end start
22. W.A.P CONVERT DECIMAL TO HEX.

code segment

assume cs:code
start : mov ah,2ah
int 21h

mov ax,4c00h
int 21h

code ends
end start
23. W.A.P TO DISPLAY CURRENT DATE.

code segment

assume cs:code
start : mov ah,2ah
int 21h

mov ax,4c00h
int 21h

code ends
end start
24. W.A.P. TO CONVERT HEX TO OCTAL.

data segment
input dw 1a3bh
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax

mov dx,input
mov cx,0403h

mov al,07h
and al,dl
mov bl,al

mov al,38h
and al,dl
ror al,3
mov bh,10h
mul bh
mov bh,al
add bl,bh

mov ax,0000h
mov bh,al

mov ax,0e00h
and ax,dx
ror ax,9
mov ch,10h
mul ch
add bh,al

mov ax,70000h
and ax,dx
ror ax,12
mov dl,al

mov al,80h
and al,dh
ror al,6
mov dh,al
mov ax,4c00h
int 21h

code ends
end start
25. W.A.P. TO FIND THE AVERAGE OF NUMBER.
26. W.A.P. TO CHANGE THE SIZE OF CURSOR.

code segment

assume cs:code

start:
mov ah,01h
xor cx,cx
mov cl,0
mov ch,0
int 10h

int 3

code ends
end start
27. W.A.P TO CHECK THE PASSWORD.

You might also like