Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 362 Microprocessor Systems and Interfacing © 2-1 Laboratory 2.1 Part 1: Assembler Directives Procedure:  Create a directory called H:\cx\source\ee362\lec02\L02LabAld.

Similar presentations


Presentation on theme: "EE 362 Microprocessor Systems and Interfacing © 2-1 Laboratory 2.1 Part 1: Assembler Directives Procedure:  Create a directory called H:\cx\source\ee362\lec02\L02LabAld."— Presentation transcript:

1 EE 362 Microprocessor Systems and Interfacing © 2-1 Laboratory 2.1 Part 1: Assembler Directives Procedure:  Create a directory called H:\cx\source\ee362\lec02\L02LabAld  Run the COSMIC IDE with the command: Programs->Cosmic Tools->Idea12  Create a new project called Ald.  Use the IDEA Cpu12 development environment to create, assemble, and link the file given on the following slide.

2 EE 362 Microprocessor Systems and Interfacing © 2-2 Laboratory 2.1 (Part 1) Call the program below ald.s switch.data var1:dc.b$40 var2:dc.b$22 cons1:equ50 cons2:equ$50 switch.text start:ldaa#cons1;instruction 1 addavar1;instruction 2 addavar2;instruction 3 ldab#cons2;instruction 4 nop end

3 EE 362 Microprocessor Systems and Interfacing © 2-3 Laboratory 2.1 (Part 1 continued) Linker Command File ald.lkf +seg.text -b 0x900 -n.text# program start address +seg.const -a.text# constants follow code +seg.data -b 0x800# data start address ald.o # object module

4 EE 362 Microprocessor Systems and Interfacing © 2-4 Laboratory 2.1 : Part 2 Backup the file ald.s to ald1.s Reopen ald.s and modify the code as shown: switch.data var0:ds.b4 cons1:equ$806 var1:dc.w$1122,$3344,$5566,$7788 switch.text start:ldd#cons1;Instruction 1 lddcons1;Instruction 2 lddvar1+1;Instruction 3 nop end

5 EE 362 Microprocessor Systems and Interfacing © 2-5 Laboratory 2.1 : Part 3 Backup the new ald.s and name it ald2.s Modify program ald.s so that it calculates the sum of the contents of the initialized bytes ( var1, var2 and var3). Give the variables initial values of $11, $3c, and $2a. Use the assembler directive dc.b to reserve each of these locations. Store the sum in memory location result. Use the ds.b directive to reserve an uninitialized byte- sized location for the result.

6 EE 362 Microprocessor Systems and Interfacing © 2-6 Laboratory 2.2 : Assembler, Linker and Debugger, and I/O ports Invoke the Idea12 integrated development environment GUI ( Programs-Cosmic Tools-Idea12 ). Create, name and save a new project in you own account. Use DOS legal filenames/directories (no spaces, 8 characters or less). Add a new file to the project and enter the code shown on the next slide. Be sure to include the “.s” extension in the file name. Create and then save the linker command file with section.data at address 800 hex and.text at address 900 hex.

7 EE 362 Microprocessor Systems and Interfacing © 2-7 Laboratory 2.2 (cont) switch.data num_in:ds.b1 port_t:equ$ae switch.text start:ldaaport_t staanum_in nop end Why doesn’t the ldaa port_t instruction have a # sign in front of the port_t? _________

8 EE 362 Microprocessor Systems and Interfacing © 2-8 Laboratory 2.2 (cont) Compile and link the program. Run the previous program four times, changing the values of the dip switches as specified. Record the value stored at "num_in" after each run. SW3SW2SW1SW0Binary Code (num_in) ononoffon________ offononoff________ offoffonoff________ onoffoffon________

9 EE 362 Microprocessor Systems and Interfacing © 2-9 Laboratory 2.2 (cont) Write a program to read the switches at port T (address $ae) from the evaluation board, add 3 to the value read from the switches, and write the resulting value to the board's LEDs. The LEDs can be accessed via port S (address $d6).  To make port S an output port, add code to your program that writes $ff to memory address $d7.  Read value for port T to register A  Add 3 to register A  Write the value in register A to port S.

10 EE 362 Microprocessor Systems and Interfacing © 2-10 Laboratory 2.2 (cont) Write a program that reads the switches at port T (address $ae) from the evaluation board, adds the contents of memory location "ADDEND" to the value read from the switches, and writes the resulting value to the board's LEDs. The LEDs can be accessed via port S (address $d6). Use the “ds.b" assembler directive to reserve a byte of memory at location "ADDEND". Run the program several times, using the memory window of the debugger to placed different values in location "ADDEND".

11 EE 362 Microprocessor Systems and Interfacing © 2-11 Laboratory 2.3 : Macros Write a program using a macro that can read any specified port and then write to another specified port. The two ports should be specified in the single line macro call. Test the program by reading address $ae (switches) and then writing to address $d6 (LEDs). Make sure port S at address $d6 is an output.

12 EE 362 Microprocessor Systems and Interfacing © 2-12 Troubleshooting Tips Problem 1. Compilation failed. Response: When compilation fails, make sure that the working directory was correctly specified, and that the working directory contains all the necessary source code, object files, linker files, etc. main.s macro.s linker.lkf

13 EE 362 Microprocessor Systems and Interfacing © 2-13 Troubleshooting Tips Problem 2. Link failed. Response: When the linker fails, make sure that a. the linker command file lists all object files to be linked, b. global variables and labels are defined and referenced in each of main.s and macro.s, and c. you have not listed object files that you didn't intend to use into the linker command file.

14 EE 362 Microprocessor Systems and Interfacing © 2-14 Troubleshooting Tips Problem: Debugger failed to load h12 files properly, or board acts weird. Response: Check connectors and DIP switches. (The DIP switches should all be off except bit 3). Restart the debugger and power-cycle the board. Try to reload and run the program TSTBRD12.H12.

15 EE 362 Microprocessor Systems and Interfacing © 2-15 Troubleshooting Tips Problem: You changed something in the source files but in the debugger, you see the old version. Response: Check the time stamp on the.h12 file. If it is not current, check the destination file specified in the linker options GUI. Any time you seem to be using an old version of a file, the fastest way to eliminate the problem is to delete the.o and.h12 files and rebuild. (Of course, at that point, you usually find that you have a different problem, but at least you'll be closer to a solution.)


Download ppt "EE 362 Microprocessor Systems and Interfacing © 2-1 Laboratory 2.1 Part 1: Assembler Directives Procedure:  Create a directory called H:\cx\source\ee362\lec02\L02LabAld."

Similar presentations


Ads by Google