Debug Commands: 1. Introduction To Dos Debug Command and Masm
Debug Commands: 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
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
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
end start
5. W.A.P. TO FIND OUT MINIMUM/MAXIMUM NUMBER FROM GIVEN
SERIES OF 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
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
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
code ends
end start
decendeing
data segment
values db 87h,56h,42h
result db ?
data ends
code segment
assume cs:code,ds:data
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
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
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
data ends
code segment
assume cs:code,ds:data
data ends
code segment
assume cs:code,ds:data
code ends
end start
14. (A) W.A.P.TO CONVERT FROM BCD TO ASCII USING PROCEDURE.
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
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
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
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
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
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
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
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.