Beruflich Dokumente
Kultur Dokumente
assembly.programming@gmail.com
Introduction
Text Books:
Gaonkar, R. S. (2002). Microprocessor architecture, programming, and application with the 8085, 5th edition, Prentice Hall. Brey, B. B. (1993). The 8085A microprocessor software, programming and architecture, 2nd edition, Prentice Hall. .
assembly.programming@gmail.com
Assessment
1st MID : 20% 2nd MID : 20% Assignment - Quiz : 20% Final Examination : 40%
Warnings:
Copying assignment/quiz/exam is prohibited. Delay of submission influences on marks.
assembly.programming@gmail.com
What is a Microprocessor?
assembly.programming@gmail.com
In the early 1970s the microchip was invented. All of the components that made up the processor were now placed on a single piece of silicon. The size became several thousand times smaller and the speed became several hundred times faster. The MicroProcessor was born.
Assembly Programming - 8085
assembly.programming@gmail.com 5
No.
It went directly from discrete elements to a single chip. However, comparing todays microprocessors to the ones built in the early 1970s you find an extreme increase in the amount of integration.
assembly.programming@gmail.com
assembly.programming@gmail.com
Definition (Contd.)
Lets expand each of the underlined words: Programmable device: The microprocessor can perform different sets of operations on the data it receives depending on the sequence of instructions supplied in the given program. By changing the program, the microprocessor manipulates the data in different ways. Instructions: Each microprocessor is designed to execute a specific group of operations. This group of operations is called an instruction set. This instruction set defines what the microprocessor can and cannot do.
Assembly Programming - 8085
assembly.programming@gmail.com 8
Definition (Contd.)
Takes in: The data that the microprocessor manipulates must come from somewhere.
It comes from what is called input devices. These are devices that bring data into the system from the outside world. These represent devices such as a keyboard, a mouse, switches, and the like.
assembly.programming@gmail.com
Definition (Contd.)
Numbers: The microprocessor has a very narrow view on life. It only understands binary numbers. A binary digit is called a bit (which comes from binary digit). The microprocessor recognizes and processes a group of bits together. This group of bits is called a word. The number of bits in a Microprocessors word, is a measure of its abilities.
assembly.programming@gmail.com
10
Definition (Contd.)
Words, Bytes, etc.
The earliest microprocessor (the Intel 8088 and Motorolas 6800) recognized 8-bit words.
They processed information 8-bits at a time. Thats why they are called 8-bit processors. They can handle large numbers, but in order to process these numbers, they broke them into 8-bit pieces and processed each group of 8-bits separately.
Later microprocessors (8086 and 68000) were designed with 16-bit words.
A group of 8-bits were referred to as a half-word or byte. A group of 4 bits is called a nibble. Also, 32 bit groups were given the name long word.
Today, all processors manipulate at least 32 bits at a time and there exists microprocessors that can process 64, 80, 128 bits or more at a time.
Assembly Programming - 8085
assembly.programming@gmail.com 11
Definition (Contd.)
Arithmetic and Logic Operations:
Every microprocessor has arithmetic operations such as add and subtract as part of its instruction set.
Most microprocessors will have operations such as multiply and divide. Some of the newer ones will have complex operations such as square root.
In addition, microprocessors have logic operations as well. Such as AND, OR, XOR, shift left, shift right, etc. Again, the number and types of operations define the microprocessors instruction set and depends on the specific microprocessor.
12
assembly.programming@gmail.com
Definition (Contd.)
Program: A program is a sequence of instructions that bring data into the microprocessor, processes it and sends it out.
There are many programming languages (C, C++, FORTRAN, and JAVA) However, these programming languages can be grouped into three main levels (these days a fourth level is developing).
assembly.programming@gmail.com
13
Definition (Contd.)
Programming Languages
Machine language
Machine language is the lowest level programming language. It is a language intended to be understood by the microprocessor (the machine) only. In this language, every instruction is described by binary patterns. e.g. 11001101 may mean 1 + 2 This is the form in which instructions are stored in memory. This is the only form that the microprocessor understands.
assembly.programming@gmail.com
14
Definition (Contd.)
Programming Languages
Assembly language
This language is more understandable by humans. In this language, the binary patterns are assigned mnemonics (short abbreviated names). e.g. Add 1,2 is assigned to the machine language pattern 11001101 mentioned above to refer to the operation 1+2. There is usually one assembly language instruction for each machine language instruction.
assembly.programming@gmail.com
15
Definition (Contd.)
Programming Languages
High level languages
These are languages like C, PASCAL and FORTRON. These are more natural for humans to use than assembly or machine languages. They are also more compact (i.e. it takes less statements to write the program). One high level instruction translates into many assembly or machine language instructions. e.g. x = y + z may translate into: MOV 1000, R1 MOV 1004, R2 ADD R1, R2 MOV R1, 1008
16
assembly.programming@gmail.com
Definition (Contd.)
Programming Languages
The new level being developed: is ultra high level languages which would contain things like C++, and JAVA.
Here a single instruction may translate into hundreds of assembly or machine language instructions.
assembly.programming@gmail.com
17
Definition (Contd.)
Stored in memory :
First, what is memory?
Memory is the location where information is kept while not in current use. Memory is a collection of storage devices. Usually, each storage device holds one bit. Also, in most kinds of memory, these storage devices are grouped into groups of 8. These 8 storage locations can only be accessed together. So, one can only read or write in terms of bytes to and form memory. Memory is usually measured by the number of bytes it can hold. It is measured in Kilos, Megas and lately Gigas. A Kilo in computer language is 210 =1024. So, a KB (KiloByte) is 1024 bytes. Mega is 1024 Kilos and Giga is 1024 Mega.
assembly.programming@gmail.com
18
Definition (Contd.)
Stored in memory:
When a program is entered into a computer, it is stored in memory. Then as the microprocessor starts to execute the instructions, it brings the instructions from memory one at a time. Memory is also used to hold the data.
The microprocessor reads (brings in) the data from memory when it needs it and writes (stores) the results into memory when it is done.
assembly.programming@gmail.com
19
Definition (Contd.)
Produces: For the user to see the result of the execution of the program, the results must be presented in a human readable form.
The results must be presented on an output device. This can be the monitor, a paper from the printer, a simple LED or many other forms.
assembly.programming@gmail.com
20
10
A Simple Program
A program is a sequence or series of very simple commands or instructions. A real world example program might be the problem of crossing a busy street.
Step 1: Walk up to the traffic lights and stop. Step 2: Look at the traffic light. Step 3: Is your light green? Step 4: If the light is red, goto step 2. (otherwise continue to step 5) Step 5: Look to the left. Step 6: Are there cars still passing by? Step 7: If yes, goto step 5. (otherwise continue to step 8). Step 8: Look to the right. Step 9: Are there cars still passing by? (there shouldn't be any by now, but, you never know!) Step 10: If yes, goto step 8. (otherwise continue to step 11) Step 11: Proceed across the street, carefully!! .
assembly.programming@gmail.com
21
A Simple Program
Now this may seem childish at first glance, but this is exactly what you do every time you cross a busy street, that has a traffic light. This is also exactly how you would tell a MPU to cross the street, if one could. This is what I mean by a sequence or series of very simple steps. Taken as a whole, the steps lead you cross a busy intersection, which, if a computer did it, would seem very intelligent. It is intelligence, people are intelligent. A programmer that programmed these steps into a MPU, would impart that intelligence to the micro. The MPU would not, however, in this case, know what to do when it got to the other side, since we didn't tell it.
assembly.programming@gmail.com
22
11
A Simple Program
In a MPU, the problems are different but the logical steps to solve the problem are similar, that is, a series of very simple steps, leading to the solution of a larger problem. Also notice that since the steps are numbered, 1 through 11, that is the order in which they're executed.
The Program Counter (PC), in this case, starting with 1 and ending with 11, doing what each one says. The PC automatically advances to the next step, after doing what the current step says, unless a branch, or jump, is encountered. A branch is an instruction that directs the PC to go to a specific step, other than the next in the sequence.
assembly.programming@gmail.com
23
A Simple Program
The point of this lesson is to show how a simple set of instructions can solve a bigger problem.
Taken as a whole, the solution could appear to be more complicated than any of the separate steps it took to solve it.
The most difficult problem to be solved in programming a MPU is to define the problem you are trying to solve.
Sounds silly but I assure you, it's not. This is the Logical Thought Process. It is having a good understanding of the problem you're trying to solve.
You must understand the information I'm presenting in order to pass the course. Trying to remember everything does not work at university.
assembly.programming@gmail.com
24
12
Each MPU recognises and processes a group of bits called the word.
A word is a group of bits the computer recognizes and processes at a time.
assembly.programming@gmail.com
25
All numbering systems follow the same rules. Decimal is Base 10, Binary is Base 2, and Hex(adecimal) is Base 16. The base of a system refers to how many possible numbers can be in each digit position.
In decimal, a single digit number is 0 through 9. In binary a single digit number is 0 or 1. In hex a single digit number is 0 through 9, A,B,C,D,E, and F.
assembly.programming@gmail.com
26
13
assembly.programming@gmail.com
28
14
assembly.programming@gmail.com
29
Number Conversion
assembly.programming@gmail.com
30
15
After the invention of the transistor, integrated circuits (ICs) appeared on the scene at the end of the 1950s.
an entire circuit consisting of several transistors, diodes, and resistors could be designed on a single chip.
In the early 1960s, logic gates 7400 series were commonly available as ICs, and the technology of integrating the circuits of a logic gate on a single chip became known as small-scale integration (SSI).
assembly.programming@gmail.com
31
As semiconductor technology advanced, more than 100 gates were fabricated on one chip:
medium-scale integration (MSI). Example:a decade counter (7490).
Within a few years, it was possible to fabricate more than 1000 gates on a single chip
large-scale integration (LSI).
Now we are in the era of very-large- scale integration (VLSI) and super-large-scale integration (SLSI). The lines of demarcation between these different scales of integration are rather ill defined and arbitrary.
assembly.programming@gmail.com
32
16
Historical Perspective
The microprocessor revolution began with a bold and innovative approach in logic design pioneered by Intel engineer Ted Hoff. In 1969, Intel was primarily in the business of designing semiconductor memory.
it introduced a 64-hit bipolar RAM chip that year.
assembly.programming@gmail.com
33
Historical Perspective
Intel coined the term microprocessor and in 1971 released the first 4-bit microprocessor as the 4004.
It was designed with LSI technology; It had 2,300 transistors, 640 bytes of memory-addressing capacity, and a 108 kHz clock. Thus, the microprocessor revolution began with this tiny chip.
Gordon Moore, cofounder of Intel Corporation, predicted that the number of transistors per integrated circuit would double every 18 months;
this came to he known as Moores Law. Just twenty-five years since the invention of the 4004, we have processors that are designed with 15 million transistors, that can address one terabyte (1 X 112) of memory, and that can operate at 400 MHz to I .5-0Hz frequency (see Table 1.1).
assembly.programming@gmail.com
34
17
assembly.programming@gmail.com
35
A Microprocessor-based system
From the above description, we can draw the following block diagram to represent a microprocessor-based system:
sso rop roc e r
Input
Output
Memory
M ic
18
assembly.programming@gmail.com
37
Control
assembly.programming@gmail.com
38
19
Register Array
A collection of registers within the microprocessor itself. These are used primarily for data storage during program execution. The number and the size of these registers differ from one microprocessor to the other.
Control Unit
As the name implies, the control Unit controls what is happening in the microprocessor. It provides the necessary control and timing signals to all operations in the microprocessor as well as its contact to the outside world.
Assembly Programming - 8085
assembly.programming@gmail.com 39
The control unit receives the bit pattern for this instruction (0100011011) from memory. It decodes the bit pattern and determines that this is an Add operation (0100). It also determines that the inputs to the addition come from Register R1 (01) and Register R2 (10). It finally determines that the results go into register R3 (11). It issues a control signal connecting one input of the adder (in the ALU) to register R1 (in the Register Array) and the other input to register R2. Then after an appropriate amount of time, it issues a control signal to register R3 to store the output of the adder.
assembly.programming@gmail.com 40
20
R1
EN
R2
EN
R3
EN
R4
S0 S1
S0
4 X 1 MUX
S1
4 X 1 MUX
Adder
The control unit is in complete control of the system at all times. It controls the behavior using select and enable inputs to the different elements of the system.
Assembly Programming - 8085
assembly.programming@gmail.com 41
Memory
Memory stores information such as instructions and data in binary format (0 and 1). It provides this information to the microprocessor whenever it is needed. Usually, there is a memory sub-system in a microprocessor-based system. This sub-system includes:
The registers inside the microprocessor Read Only Memory (ROM)
used to store information that does not change.
assembly.programming@gmail.com
42
21
Memory
To execute a program:
the user enters its instructions in binary format into the memory. The microprocessor then reads these instructions and whatever data is needed from memory, executes the instructions and places the results either in memory or produces it on an output device.
assembly.programming@gmail.com
43
I/O Input/Output
Input and output devices are the systems means of communicating with the outside world. These devices are collectively known as peripherals.
Input devices transfer binary information from the outside world to the microprocessor.
Examples of input devices are: keyboard, mouse, bar code reader, scanner and the like.
Output devices transfer binary information from the microprocessor to the outside world.
Theses include things like an LED, a monitor, a printer and the like.
assembly.programming@gmail.com
44
22
System Bus
The microprocessor communicates with only one peripheral at a time. Controlling the bus is done by the Control Unit.
assembly.programming@gmail.com
45
To execute a program, the microprocessor reads each instruction from memory, interprets it, then executes it. To use the right names for the cycles:
The microprocessor fetches each instruction, decodes it, Then executes it.
23
Machine Language
The number of bits that form the word of a microprocessor is fixed for that particular processor.
These bits define a maximum number of combinations.
For example an 8-bit microprocessor can have at most 28 = 256 different combinations.
However, in most microprocessors, not all of these combinations are used. Certain patterns are chosen and assigned specific meanings. Each of these patterns forms an instruction for the microprocessor. The complete set of patterns makes up the microprocessors machine language.
assembly.programming@gmail.com 47
Because it is very difficult to enter the bit patterns correctly, they are usually entered in hexadecimal instead of binary.
For example, the combination 0011 1100 which translates into increment the number in the register called the accumulator, is usually entered as 3C.
Assembly Programming - 8085
assembly.programming@gmail.com 48
24
Assembly Language
Entering the instructions using hexadecimal is quite easier than entering the binary combinations.
However, it still is difficult to understand what a program written in hexadecimal does. So, each company defines a symbolic code for the instructions. These codes are called mnemonics. The mnemonic for each instruction is usually a group of letters that suggest the operation performed.
assembly.programming@gmail.com
49
Assembly Language
assembly.programming@gmail.com
50
25
Assembly Language
It is important to remember that a machine language and its associated assembly language are completely machine dependent.
In other words, they are not transferable from one microprocessor to a different one.
assembly.programming@gmail.com
51
The other possibility is a program called an assembler, which does the translation automatically.
assembly.programming@gmail.com
52
26
assembly.programming@gmail.com
Compilers are still inefficient when complete control is needed and when memory is very critical.
In such a situation, it is better to do the job yourself.
Writing a program in assembly language may not be easy. But, you can control exactly how things are being done and which instruction is being used to perform each operation.
assembly.programming@gmail.com
54
27
The hardware of a computer system is the collection of chips that make up its different pieces, including the microprocessor.
The hardware consists of five main systems:
The microprocessor Memory (RAM & ROM) Storage (Disk, CD) Input Devices (keyboard, mouse) Output Devices (monitor, printer).
Input
Microprocessor
Output
Memory
Storage
assembly.programming@gmail.com
55
The interaction between the two systems (hardware and software) is managed by a group of programs known collectively as Operating system.
assembly.programming@gmail.com 56
28
The operating system is a layer between the application programs and the hardware.
Pieces of the operating system control the operation of the disks, the monitor, the keyboard, the mouse, the printer, the sound card, and even memory.
When a program wants to use one of these items, it sends a request to the operating system and the operating system in turn will perform the operation.
When the computer is first turned on, the operating system starts to execute. It stays running as long as the computer is operating.
assembly.programming@gmail.com
57
The interaction of the user with the computer is through the operating system.
When the user invokes a program, the operating system starts the process and makes the program start executing. The program is executed on top of the operating system.
Application Operating Application Programs Operating System Hardware System Programs Hardware
assembly.programming@gmail.com
58
29
Operating Systems
Other operating systems (like UNIX) are designed to work on any platform (hardware).
assembly.programming@gmail.com 59
30