Professional Documents
Culture Documents
NGG Project Report
NGG Project Report
ASSEMBLY LANGUAGE
CEL-324
|Page
SUBMITTED TO:
Mr. MUSLIM
SUBMITTED BY:
SHAHEER IMRAN
(02-134202-049)
COURSE INSTRUCTOR:
MISS AISHA DANISH
LAB INSTRUCTOR:
MR. MUSLUM
CLASS:
BSCS-3B Fall 2021
|Page
Table of Contents
ABSTRACT........................................................................................................................................................1
1. INTRODUCTION..........................................................................................................................................0
1.1 What is a Microprocessor.........................................................................................................................0
1.2 What is 8086 Microprocessor...................................................................................................................0
1.3 Emulator...................................................................................................................................................1
1.4 Guessing Game.........................................................................................................................................1
1.5 OBJECTIVES:..............................................................................................................................................2
1.6 FUTURE WORK..........................................................................................................................................2
2. SYSTEM REQUIREMENTS...........................................................................................................................4
2.1 HARDWARE REQUIREMENTS....................................................................................................................4
2.2 SOFTWARE REQUIREMENTS.....................................................................................................................4
3. SYSTEM ANALYSIS......................................................................................................................................0
3.1 INTRODUCTIONS.......................................................................................................................................0
Data Transfer Instructions..........................................................................................................................0
Arithmetic Instructions...............................................................................................................................1
Bit Manipulation Instructions.....................................................................................................................2
String Instructions......................................................................................................................................3
Program Execution Transfer Instructions (Branch and Loop Instructions)..................................................3
3.2 Code:........................................................................................................................................................5
3.3 Screen Shots...........................................................................................................................................14
|Page
ABSTRACT
Keywords—Emulator, Microprocesor,8086,Guessing-GAME
|Page
1. INTRODUCTION
1.1 What is a Microprocessor
A microprocessor, also simply called a processor, [1][2] or CPU[3] is a computer processor
that is implemented on a single (or more) integrated circuit (IC)[4][5] dies of MOSFET
construction in a single package. The microprocessor is a multipurpose, clock-driven,
register-based, digital integrated circuit that accepts binary data as input, processes it
according to instructions stored in its memory, and provides results (also in binary
form) as output. Microprocessors contain both combinational logic and sequential
digital logic. Microprocessors operate on numbers and symbols represented in the
binary number system.
The integration of a whole CPU onto a single or a few integrated circuits using Very-
Large-Scale Integration (VLSI) greatly reduced the cost of processing power.
Integrated circuit processors are produced in large numbers by highly automated
metal-oxide-semiconductor (MOS) fabrication processes, resulting in a relatively low
unit price. Single-chip processors increase reliability because there are many fewer
electrical connections that could fail. As microprocessor designs improve, the cost of
manufacturing a chip (with smaller components built on a semiconductor chip the
same size) generally stays the same according to Rock's law.
Before microprocessors, small computers had been built using racks of circuit boards
with many medium- and small-scale integrated circuits, typically of TTL type.
Microprocessors combined this into one or a few large-scale ICs. The first
microprocessor was the Intel 4004.
|Page
The 8086 gave rise to the x86 architecture, which eventually became Intel's most
successful line of processors. On June 5, 2018, Intel released a limited-edition CPU
celebrating the 40th anniversary of the Intel 8086, called the Intel Core i7-8086K.
1.3 Emulator
In computing, an emulator is hardware or software that enables one computer
system (called the host) to behave like another computer system (called the guest).
An emulator typically enables the host system to run software or use peripheral
devices designed for the guest system. Emulation refers to the ability of a computer
program in an electronic device to emulate (or imitate) another program or device.
Many printers, for example, are designed to emulate HP LaserJet printers because so
much software is written for HP printers. If a non-HP printer emulates an HP printer,
any software written for a real HP printer will also run in the non-HP printer
emulation and produce equivalent printing. Since at least the 1990s, many video
game enthusiasts have used emulators to play classic (and/or forgotten) arcade
games from the 1980s using the games' original 1980s machine code and data, which
is interpreted by a current-era system and to emulate old video game consoles.
|Page
reverse their roles and repeat the game. The winner is the player who gets the
correct answer with the fewest guesses.
The key strategy in this game is to generate a clever guess. If, for example, the
second player knows the number is between 0 and 100, then a reasonable first guess
is 50. This choice evenly splits the range, giving you the maximum amount of
information about the next guess. If the first player says the guess is too low, then
the second player splits the reduced range and guesses 75. If the player says the
guess is too high, then the optimal guess is 25. It can be shown that by splitting the
remaining range in half after each guess, it will, at worst, take the second player no
more than guesses to find the unknown number where is the initial range. So
if the unknown number lies between 0 and 7, then it can be guessed in no more than
guesses.
1.5 OBJECTIVES:
Here the objective of this project is to implement the logic of assembly language.
Therefore to understand the fact that how assembly language works.
Points for this project for understanding:
t allows complex jobs to run in a simpler way.
It is memory efficient, as it requires less memory.
It is faster in speed, as its execution time is less.
It is mainly hardware oriented.
It requires less instruction to get the result.
It is used for critical jobs.
It is not required to keep track of memory locations.
Most of the individual technologies to accomplish this exist today. The bottle neck is
that the control solutions available do not make the task friendly. The typical control
|Page
architecture today is many individual controllers specializing in a single task all
coordinated through one central controller; normally a PLC.
Some innovative, creative Assembly Engineers are leading the way with very cool,
leading edge assembly cells that are flexible and powerful with the ability to produce
a variety of parts and to sense the process and process variables on the fly and take
corrective actions. These cells and stations do exist. However most have one thing in
common. They are a Controls Engineer’s nightmare. Most were created with many
thousands of hours of PLC programming and debug work by a team of Controls
Engineers, typically one of which is of rare talent.
These Engineers who created the solution are the only people who can efficiently
work on the cell. Pity the poor maintenance guy who must try and debug a problem
a year later when the “creators of the monster” are off to their next project.
Standardized protocols and communication standards are all part of the solution.
Some Engineers are working on solutions that move away from the centralized
control model discussed above to a more decentralized control model. While others
are moving toward even more centralized control solutions. The solution is probably
a high bred strategy of both.
Whatever the solution, the major innovations in manufacturing over the next 25
years will be control based innovations. Control technologies and strategies that
unleash the technical power available today in new ways and new combinations.
Sure, we will develop new processes and new materials, but nothing will unleash our
productivity more than better control solutions that allow us to fully and efficiently
capitalize on the technologies that already exist today.
The factories of the future, the factories in our imagination are only limited by the
control technologies available today.
|Page
2. SYSTEM REQUIREMENTS
2.1 HARDWARE REQUIREMENTS
Hardware Requirement
Processor RAM Disk space
GHz or faster 1.6 1GB of RAM (1.5 GB if RPM hard 5400
processor running on a virtual drive and 5 GB of
machine) available hard disk
space
Table (2.1): Hardware Requirement
Software Requirement
|Page
3. SYSTEM ANALYSIS
3.1 INTRODUCTIONS
Operand types:
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. SREG:
DS, ES, SS, and only as second operand: CS.
1 - instruction sets this flag to 1. 0 - instruction sets this flag to 0. r - flag value
depends on result of the instruction. ? - flag value is undefined (maybe 1 or 0).
MOV − Used to copy the byte or word from the provided source to the
provided destination.
PPUSH − Used to put a word at the top of the stack.
POP − Used to get a word from the top of the stack to the provided location.
PUSHA − Used to put all the registers into the stack.
POPA − Used to get words from the stack to all registers.
XCHG − Used to exchange the data from two locations.
XLAT − Used to translate a byte in AL using a table in the memory.
IN − Used to read a byte or word from the provided port to the accumulator.
OUT − Used to send out a byte or word from the accumulator to the provided
port.
|Page
Instructions to transfer the address
LEA − Used to load the address of operand into the provided register.
LDS − Used to load DS register and other provided register from the memory
LES − Used to load ES register and other provided register from the memory.
LAHF − Used to load AH with the low byte of the flag register.
SAHF − Used to store AH register to low byte of the flag register.
PUSHF − Used to copy the flag register at the top of the stack.
POPF − Used to copy a word at the top of the stack to the flag register.
Arithmetic Instructions
These instructions are used to perform arithmetic operations like addition,
subtraction, multiplication, division, etc.
|Page
Instruction to perform multiplication
DIV − Used to divide the unsigned word by byte or unsigned double word by
word.
IDIV − Used to divide the signed word by byte or signed double word by word.
AAD − Used to adjust ASCII codes after division.
CBW − Used to fill the upper byte of the word with the copies of sign bit of the
lower byte.
CWD − Used to fill the upper word of the double word with the sign bit of the
lower word.
SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in
LSBs.
SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.
|Page
SAR − Used to shift bits of a byte/word towards the right and copy the old MSB
into the new MSB.
ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to
Carry Flag [CF].
ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and
to Carry Flag [CF].
RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF
to MSB.
RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF
to LSB.
String Instructions
String is a group of bytes/words, and their memory is always allocated in a sequential
order.
|Page
These instructions are used to transfer/branch the instructions during an execution.
It includes the following instructions −
CALL − Used to call a procedure and save their return address to the stack.
RET − Used to return from the procedure to the main program.
JMP − Used to jump to the provided address to proceed to the next
instruction.
|Page
3.2 Code:
.model small
.stack 100h
.data
CR equ 13d
LF equ 10d
; Declare strings
s_retryfail DB 13, 10, "Unlucky! Your guess was incorrect! :(", 13, 10, "Would you like to try again? (y/n): $"
|Page
s_retrysucc DB 13, 10, "Congratulations! Your guess was correct! :)", 13, 10, "Would you like to play again? (y/n): $"
s_bye DB 13, 10, "Thanks for playing, bye! :)", 13, 10, "$"
.code
start:
MOV ax, 0h
MOV bx, 0h
MOV cx, 0h
MOV dx, 0h
MOV BYTE PTR [BX], 0d ; Is A Pointer Directive Used To Store 8-Bit Value
Mid:
MOV ds, ax
MOV ah, 9h
INT 21h
MOV cl, 0h
MOV dx, 0h
while:
|Page
CMP cl, 5d
JG endwhile ; This Method Will Read Input One By One From User Upto 5 Decimal Values
MOV ah, 1h
INT 21h
CMP al, 0Dh ; Will Chk If User Pressed Enter, Means User Is Done With Input
JE endwhile
MOV dl, al
INC cl
JMP while
endwhile:
DEC cl
JG overflow
MOV cl, 0h
while2:
|Page
CMP cl,errorChk
JG endwhile2
POP dx
MOV ch, 0h
MOV al, 1d
; -- IF CL is 2
while3:
CMP ch, cl ;In Method While2, While3 and endwhile3 We Will Process The User Input And
Then After Processing Jump To endwhile2 To CMP Values
JGE endwhile3
MUL dh
INC ch
JMP while3
endwhile3:
MUL dl
JO overflow
|Page
MOV dl, al
JC overflow
INC cl
JMP while2
endwhile2:
MOV ds, ax
CMP dh, dl
JC greater
JE equal
JG lower
equal:
MOV ah, 9h
INT 21h
JMP exit
|Page
greater:
MOV ah, 9h
INT 21h
JMP start
lower:
MOV ah, 9h
INT 21h
JMP start
overflow:
MOV ah, 9h
INT 21h
JMP start
exit:
retry_while:
MOV ah, 9h
INT 21h
MOV ah, 1h
|Page
INT 21h
JE return_to_DOS
JE restart
JMP retry_while
retry_endwhile:
restart:
MOV AH, 9
INT 21H
JMP beg
; Start prog
beg:
JMP RANDNUM
; Generate randnum
RANDNUM:
INT 21H
MOV AL,DL
MOV CL,20
DIV CL
|Page
MOV BL, AL
INC BL
JMP INPUT
; Recieve input
INPUT:
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
JMP COMPARE
COMPARE:
CMP AL, BL
JZ SUCCESS
JMP FAIL
; If guess is successful
SUCCESS:
MOV AH, 9
INT 21H
JMP Res
; If guess is unsuccessful
FAIL:
MOV AH, 9
INT 21H
JMP Res
|Page
Res:
MOV AH, 1
INT 21H
INT 21H
JZ Mid
MOV AH, 9
INT 21H
return_to_DOS:
end start
RET
|Page
3.3 Screen Shots
Round 1:
|Page
Round 2:
THANKYOU
|Page