LAB 1
1. Show how you can invoke DEBUG.
2. How can you display a list of all valid commands? Also, show the list of
commands displayed. What information is displayed in the list against
each command?
3. Show how you can execute the r command in different formats.
4. What is a register?
5. What is the difference between registers and flags?
6. Briefly explain the purpose of each register. For Example, exe
(accumulator) is a data register used by the CPU for arithmetic
operations.
LAB 2
TASK 2: [Ax=06AF]
mov ah,3
Solution:
LAB 3
TASK 2: PRACTICE AND DEMONSTRATE WITH EXAMPLE HOW LOOP AND JUMP COMMANDS
CAN BE USED.
Loop:
The loop instruction in Assembly language is used to implement a loop. It uses the ECX register
as a counter and decrements it by 1 at each iteration. When ECX reaches 0, the loop ends. If
ECX is not zero after a decrement, it jumps to the label provided to the loop instruction.
Example of loop usage in Assembly:
section .data
newline db 10, 0
section .text
global _start
_start:
mov ecx, 5
print_loop:
mov eax, ecx
add eax, '0'
mov edx, 1
mov ebx, 1
mov ecx, eax
mov eax, 4
int 0x80
; Print newline
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, 1
int 0x80
dec ecx
jnz print_loop
; Exit program
mov eax, 1
xor ebx, ebx
int 0x80
JUMP (JMP):
The jump command (often jmp in Assembly language) is used to transfer program control to a
different part of the program. It is an unconditional branch command that doesn't require any
condition to be met.
Example of jump usage in Assembly:
section .text
global _start
_start:
jmp _end
; This code will be skipped
_end:
; Execution continues here after the jump
In this example, the program control will immediately jump to the _end label, skipping any code
in between.
LAB 4
TASK 2. RUN AND TEST THE FOLLOWING EXAMPLE IN THE EMULATOR:
title Hello World Program
org 100h
.data
hello_message db 'Hello','World',0dh,0ah,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx,offset hello_message
INT 21H
mov ax,4C00h
INT 21H
main endp
end main
OUTPUT:
LAB 5
2. Write a program that input a character from user. If character is in lowercase, the program
will convert it to uppercase and will display it on console after conversion.
TITLE PGM_1: CASE CONVERSTION PROGRAM
- MODEL SMALL
- STACK 100H
- DATA
CR EQU 0DH
LF EQU 0AH
MSG1 DB 'ENTER A LOWER CASE LETTER $'
MSG2 DB 0DH,0AH, 'IN UPPER CASE ITS IS: '
CHAR DB? , '$'
-CODE
MAIN PROC
;INITIALIZE DS
MOV AX,eDATA
MOV DS,AX
;print user prompt
LEA DX,MSG1
MOV AH,9
INT 21H
;input a char and cover to upper case
MOV AH,1
INT 21H
SUB AL, 20H
MOV CHAR, AL
;display on the next line
LEA DX,MSG2
MOV AH,9
INT 21H
;DOS EXIT
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
LAB 6
1. Will the following code jump to the label named Target?
Mov ax, 81
cmp AX, 26h
jg Target
Yes, The following code will jump to the label named Target.
2. Will the following code jump to the label named Target?
Mov ax,-30
cmp ax,-50
jg Target
Yes the following code will jump to the label named Target.
4. Write a program to add first ten numbers. The result should be stored in register bl.
Title add_first 10 number
org 100h
.data
num db 0h,1h,2h,3h,4h,5h,6h,7h,8h,9h
.code
mov di,offset num
mov cx,10
mov bl,0
Loop1:
add bl, [di]
inc di
loop Loop1
ret
LAB 7
Task 2. Write a near procedure that cubes the contents of the CX Register. Call
this procedure in your program.
Task 3. Trace the program "INT 10h" step by step until the instruction "IRET" is executed.
Keep your eyes on the content of register SP and dump/record the stack segment after each
step. Record what is pushed into the stack when it goes to the interrupt service routine and
what are popped out from the stack when it goes out of the interrupt service routine. Why
does it have to do so?
LAB 8
Task 2. Write a program that takes two unsigned integers from the user, compares them and
displays the largest one on the screen.
Task 3. Write a program that takes two unsigned integers from the user, compares them and
displays the smallest one on the screen.