eee316: logical instructions, jump commands, loops and arrays in assembly language
TRANSCRIPT
Department of Electrical and Electronic Engineering
Bangladesh University of Engineering and Technology
Course No.: EEE 316 Group No.: 05
Course Name: Microprocessor and Interfacing Sessional.
Experiment No.: 02, 03, 04
Experiment Name:
Logical Instructions, Jump Commands, LOOPs and Arrays in Assembly Language
Date of Performance: 21/01/2014 Name: Musbiha Binte Wali
Date of Submission: 25/01/2014 Level: 3 Term: 2
Section: A1
Student No.: 0906022
Objective:
To be familiar with the operations of Arrays in assembly language programming.
Home Task: To write complete assembly language for the operation of
finding out how many numbers divisible by 5 lie in between two given input numbers DATA1 and DATA2.
Also finding out those numbers.
Code:
CODE SEGMENT
ASSUME CS:CODE, DS:CODE
;
ORG 100H
;
MAIN: MOV AX, CS
MOV DS, AX
;
MOV BX, 0
MOV CX, 0
MOV DX, 0
MOV CL, DATA2
SUB CL, DATA1
ADD CL, 1
beginn: ;LOOP STARTS
MOV AL, CL
ADD AL, DATA1
SUB AL, 1
CBW ;AH will have the remainder
MOV BL, 5
DIV BL
CMP AH, 0
JZ AN_
JMP END_
AN_:
ADD DL, 1 ;When Remainder is zero
MOV AL, CL
ADD AL, DATA1
SUB AL, 1
MOV BL,DL
MOV [ARR+BX-1], AL
END_:
loop beginn
;
MOV ANS, DL
MOV AH, 4CH
INT 21H
;
ORG 1500H
DATA1 DB 22
ORG 1510H
DATA2 DB 39
ORG 1540H
ANS DB ? ;how many numbers
ORG 1600H
ARR DB 80 DUP(0) ;solution array
;
CODE ENDS
END
END MAIN
Debug Results:
In each debugging, DATA1’s value is at 1410:1500.
DATA2’s value is at 1410:1510. Answer ANS’s value is at 1410:1540.
Answer ARRAY is at 1410:1600.
For DATA1= 2 and DATA2= 4, Answer=0 (at 1410:1540) and the Answer array contains no contents (at 1410:1600)
For DATA1= 14 and DATA2= 16, Answer=01 (at 1410:1540) and the Answer array contains one content which is 15 (at 1410:1600)
For DATA1= 22 and DATA2= 39, Answer=03 (at 1410:1540) and the Answer array contains three contents which are 35, 30, 25
(at 1410:1600)
For DATA1= 15 and DATA2= 50, Answer=08 (at 1410:1540) and the Answer array contains eight contents which are 50, 45, 40,
35, 30, 25, 20, 15 (at 1410:1600)
Lab Task: Taking an input array and reversing the case of each array-element; if any of them is digit, expressing that
as 10’s complement
Code: CODE SEGMENT
ASSUME CS:CODE, DS:CODE
;
ORG 100H
;
MAIN: MOV AX, CS
MOV DS, AX
;
ORG 100H
ARR_ DB '1','A' ,'a','2','3','4','7','5','G','h','4','k'; ;input array
ORG 1500H;
ANS DB 12 DUP(0);
MOV CX ,12;
MOV DL, 106;
LOOP1:
MOV BX,CX;
MOV AL,[ARR_+BX-1];
CMP AL,'9';
JG SKIP;
SUB DL,AL;
MOV AL, DL;
MOV DL,106;
MOV [ANS+BX-1],AL;
JMP EXIT_;
SKIP:
CMP AL,'Z';
JG SKIP1;
ADD AL,32;
MOV [ANS+BX-1],AL;
JMP EXIT_;
SKIP1:
SUB AL,32;
MOV [ANS+BX-1],AL;
EXIT_:
LOOP LOOP1;
MOV AH, 4CH
INT 21H
CODE ENDS
END MAIN
Result:
In debugging window, Input array is at 1413:0200.
Output array is at 1413:1500. Input array was: 1Aa23475Gh4k
Output array is: 9aA87635gH6K