Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understand Subroutines - Lab 7 - Microcomputer Principles | ECEN 3213, Lab Reports of Electrical and Electronics Engineering

Material Type: Lab; Subject: Electrical and Computer Engineering ; University: Oklahoma State University - Stillwater; Term: Spring 2005;

Typology: Lab Reports

Pre 2010

Uploaded on 03/19/2009

koofers-user-iq2
koofers-user-iq2 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download Understand Subroutines - Lab 7 - Microcomputer Principles | ECEN 3213 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity! ECEN 3213 Spring 2005 Lab 7 Due in Lab Section, Mar. 7, 9 Objective. Understand subroutines. Discussion. A subroutine is called with the jsr instruction and a return from a subroutine is done with the rts instruction. These instructions use the stack to temporarily store the subroutine address on the stack. jsr sublabel This instruction pushes the (incremented) PC onto the stack and then jumps the subroutine at the address with label “sublabel”. rts This instruction pulls the top of the stack into the PC which causes the instruction after the original rts to be executed. WARNING: the stack must be initialized before any jsr instructions are executed. We have discussed extensively in class how the stack can also be used to pass subroutine arguments and reserve temporary space for local subroutine variables. You can use either the stack or any registers you desire to pass subroutine arguments for this lab. Shifting. You will need to shift data into different bit positions for this lab. There are several 6811 instructions for shifting 1 bit to the left or to the right. More modern instruction sets have the capability to shift by any number of bit positions in a single instruction. With the 6811 you have no choice but to use multiple shift instructions to shift by multiple bits. The fol- lowing example shifts the contents of the A register to the left by 4 bits. lsla lsla lsla lsla This puts 0’s into the right-most bits. We also could have used rola which would roll the left-most bits into the right-most bits.ECEN 3213 Spring 2005 Lab 7 January 27, 2005 page 1 of 3 Program Specifications. Write assembly code for a subroutine that reads 4 data bits from 4 data switches labeled “d3”, “d2”, “d1” and “d0” with d3 for the most significant bit and d0 the least significant. Use this subroutine to read data 4 bits at a time for display on an 8 bit output port. The output port should drive 8 LED’s labeled “d7”, “d6”, “d5”, “d4”, “d3”, “d2”, “d1” and “d0” with d7 showing the most significant bit and d0 the least significant. The first time the data is entered, it should be displayed in the upper 4 bits of the output port without changing the lower 4 bits. The second time the data is entered, it should be displayed in the lower 4 bits of the output port without changing the upper 4 bits. The eas- iest way to achieve this is to call the data reading subroutine in a loop such as the follow- ing pseudo-code. loop: input data shift data output data input data output data go to loop There must be an additional control switch labeled “go”. The operation of the control switch is as follows. go switch open (low) - all other switch settings are ignored. You should change the other switches only when the go switch is open. go switch closed (high) - read the setting of the data switches. IMPORTANT: do the operation only once and then wait for the go switch to go low. You may use any pin on any port that is appropriate to monitor the switches and drive the LED’s. Reset should initialize the LED’s to all 0’s. Procedure. 1. Enter your program in the program window and assemble it. Remember that you must open a microcomputer window in order to assemble your code. 2. Run your program and make sure it runs without getting any error messages. 3. Verify that the LED’s display the correct value when the switch settings are changed. Program Demonstration The previous steps can all be done outside the assigned lab period if you wish. To get credit for the lab (10 pts. maximum), you must complete the following steps in the assigned lab period.ECEN 3213 Spring 2005 Lab 7 January 27, 2005 page 2 of 3
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved