Assembly Language Lab report input output loop

Assembly Language Lab report input output loop

Experiment No: 1
(i)
Experiment Name: Input and Output in assembly.
Objectives: To be able to take an input and print as an output.
Apparatus: MICROPROCESSOR EMULATOR 8086, Computer etc
Introduction:  In assembly it is not possible to take a number containing more than one digits at at a time or not possible to show a number containing more than one digit at once. We have to take user input one by one character and also print by one. So it is little bit difficult. Let’s see a program that will take a simple user input and will print the output.
We have to assign a value in 'AH' register and then occur an interrupt to take user input or show output in assembly.
For single character input we have to put '1' in AH
For   single character output we have to put '2' in AH
For   string output, put '9' in AH
Then call an interrupt to happen this. Generally call ‘INT 21H' for input and output.
Procedure:
1. Create: open emu8086 write a program after that save the program with .asm extension.
2. Compile: Emulator
3. Execute: Run
Code:  

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 .MODEL SMALL
 .STACK 100H

 .DATA
    PROMPT_1  DB  'Enter the Number : $'
    PROMPT_2  DB  0DH,0AH,'The Number is : $'

 .CODE
   MAIN PROC
     MOV AX, @DATA                ; initialize DS
     MOV DS, AX

     LEA DX, PROMPT_1             ; load and print PROMPT_1
     MOV AH, 9
     INT 21H

     MOV AH, 1                    ; read a Number
     INT 21H
     MOV BL, AL
                         
     LEA DX, PROMPT_2             ; load and print PROMPT_2
     MOV AH, 9
     INT 21H
   
     MOV AH, 2                        ; print the Number
     MOV DL, BL
     INT 21H

     MOV AH, 4CH                  ; return control to DOS
     INT 21H
   MAIN ENDP
 END MAIN

Result:


Conclusion: The program codes take an input and print as an output successfully.



(ii)
Experiment Name: Flow control loop (An assembly program that can and print 0-9).
Objectives: To be able to a print 0-9.
Apparatus: MICROPROCESSOR EMULATOR 8086, Computer etc
Introduction:  The JMP instruction can be used for implementing loops. The processor instruction set, however, includes a group of loop instructions for implementing iteration. The basic LOOP instruction has the following syntax − LOOP    label
Where, label is the target label that identifies the target instruction as in the jump instructions. The LOOP instruction assumes that the ECX register contains the loop count. When the loop instruction is executed, the ECX register is decremented and the control jumps to the target label, until the ECX register value, i.e., the counter reaches the value zero.
Procedure:
1. Create: open emu8086 write a program after that save the program with .asm extension.
2. Compile: Emulator
3. Execute: Run
Code: 
1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.MODEL SMALL
 .STACK 100H

 .DATA
    PROMPT  DB  'The counting from 0 to 9 is : $'

 .CODE
   MAIN PROC
     MOV AX, @DATA              
     MOV DS, AX

     LEA DX, PROMPT             
     MOV AH, 9
     INT 21H

     MOV CX, 10                 

     MOV AH, 2                    
     MOV DL, 48                  

     @LOOP:                     
       INT 21H                 

       INC DL                    
       DEC CX                   
     JNZ @LOOP                   

     MOV AH, 4CH                
     INT 21H
   MAIN ENDP
 END MAIN

Result:

Conclusion: The program code of taking single character input and printing it works successfully.
----

Assembly Language Lab report, Input and Output in assembly, Flow control loop Lab report, An assembly program that can and print 0-9 Lab report, microprocessor and assembly language lab, assembly language programming lab manual pdf, microprocessor 8086 lab report, assembly language Lab report notes pdf, assembly language programming questions and answers pdf Lab report, 8086 assembly language Lab report, assembly language projects pdf Lab report, assembly language example Lab report