Decision Structures, Loops, and Hardware Devices .. Background:.
Added on -2019-09-16
| 6 pages
| 2237 words
| 398 views
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. For the 68000, a simple hardware device is simply a location in memory. Therefore, to communicate with simple devices, you simply read from or write to that location in memory.To view the Hardware window, select 'Hardware' from the View menu. The top half of 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 device bank.Use the default address for all devices.A good coding practice would be to assign a name to each device using an equate and to use this name in the code to refer to the address of the device. Also, consider equates for any character that has to be displayed on the seven segment display. Normally, equates are located after the leading 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 area MOVE.B #$0A,LEDS Display 10 (in binary) on LEDsFor this example, writing $0A to memory location $00E00010, will show 00001010 on the LEDs. Why a byte? There are only 8 LEDs and each bit of the byte will correspond to one LED.The seven segments in a display are always identified by the index shown on the display image below. To produce the number 7 on the display you need to light the segments labeled as 0, 1, and 2. The code to light these segments would either be 0000111 ( referred to as the gfedcba encoding and specified as <b6> to <b0>) or 1110000 ( referred to as the abcdefg encoding and specified as <b0> to <b6>) to light segments '0', '1' and '2' of the display. Our display is using the gfedcba encoding and the 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 your understanding and ability to use the interface. Complete these four questions before doing the remainder of the questions. These programs are short. If your proof of concept 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 it right 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 shift where the bit shifted out of one end of the operand is shifted into the other end of 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 should continuously 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) when a '1' is written to that position.oThe speed of the display depends on the speed of the machine that you are running the program on. The lights will be changing too fast to see if the rotate is correct. You will have to write a delay loop to slow the rotate/display down. A delay loop simply loops a number of times (quite a few actually) doing nothing. You could use the NOP instruction(s) in the 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. For example, %10101010 is not a good pattern because you cannot determine the scroll direction.
2.Write a program to read a value from the toggle switches (the ones that look like light switches) and display that value on the LEDs. The program should run continuously, i.e. the program will be in an infinite loop, and as the toggle switches are changed, the display changes.oThe toggle switches are 'active high' which means they write a '1' to the corresponding bit in memory when the switch is 'on' or 'up'.oSince this program depends on human input (and we are incredibly slow compared 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 are changed, the display changes.Note that the LED should be on when the button is depressed and off when the button is released.oThe push buttons are 'active low' which mean they write a '0' to the corresponding 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 button behaves differently from the toggle switches and is only onwhilethe button 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 run continuously, 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 on the toggle switches to the LEDs.oSince a human is very slow compared to the system, your program will require a loop topollfor input from the push buttons, i.e. you will have to continually check to see if any push button (in this case) has been pressed before proceeding to the next action. In this application,the pushbutton is acting like an enter key and does not have to be continuously depressed.5.Odd / Even : The user enters an unsigned number and the display will indicate if this number is odd, even or equal to zero. The program should run continuously 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
Found this document preview useful?
You are reading a preview Upload your documents to download or Become a Desklib member to get accesss