You are on page 1of 7

Don Bosco Institute of Technology, Kulra(W)

Department of Computer Engineering


CSL602: System Software Lab
2020-21

Experiment Experiment Name


No.
1 Introduction to System Software Lab

Student Name: Reena Kale


Roll No : 23

Objective:

∙ Students will be able to revisit the concepts of assembly language programming

∙ Students will be able to write an assembly program for a hypothetical machine


using the given specification.

Task to be performed:
A. Execute the program in Emu8086 (using the required syntax)

ORG 100H
MOV AX,4000H
MOV DS,AX
MOV AL,[8000H]
CMP AL,00H
JE LABEL1
CMP AL,01H
JE LABEL1
CMP AL,08H
JA LABEL2
MOV BX,0000H
MOV BL,AL
DEC BL
LABEL:MUL
BX
DEC BL
JNZ LABEL
MOV[8001H],AX
JMP END
LABEL1:MOV [8001H],01H
JMP END
LABEL2:MOV [8001H],00H
END:RET

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

B. Writing ALP using a given specification.Write Assembly language program for


adding 3 numbers.

Type of Statement Assembly Location Counter Machine Code


(IS/DL/AD) Language Program (LC) (eg. + 09 0 509)
AD START 101

IS READ X 101 09 0 110

IS READ Y 102 09 0 111

IS READ Z 103 09 0 112

IS MOVER AREG,X 104 04 1 110

IS ADD AREG,Y 105 01 1 111

IS ADD AREG,Z 106 01 1 112

IS MOVEM 107 05 1 113


AREG,RESULT

IS PRINT RESULT 108 10 0 113

IS STOP 109 00 0 000

DL X DS 1 110

DL Y DS 1 111

DL Z DS 1 112

DL RESULT DS 1 113

AD END 114

∙ Write Assembly language program for a hypothetical machine for factorial of a

number in the format below. Also construct a symbol table for the same.

Type of Assembly Language Program Location Machine Code


Statement Counter (LC) (eg. + 09 0 509)
(IS/DL/AD
)
AD START 101

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

IS READ A 101 09 0 120

IS MOVER AREG, A 102 04 1 120

IS COMP AREG, EIGHT 103 06 1 123

IS BC GT,LAST 104 07 1 118

IS MOVER BREG, ONE 105 04 2 121

IS MOVEM BREG, RESULT 106 05 2 124

IS COMP AREG, ZERO 107 06 1 122

IS BC EQ,LAST 108 07 3 118

IS COMP AREG, ONE 109 06 1 121

IS BC EQ, LAST 110 07 3 118

IS MOVER CREG , A 111 04 3 120

IS SUB CREG, ONE 112 02 3 121

IS AGAIN : MUL AREG , CREG 113 03 1

IS SUB CREG, ONE 114 02 3 121

IS COMP CREG, ZERO 115 06 3 122

IS BC GT, AGAIN 116 07 4 113

IS MOVEM AREG, RESULT 117 05 1 124

IS LAST : PRINT RESULT 118 10 0 124

IS STOP 119 00 0 000

DL A DS 1 120

DL ONE DC =’1’ 121

DL ZERO DC =’0’ 122

DL EIGHT DC =’8’ 123

DL RESULT DC =’0’ 124

AD END 125

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

Symbol Table:

Symbol ML Defined Used Length/Value

A 120 Y Y 1

ONE 121 Y Y 1

ZERO 122 Y Y 0

EIGHT 123 Y Y 8

RESULT 124 Y Y 1

AGAIN 113 Y Y 1

LAST 118 Y Y 1

Theory & Algorithm : Instructions used:


MOV instruction simply means to move contents. MOV instruction
copies the source operand to destination operand. In this process the
source operand is not affected.
Syntax: MOV Destination , Source The flags are not affected by
MOV instruction.
However, there are certain restrictions while transferring data. •
Memory → Memory • Immediate → Segment Register • Segment
Register → Segment Register These transfers are not valid. Except
for these, any MOV instruction is a valid instruction.
Eg: MOV BX, 0DE23H MOV AX, 3000H MOV CX, [0800H]

The MUL/IMUL Instruction


There are two instructions for multiplying binary data. The MUL
(Multiply) instruction handles unsigned data and the IMUL (Integer
Multiply) handles signed data. Both instructions affect the Carry
and Overflow flag.
The syntax for the MUL/IMUL instructions is as follows −
MUL/IMUL multiplier
Multiplicand in both cases will be in an accumulator, depending
upon the size of the multiplicand and the multiplier and the

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

generated product is also stored in two registers depending upon the


size of the operands.
When two bytes are multiplied −
The multiplicand is in the AL register, and the multiplier is a byte
in the memory or in another register. The product is in AX.
High-order 8 bits of the product is stored in AH and the low-order 8
bits are stored in AL.
When two one-word values are multiplied −
The multiplicand should be in the AX register, and the multiplier is
a word in memory or another register. The resultant product is a
doubleword, which will need two registers. The high-order
(leftmost) portion gets stored in DX and the lower-order (rightmost)
portion gets stored in AX.

CMP instruction:
For comparison, it subtracts the source operand from the
destination operand but does not store the result anywhere. The
flags are affected depending upon the result of the subtraction. If
both of the operands are equal, zero flag is set. If the source
operand is greater than the destination operand, carry flag is set or
else, carry flag is reset.
The DEC Instruction
The DEC instruction is used for decrementing an operand by one. It
works on a single operand that can be either in a register or in
memory.
Syntax:
The DEC instruction has the following syntax −
DEC destination
The operand destination could be an 8-bit, 16-bit or 32-bit operand.
Eg: DEC BX DEC CH
Algorithm:
Step1 : Initialization of data segment
Step2 : Store input in a register
Step3 : If input is 0 then store 1 as result
Step4 : If input is 1 then store 1 as result

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

Step5 : If input is greater than 8 store 0 as result (invalid)


Step6 : Else initialize counter by copying input in count register and
decrement by 1
Step7 : Multiply input with the count until count is 0
Step8 : Store result in the desired location

Program Code:

Course In-charge: Ditty Varghese


Don Bosco Institute of Technology, Kulra(W)
Department of Computer Engineering
CSL602: System Software Lab
2020-21

Input to the Program:

Output Screenshot:

Outcome of the Thus, we were able to write down machine code of the respective
Experiment: Assembly language, classify the type of statements and were also
successful in implementing the same in emu8086.
References: Assembly program to find factorial of number given by user |
Computer Science Simplified - A Website for IGNOU MCA &
BCA Students for Solved Assignments, Notes, C Programming,
Algorithms - CSSimplified.com
https://www.tutorialspoint.com/assembly_programming/index.htm
https://www.geeksforgeeks.org/introduction-of-assembler/

Course In-charge: Ditty Varghese

You might also like