Assembly language lab [AL Fundamentals] using emu8086
1. printing ‘hello world’ 7. mov ax,@data 10. ret
1. org 100h 8. mov ds,ax
2. .data =======division======
9. mov dx, offset var1
3. var1 DD "Hello 10. mov ah,09h 1. org 100h
World" 11. int 21h 2. num1 DD 1000 ;what is
4. .code 12. ret ?100,1000
5. ;mov dh,0E
3. num2 DD 100 ;what if
6. mov ah,2 =======or ========
?110,110
7. mov DL,'H'
8. int 21h 1. include '[Link]' 4. .code
9. mov DL,'E' 2. org 100h 5. mov Ax,num1
10. int 21h 3. printn "Hello World$" 6. mov Bx,num2
11. mov DL,'L' ;$ to indicate the end 7. div Bx
12. int 21h of the string ;Dx:10,DX:0000 why?
13. mov DL,'L' 4. ret 8. Ret
14. int 21h =======Or=======
15. mov DL,'O' 2. Add,sub,div,Mult, 1. org 100h
16. int 21h 3. org 100h 2. mov Ax,1004h
17. ;mov dl,032 4. .data ;division from
18. ;int 21h 5. var1 db 5 ;200 two registers
19. mov DL,'W' 3. mov dx,1004h
6. var2 db -3 ;100
20. int 21h 4. mov Bx,1234h
7. .code
21. mov DL,'O' 5. div Bx
22. int 21h 8. MOV AL, var1
6. ret
23. mov DL,'R' ;addition & subtraction
24. int 21h 9. ADD AL, var2 ===multiplication===
25. mov DL,'L' 10. inc al
1. org 100h
26. int 21h 11. sub al,3 ;which carry
2. mov AL,14h
27. mov DL,'D' flag is affected
3. mov BL,24h
28. mov cx,var1 12. ret ;o/p:00
29. int 21h 4. MUL BL ;AH=02 AL=D0
30. ret ======or====== 5. Ret
======or======
========or========== 1. org 100h 1. org 100h
2. .data 2. mov Ax,1234h
1. .model small;tiny 3. var1 dd 200 3. mov BX,45F4h
,large 4. var2 dd 56 4. MUL BX
2. .stack 100h 5. .code ;AX=5D90,DX=04F9
3. org 100h 6. MOV AX, var1 1. Ret
4. .data 7. ADD AX, var2 1. org 100h
5. var1 DB "Hello 2. mov Ax,10
8. inc AX
3. mov BX,10
World$" ;$ to indicate 9. sub AX,260 ; which 4. MUL BX
the end of the string carry flag will be 5. Ret
6. .code affected? clc
Assembly language lab [AL Fundamentals] using emu8086
3. Write an assembly language program 17. int 21h
to compute the sum of the first 5 18. mov dl,0Ah ;to Disp characters
natural numbers. 19. int 21h
1. .data 20. loop L1 ; repeat the outer loop
2. sum dw 1 b)
3. limit dw 5
4. .code
5. mov ax,0
6. mov cx,limit
7. lable1:
8. ADD ax,sum
9. inc sum
1. org 100h
10. loop lable1 ;output 0Fh,
2. .data
3. count DW ?
4. Write an assembly language program
4. num DW 1
to print the following patterns:
5. .code
a)
6. mov ah,0Eh
7. mov cx,5 ; set outer loop count
8. L1:
9. mov count,cx ; save outer loop count
10. mov cx,num ; set inner loop count
11. L2:
Hint outer loop:5 12. mov ah,02h
Inner loop 4 13. mov dl,2Ah
1. org 100h 14. int 21h
2. .data 15. loop L2 ; repeat the inner loop
3. count DW ? 16. mov cx,count ; restore outer loop
4. .code count
5. mov ah,0Eh 17. mov dl,0Dh ;line feed
6. mov cx,5 ; set outer loop count 18. int 21h
7. L1: 19. mov dl,0Ah ;to Disp characters
8. mov count,cx ; save outer loop count 20. int 21h
9. mov cx,4 ; set inner loop count 21. inc num
10. L2: 22. loop L1 ; repeat the outer loop
11. mov ah,02h
12. mov dl,2Ah
13. int 21h
14. loop L2 ; repeat the inner loop
15. mov cx,count ; restore outer loop count
16. mov dl,0Dh ;line feed
Assembly language lab [AL Fundamentals] using emu8086
5. ===========ARRAY============ 15. mov cx,num
5.1 Program to add an array and 16. printn
place its sum in variable Result; 17. print 'The reverse order is:'
1. .org 100h 18. l2:
2. include '[Link]' 19. pop bx
3. LEA BX, ARRAY; 20. mov dx,bx
4. MOV CX, 6 21. mov ah,02h
5. MOV AX, 0 22. int 21h
6. L1: 23. loop l2
7. ADD AX, [BX]; 24. ret
8. ADD BX, 2; 7. ====INTERFACING IN AL =======
9. loop L1 7.1 On Emu8086 emulator there are many
10. print "The result of the sum: " examples how virtual device works.
11. MOV RESULT, AX; i. Robot
12. mov ah,02h ii. Traffic light
13. mov dx,RESULT iii. Display Test
14. int 21h iv. Stepper Motor
15. ARRAY DW 1,2,3,4,5,6 v. Simple etc.
16. RESULT DW 0 8. ==MISCELLANEOUS PROBLEMS==
17. Ret 8.1 Read a number from keyboard and
determine whether it is +ve/-ve
6. ===========STACK===========
8.2 Read sixteen-bit number from
6.1 Write an assembly language
keyboard and determine whether it is
program to display the reverse of a
Even/ODD
number or digits. Ex: input=12345,
8.3 Read Two 8-bit integer numbers from
output=54321
keyboard and calculate Addition,
Input=Abebe, output=ebebA
subtraction, Division and
1. org 100h
Multiplication using procedures
2. include '[Link]'
8.4 Write an AL program to display your
3. .data
name, ID and section.
4. num dw 1
8.5 For these sample code:
5. .code
ARRAY DW 1,2,3,4,5,6
6. mov cx,5
8.5.1 How you can access each
7. print 'Enter five integer numbers: '
element?
8. l1:
8.5.2 update element 4 to 8.
9. mov ah,01h
8.6 For those palindrome words and
10. int 21h
numbers: redivider, deified, civic,
11. mov ax,ax
radar, level, rotor, kayak, reviver,
12. push ax racecar, madam,
13. inc num refer,111,121,818..etc write an
14. loop l1 assembly language program to
Assembly language lab [AL Fundamentals] using emu8086
check whether it is PALINDROME have one possible operand, having
or not PALINDROME using stacks. Two possible operands, Three, etc.…
8.7 Read about the instruction codes in
the resource attached. Example
instruction codes having no operands,
=================GOOD LUCK==================