Decision Structures, Loops, and Hardware Devices .. Background:.

Added on - 16 Sep 2019

  • 6


  • 2237


  • 231


  • 0


Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 3 of 6 pages
Decision Structures, Loops, and Hardware Devices.Background:All programming questions will be done using the Easy68Khardware simulator. Forthe 68000, a simple hardware device is simply a location in memory. Therefore, tocommunicate with simple devices, you simply read from or write to that location inmemory.To view the Hardware window, select 'Hardware' from the View menu. The top halfof the hardware window contains, from top to bottom:an 8 digit 7-segment display,a bank of 8 light emitting diodes (LED),a bank of 8 toggle switches, anda bank of 8 push button switches.Each of these devices has an address (in hex) shown in the window next to the devicebank.Use the default address for all devices.A good coding practice would be toassign a name to each device using an equate and to use this name in the code to referto the address of the device. Also, consider equates for any character that has to bedisplayed on the seven segment display. Normally, equates are located after theleading comments but before the origin directive for the program.LEDS EQU $E00010 LEDs addressF EQU %01110001 Letter F for 7seg displaySTART ORG $400 Start of program areaMOVE.B #$0A,LEDS Display 10 (in binary) on LEDsFor this example, writing $0A to memory location $00E00010, will show 00001010on the LEDs. Why a byte? There are only 8 LEDs and each bit of the byte willcorrespond to one LED.The seven segments in a display are always identified by the index shown on thedisplay image below. To produce the number 7 on the display you need to light thesegments labeled as 0, 1, and 2. The code to light these segments would either be0000111 ( referred to as the gfedcba encoding and specified as <b6> to <b0>) or1110000 ( referred to as the abcdefg encoding and specified as <b0> to <b6>) to lightsegments '0', '1' and '2' of the display. Our display is using the gfedcba encoding andthe top-most bit <b7> is the decimal sign which is not shown in the diagram below.
NOTE: The questions 1 to 4 are "proof of concept" programs to simply test yourunderstanding and ability to use the interface. Complete these four questions beforedoing the remainder of the questions. These programs are short. If your proof ofconcept programs, excluding comments and the delay loop, are longer than 10 lines inlength, you do not understand the question.1.Write a program to take an arbitrary 8-bit pattern from memory and scroll itright as if it was a circular buffer. For example, if the initial pattern is%01011001 then the next pattern is %10101100 and then %01010110, etc.Most assembly languages have arotatecommand which is a circular shiftwhere the bit shifted out of one end of the operand is shifted into the other endof the operand. Display the pattern on the hardware LEDs as it is being rotated.The LED should be "on" (red) when the bit is 1. The program shouldcontinuously scroll the pattern, i.e. the program will be in an infinite loop.oThe LEDs are 'active high' which means the light goes 'on' (is red) whena '1' is written to that position.oThe speed of the display depends on the speed of the machine that youare running the program on. The lights will be changing too fast to see ifthe rotate is correct. You will have to write a delay loop to slow therotate/display down. A delay loop simply loops a number of times (quitea few actually) doing nothing. You could use the NOP instruction(s) inthe loop to use some time up without causing any actions to occur. Hint:you did this in the lab.oPick a good pattern so that it is obvious that the rotate is working. Forexample, %10101010 is not a good pattern because you cannotdetermine the scroll direction.
2.Write a program to read a value from the toggle switches (the ones that looklike light switches) and display that value on the LEDs. The program shouldrun continuously, i.e. the program will be in an infinite loop, and as the toggleswitches are changed, the display changes.oThe toggle switches are 'active high' which means they write a '1' to thecorresponding bit in memory when the switch is 'on' or 'up'.oSince this program depends on human input (and we are incredibly slowcompared to the speed of the machine), no delay routine is required.3.Write a program to read a value from the push buttons and display that value onthe LEDs. The program should run continuously and as the push buttons arechanged, the display changes.Note that the LED should be on when the buttonis depressed and off when the button is released.oThe push buttons are 'active low' which mean they write a '0' to thecorresponding bit in memory while the button is pressed and write a '1'when the button is released. Consequently, the buttons are normally highwhen there is no activity on the buttons. Note also that the push buttonbehaves differently from the toggle switches and is only onwhilethebutton is being depressed.4.Write a program to read a value from the toggle switches and display that valueon the LEDs when a push button is depressed. The program should runcontinuously, i.e. the program will be in an infinite loop.oThe system should start with the LEDs off.oUser enters a value on the toggle switches (not displayed on LEDs yet).oWhen the user presses any push button, display the value currently onthe toggle switches to the LEDs.oSince a human is very slow compared to the system, your program willrequire a loop topollfor input from the push buttons, i.e. you will haveto continually check to see if any push button (in this case) has beenpressed before proceeding to the next action. In this application,the pushbutton is acting like an enter key and does not have to be continuouslydepressed.5.Odd / Even : The user enters an unsigned number and the display will indicateif this number is odd, even or equal to zero. The program should runcontinuously until the user quits the program.The interface will work as follows:oat the start, the LEDs and the entire seven segment display should be off
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document