Sunday, 19 March 2017

Microprocessor Simple Straight Line Program

MICROPROCESSOR SYSTEMS (PRACTICALS) – FALL 2013
EXPERIMENT 2 – Simple Straight Line Program

DATE: ______________
Group Members: ____________________________
                                    ____________________________
                                    ____________________________
                                   
Marks Obtained: ________
COURSE:
Deadline: Start of Next LAB
Instructor:

Instructions
·         This is Syndicate effort. Only Three students per syndicate are allowed. Write your remarks next to the space provided.
·         Plagiarism is strictly forbidden.
·         Submit hard copy of the report before deadline. Marks will be deducted for late submissions.



Objectives:
      (a).      To write a program in the memory
      (b).      Assembly language and Machine code
       (c).      To Execute the program
      (d).      To demonstrate difference between RAM and ROM


Time Required: 3 hrs


Required Resource : ETS-3400 Microcomputer teaching system
This is the first experiment to introduce microprocessor instructions that you can identify . In this experiment you will load some simple straight line programs in to the trainer and examine how microprocessor execute them . There are number of trainer keyboard commands that you must learn in order to examine and use the microprocessor instructions . The trainer commands that you should know for this experiment are
Important Keys
DO – Execute the program ,beginning at the address specified after this key is pressed .
EXAM (Examine) – Display the address and the memory contents at the address specifies after this key is pressed . memory contents can be changed by pressing CHAN key and entering new data .
FWD (Forward) – Advances to the next memory location and display the contents .
BACK- Go back to the previous memory location and display the contents
AUTO (Automatic) – Open the memory location specified after this key is pressed , so that data can be entered . After data has been entered , automatically advance to the next memory location and wait for data.
RESET- Clear any trainer board commands and displays “CPU UP” . Memory contents and MP contents are not disturbed.

Assembly language and OP-CODES
Assembly language is a low level computer language . its instructions are in English like words that are called mnemonics. Since instructions are similar to English words thus human beings can easily understand them but computer only operates on binary data i.e. 1 /0 . This is also called machine language and it is machine oriented . An assembler converts assembly programs into machine language i.e. binary data which is understandable by processor . Thus every instruction in assembly language has a binary code . This is also called Operation code or OP-Code in short . An op-code is a binay number that tells the microprocessor to perform a particular operation. Different microprocessors use different sets of opcodes for the operations they can perform.

Some Instruction and their OP-Codes are

LDAA -> B6
LDAB -> F6
ABA ->1B
STAA ->B7
BRA FE -> 20 FE in machine code

Memory Map of ET-3400: The EXAM key lets you view the contents of any one of the trainer’s memory locations. The 6800 microprocessor has a 16-bit address bus for memory addresses. This means that addresses can range from 0000 to FFFF.
Most of these memory locations are unused, because we don’t have memory chips installed on the trainer to use all of these locations. In fact, the trainer has just three memory chips installed:
         Two 256-byte SRAM chips, for a total of 512 bytes of RAM.
         One 1024-byte ROM chip that provides one kilobyte of ROM.
These memory chips are installed in such a way that the RAM chips’ memory locations are at the addresses between 0000 and 01FF. And the ROM chip’s locations are at the addresses between FC00 and FFFF. We can say that the RAM is located at the very “bottom” of the system’s memory space, while the ROM is located at the very “top” of the memory space. In between is a huge gap of mostly unused addresses.
But not all of the addresses in between are unused. The 6800 microprocessor uses “memory-mapped I/O.” This means that input devices (the keypad, in our case) and output devices (the 7-segment displays) are assigned addresses in the memory space. When the processor wants to read in data from the keypad, it executes the same instructions as when it reads data from memory, using the addresses assigned to the keypad. And when the processor wants to send data to the display, it executes the same instructions as when it sends data to memory, using the addresses assigned to the display.
The table below shows a partially completed “memory map” for our system. It shows the address ranges (in hex) assigned to the RAM, the keypad, the display, and the ROM.

Address range
Description
FC00 to FFFF
ROM

Unused
C110 to C16F
7- Segment Displays

Unused
C003 to C00E
Keypad

Unused
0000 to 01FF
RAM
How many addresses are assigned to RAM in Decimal? ______________________
(Show Working)


Addition Program: Our first program will add two numbers found in RAM, and then store the result of this addition in a third memory location. We’ll use locations 0120 and 0121 to hold the numbers that we want to add, and we’ll use location 0122 to hold our final sum. There are four steps:
      (a).      Fetch the number from memory location 0120 and load it into the microprocessor’s Accumulator A register.
      (b).      Fetch the number from memory location 0121 and load it into the Accumulator B register.
       (c).      Add the contents of Accumulators A and B, putting the result in Accumulator A.
      (d).      Take the number in Accumulator A and store it in memory location 0122.
After the program finishes running, we’ll be able to look in memory location 0122 and see that it contains the desired result.
Programmers who program microprocessors often use a programming language called assembly language. Our assembly language program is five lines long, and looks like this:
LDAA 0120      ;; Load Accumulator A from the contents of location 0120
LDAB 0121       ;; Load Accumulator B from the contents of location 0121
ABA                    ;; Add Accumulators A and B, and put the sum in Accumulator A
STAA 0122       ;; Store Accumulator A on the memory location 0122
BRA FE             ;; Branch

________________
Storing ProgramTo store the desired program in the memory and then to execute it , following steps are to be followed . Desired program cannot be stored in such memory locations which it is already using e.g. 0120,0121 and
   Press RESET.
      (a).      Press AUTO to get into automatic mode.
      (b).      Load the following contents into memory, starting at address 0100:
Address Contents
0100   B6
0101    01
0102    20
0103    F6
0104    01
0105     21
0106     1B
0107     B7
0108     01
0109     22
010A     20
010B    FE
       (c).      Press RESET to get out of AUTO mode.
      (d).      To check the accuracy of what you entered, use EXAM and FWD to step through the contents of locations 0100 to 010B. Verify that they hold the contents listed above.
Program Execution: Before we run our program, we’d better load our operands. Recall that memory locations 0120 and 0121 must hold the two numbers that we want our program to add. Suppose we’re interested in adding three plus five. Then we must load these values (3 and 5) into memory locations 0120 and 0121 before we run our program. So:
      (a).      Press RESET.
      (b).      Use AUTO to enter 03 and 05 into locations 0120 and 0121. While you’re at it, also load 00 into location 0122, which is where our program will store the result of its calculation.
Now that you’ve entered your program and the data that your program will manipulate, you’re ready to execute. To do so:
      (a).      Press RESET.
      (b).      Press DO. The display will change to _ _ _ _ d o. The trainer is waiting for you to enter the address at which it should start executing instructions.
       (c).      Since we entered the first instruction of our program at 0100, enter 0100. The display will go blank. That’s because the last instruction in our program (BRA FE) causes the microprocessor to enter into a never-ending loop. It’s spinning its wheels, executing that same instruction again and again.
      (d).      After waiting a microsecond or two, press RESET to get the processor out of its infinite loop.
      (e).      Use EXAM to view the contents of memory location 0122. What value do you find? ______________
       (f).       Did the program succeed in adding the two numbers we wanted it to add?  (YES/NO)
What is the maximum sum in decimal that you can store? ___________________

Re-write the program to add two numbers from location 0130 and 0131, store value at 0132. The starting location of the program is 0110. Write the machine code here with address and contents (refer to point 10)








2 comments:

Unknown said...

Re-write the program to add two numbers from location 0130 and 0131, store value at 0132. The starting location of the program is 0110. Write the machine code here with address and contents (refer to point 10)
answer please

Unknown said...

solution please

Post a Comment