DOC PREVIEW
NMT EE 308 - EE 308 Introduction and Objectives

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2006 ASSEMBLY LANGUAGE PROGRAMMING AND 9S12 PORTS In this sequence of three labs, you will learn how to write simple assembly languageprograms for the MC9S12 microcontroller, and how to use general purpose I/O(input/output) ports.WEEK 1Introduction and ObjectivesThis laboratory will give you more experience with the tools we will use this semester ―the MiniDRAGON+ evaluation board (EVB), the D-Bug12 monitor, and the as12assembler. Be sure to read through the entire lab and do the pre-lab for each sectionbefore coming to lab1. Consider the program in Figure 1:prog: equ $1000 ; put program at address 0x1000data: equ $2000org progldab #29 ; IMM (immediate) address modeldaa #235sbastd result ; EXT (extended) address modeswiorg dataresult: ds.w 1 ; Set aside one byte of memory for; resultFigure 1. Demo program for Part 1 of Lab 2.Pre-Lab• Hand-assemble this program, i.e., determine the op-codes the MC9S12 will useto execute this program.• How many cycles will this take on the MC9S12? (Do not consider the swiinstruction.)• How long in time will this take. (Note: the MC912 executes 24 million cyclesper second.)• What will be the state of the N, Z, V and C bits after each instruction has beenexecuted (ignore the swi instruction.)Page 1EE 308 Spring 2006 • What will be in address 0x2000 and 0x2001 after the program executed?a) Assemble the program using as12. Look at the lst and s19 files. You should beable to relate the op-codes from the pre-lab to the data in the s19 file. (Adocument showing the format of the Motorola S19 files is available in thedocument S_RECORD.TXT on the EE308 datasheet page.)b) Trace through the program. Verify that the Z, N, V and C bits are what youexpect after each instruction.c) Look at the contents of address 0x2000. Does the value agree with your answerfrom the pre-lab?d) You could change this program to add rather than subtract by changing the sbainstruction to an aba instruction. Modify the program, assemble it and load thenew program into the MC9S12.a. Find the address for the sba instruction.b. In the MC9S12 Core Users Guide , find the op code for the abainstruction.c. Go to the address of the sba instruction, and change the op codeto that of the aba instruction. d. Run the program again, and verify that the program now addsrather than subtracts.2. Consider the program in Figure 2, which is a program to divide a table of ten values by2.; MC9S12 demo program Bill Rison 1/15/03; This is a program to take a table of data, and create a new table which is the original; table divided by 2prog: equ $1000 ; put program at 0x1000data: equ $2000 ; put data at address 0x2000count: equ 10 ; number of entries in tableorg prog ; set program counter to 0x1000ldab #count ; ACC B holds number of entries leftldx #table1 ; Reg X points to entry to processrepeat: ldaa 0,x ; get table1 entry into ACC Aasra ; divide by 2staa count, x ; save in table 2inx ; Reg X points to next entry in table1decb ; decrement number left to processbne repeat ; if not done, process next table1 entryswi ; done - exitorg data; initialize table 1 (COUNT bytes long)table1: dc.b $19,$a7,$53,$e3,$7a,$42,$93,$c8,$27,$cfPage 2EE 308 Spring 2006 table2: ds.b count ; reserve count bytes for table2Figure 2. Demo program for part 2 of lab 2a) Use the text editor to enter this program, assemble the program into an s19file.b) How may cycles will it take to execute the program take on the MC9S12? c) How long will it take to execute the program?d) Use the fill option to change the values in addresses 0x2000 through 0x2FFFto 0xff. Reload the s19 file.e) Set a breakpoint at repeat. f) Execute the program again. The program should stop the first time it reachesthe repeat label, with 0x0a in acc b, and 0x2000 in x.g) Continue running the program. It should stop each time it gets to the repeatlabel –b should be decremented by one, x should be incremented by one, andthere should be a new entry in table2. 3. Consider the code of Figure 3. Do parts (a) and (b) below before coming to labldy #100loop1: ldx #25000loop2: dexbne loop2 ; conditional branch to loop2deybne loop1 ; conditional branch to loop1swiFigure 3. Demo program for part 3 of lab 2.Question to answer before lab:• How many cycles will this program take on the MC9S12? (Again, ignore the swiinstruction.)• How long will it take to execute this program?• Use a text editor to enter the code into a program – you will have to add orgstatements and other assemble directives to make the program work.a) Assemble the program and run it on the EVB. How long does it take to run?This time should match your answer to your pre-lab question.Page 3EE 308 Spring 2006 WEEK 2Introduction and ObjectivesThe purpose of this laboratory is to write a few assembly language programs and testthem on your MC9S12.Pre-LabMake sure you have the programs written and clearly thought out before you come to thelab. You should put all your code starting at memory location 0x2000. You areencouraged to bring the programs in on a disk.The LabAs in last week’s lab you will write some programs in assembly language and run theprograms on the MC9S12. Write the program in Figure 1 and add necessary instructionsto make it run.The MniDRAGON+ has a seven-segment LED display connected to the MC9S12 Port H.A seven-segment display looks like this:On the MiniDRAGON+, the a LED is connected to bit 0 of Port H, the b LED isconnected to bit 1 of Port H, etc. (Bit 7 of Port H is connected to an infrared detector; itis not used to manipulate the seven segment LED display.) To display the number 3 onthe LEDs, you need to turn on segments a, b, c, d and g. To do this, you need to write a010011112, or 0x4f, to the Port H data register. (A 0xCF will also display a 3 on theLEDs, because the most significant bit can be either 0 or 1.) The following program willtoggle the a LED of the seven segment display:Page 4abcdefgEE 308 Spring 2006 PTH equ $260DDRH equ $262movb #$ff,DDRH ; make H an output portclr PTH ; clear port H data registerrepeat: bclr PTH,$1bset PTH,$1jmp repeatswiFigure 1. Demo program for part 2 of lab 2.b) Test your program on the MC9S12. Trace through the loop to see what ishappening.Note: The program should cause one of the 7-segment display to toggle.c) Modify the code to make


View Full Document

NMT EE 308 - EE 308 Introduction and Objectives

Documents in this Course
Load more
Download EE 308 Introduction and Objectives
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EE 308 Introduction and Objectives and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EE 308 Introduction and Objectives 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?