Easy68K Assembly Language: Hardware Interaction and Program Logic

Verified

Added on  2019/09/16

|6
|2237
|276
Homework Assignment
AI Summary
This assignment involves writing assembly language programs using the Easy68K hardware simulator to interact with various hardware devices, including LEDs, toggle switches, push buttons, and a seven-segment display. The programs implement decision structures and loops to control the hardware. The assignment covers several tasks, such as scrolling an 8-bit pattern on LEDs, displaying toggle switch values on LEDs, displaying push button values on LEDs, and a program that displays toggle switch values when a push button is pressed. Additionally, the assignment requires the creation of programs that can determine if an entered number is odd, even, or zero, and a program that adds two signed numbers entered via toggle switches and displays the result on LEDs and seven-segment display. The solutions are designed to test the understanding of assembly language concepts and hardware interaction within the Easy68K environment, emphasizing the use of equates and delay loops where necessary. The programs are designed to continuously run, allowing real-time interaction with the simulated hardware devices.
Document Page
Decision Structures, Loops, and Hardware Devices .
Background:
All programming questions will be done using the Easy68K hardware 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, and
a 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 address
F EQU %01110001 Letter F for 7seg display
START ORG $400 Start of program area
MOVE.B #$0A,LEDS Display 10 (in binary) on LEDs
For 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.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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 in
length, 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 a rotate command 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.
o The LEDs are 'active high' which means the light goes 'on' (is red) when
a '1' is written to that position.
o The 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.
o Pick 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.
Document Page
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.
o The toggle switches are 'active high' which means they write a '1' to the
corresponding bit in memory when the switch is 'on' or 'up'.
o Since 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 on
the 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.
o The 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 high
when there is no activity on the buttons. Note also that the push button
behaves differently from the toggle switches and is only on while the
button is being depressed.
4. Write a program to read a value from the toggle switches and display that value
on the LEDs when a push button is depressed. The program should run
continuously, i.e. the program will be in an infinite loop.
o The system should start with the LEDs off.
o User enters a value on the toggle switches (not displayed on LEDs yet).
o When the user presses any push button, display the value currently on
the toggle switches to the LEDs.
o Since a human is very slow compared to the system, your program will
require a loop to poll for 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 push
button 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:
o at the start, the LEDs and the entire seven segment display should be off
Document Page
o you will prompt the user to enter a number by displaying an "S" (start)
on the left-most character of the seven segment display
o the user will enter the number on the toggle switches and then press the
right-most push button to indicate that entry is complete
o the number on the toggle switches should be echoed on the LEDs after
entry is complete, i.e. after the right-most push button has been pressed
o the start prompt "S" should be cleared when the push button is pressed
o you will display O, E or Z on the right-most character of the seven
segment display if the number is odd, even, or equal to zero,
respectively. Due to the limitations of our seven segment display, the Z
will look like a 2.
o the user will press the right-most push button if they are ready to enter
another number on the toggle switches or the left-most button if they
want to quit
o if the user wants to continue (right-most push button selected),
display an "S" on the left-most character of the seven segment
display
the O/E/Z is cleared.
the LEDs are cleared
o ... repeats until the user selects the left-most push button
o when the left-most push button is selected, clear the LEDS and seven
segment display before the program ends.
Display/interface:
o Pushbuttons: left-most = quit, right-most = enter, selecting the other
buttons should cause no action
o Seven segment display: left-most display = start (when appropriate),
right-most display = O or E or Z (when appropriate), other display units
are not used and should be off
o LEDs: number on the toggle switches when the entry is complete
For example:
o "S" displayed
o 10100101 entered on switches
o push button to indicate entry complete, "S" cleared
o 10100101 displayed on LEDs
o "O" displayed
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
o push button to indicate new entry, "S" displayed, "O" is cleared, LEDs
cleared
o 10101010 entered on switches
o push button to indicate entry complete, "S" cleared
o 10101010 displayed on LEDs
o "E" displayed
o push button to indicate exit, all displays cleared
6. For this question, I assume that the push buttons are numbered in the
same order as the toggle switches.
Write a program to add two signed numbers entered from the toggle switches.
If the result is positive, display the number on the LEDs; if the result is
negative, display a minus sign on the left-most seven segment display and the
magnitude of the result to the LEDs.
The interface will work as follows:
o at the start, the LEDs should be off
o the result register should be cleared
o the user will enter the first number on the toggle switches and then press
push button 0 (right-most push button) to indicate that entry is complete
the first number should be echoed on the LEDs
o the user will enter the second number on the toggle switches and then
press push button 1 to indicate that entry is complete
the second number should be echoed on the LEDs
push button 1 should always trigger the addition
o when the user presses push button 2, the sum of the two numbers will be
displayed on the LEDs in the following manner
if the result is positive, display the sum on the LEDs
if the result is negative, display a minus sign on the left-most
seven segment display and the magnitude of the result to the
LEDs.
if there is an overflow, display an 'E' on the left-most seven
segment display and display the contents of the result register on
the LEDs
o note that push buttons can be pushed in any order
o ... repeats until the user selects the left-most push button
o when the left-most push button (push button 7) is selected, clear the
LEDS to show that the program has ended
Document Page
o the remaining push buttons should cause no action to occur and should
be disregarded.
The program should be dominated by the push button functions and not depend on the
push buttons to be entered in order. For example, if the user enters a number on the
switches and presses push button 0 and that is followed by the user entering a number
on the switches and pressing push button 0, then the second number that was entered
is the "first number" (essentially the user has entered a correction). Alternatively, if
the user enters a number on the switches, presses push button 0, and then presses push
button 1, then the same number is entered as both the first number and the second
number. At any point in time, if the user presses push buttons 2, display the contents
of the result as they exist at that point in time.
HINT: For push button dominance, " the user will enter the first number on the toggle
switches and then press push button 0 to indicate that entry is complete; the first
number should be echoed on the LEDs " should be thought of as "if the user presses
push button 0, the value on the toggle switches is read into the first number and
echoed on the LEDs".
Submit
the source files (.x68),
the listing files (.l68),
for this assignment, the markers will actually run your programs to do the
marking
© 2002-2017 Nora Znotinas, Wilfrid Laurier University
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]