13.07.2013 Views

EECE 259 - Lab 5 - Using The Assembler and Debug Monitor.pdf

EECE 259 - Lab 5 - Using The Assembler and Debug Monitor.pdf

EECE 259 - Lab 5 - Using The Assembler and Debug Monitor.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Part E – Modifying a Program<br />

Go back to the IDE68k/<strong>Assembler</strong> <strong>and</strong> open up the original program you typed in<br />

at the start of the <strong>Lab</strong>, the one that copies Switches to LEDS.<br />

Modify the program to do the following. For each change, download, disassemble<br />

<strong>and</strong> single step the new version of the program.<br />

o Read Port B (switches 8-15) <strong>and</strong> copy the data to the red leds 8-15 <strong>and</strong><br />

also the Hex0 Display (look up the addresses of these output ports in the<br />

lecture notes <strong>and</strong> h<strong>and</strong>outs on using the 68000 on the DE2 board).<br />

o Store the data you read from Port A <strong>and</strong> Port B to Static Memory at<br />

addresses $00010000 <strong>and</strong> $00010001. Single step this program <strong>and</strong> set up<br />

watch points on these two address to observe them change.<br />

Part F – Writing your own program<br />

Write an assembly language program to read in your 8 digit student number using the<br />

slider switches SW0-SW7 on the DE2 board (note these switches are connected to<br />

one of the input ports) <strong>and</strong> display them on the 8 digit hex displays. To make it<br />

simple, assume your student number only contains digits in the range 0-7 (not 8 or 9)<br />

as this means we do not have to read the other input port where switches 8 <strong>and</strong> 9 are<br />

connected.<br />

For example, if your student number was 56231447, then you would enter this by<br />

moving SW5 to the up position then back to the down position, followed similarly by<br />

Switches 6,2,3,1,4,4,7. Your software will have to read the switch port, detect when a<br />

switch has moved to the up <strong>and</strong> then down position <strong>and</strong> write data to the Hex<br />

displays.<br />

You should investigate the BNE (branch if not equal to zero instruction) <strong>and</strong> BEQ<br />

(branch if equal to zero instruction) to determine when the switch has been pushed up<br />

or returned to the down position (logic 0). This can be explained as follows.<br />

When the switch is in the up position (logic 1), <strong>and</strong> you read the value of the switches<br />

into 68000 register d0, it will clear the ‘Z’ bit in the 68000 condition code register.<br />

When the switches are in the down position (logic 0), reading the switches will set the<br />

‘Z’ bit. BNE <strong>and</strong> BEQ branch if the Z bit is 0 or 1 respectively.<br />

Note you can expect some occasional “contact bounce” on the switches leading to<br />

occasional incorrect detections of up/down movement (this is normal for a<br />

mechanical switch)<br />

When all 8 digits of your student number have been read, the program should stop<br />

<strong>and</strong> return to the debug monitor with a TRAP #15 instruction. Use the debugger to<br />

single step <strong>and</strong> debug the program.<br />

Write an assembly language program to read the 1st first 4 digits of your student<br />

number <strong>and</strong> convert them into a 16 bit (4 digit) BCD number. For example, if the first

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!