Question

In: Electrical Engineering

Create an assembly language program on the 9S12 CPU to read switches and drive LED's 1-Configure...

Create an assembly language program on the 9S12 CPU to read switches and drive LED's

1-Configure all bits of Port U for output using address DDRU. There are 8 LEDs

connected to those pins. When you output a 1 to a bit, that bit will be enabled for

output, so when you later write a 1 to a bit in port U (PTU) that LED will turn ON.

2. Switches are attached to Port T. They work by grounding the bit when switched

on, (negative logic): ON = 0, OFF = 1. The PCB supplies pull-up resistors.

3. Read the switches, and configure your program so that if switch 1 is on, you

send out a data pattern which will make the even LEDs turn ON, others OFF.

4. If switch 2 is on, make the lower 4 LEDs ON and the higher 4 LEDs OFF

5. If switch 3 is ON, start out lighting the LED for bit 0, then move the light left until

the LED for bit 7 is ON. After that, turn OFF all LEDs, then turn on the LED for a bit

7 again and move the light back towards the LED for bit 0. After it gets there, turns all the LEDs OFF again, then repeat the cycle until the switch changes).

Note: for all of the above you will have to keep going back afterward and reading the switch to see if it has changed.

6. Add a delay to your program so the human eye can see the operation!

Solutions

Expert Solution

Answer :- The code has been written below-

ldaa #$FF ;load value 1111_1111 into register A
staa DDRU ;make port U pins as output
ldaa #$00 ;load value 0000_0000 into register A
staa DDRT ;make port T pins as input
Loop1: ;label name Loop1
ldaa PTT ;read port T pins and keep in A
cmpa #$FE ;check if switch 1 is pressed
beq Case1 ;if yes then goto label named as Case1
cmpa #$FD ;check if switch 2 is pressed
beq Case1 ;if yes then goto label named as Case1
cmpa #$FB ;check if switch 3 is pressed
beq Case1 ;if yes then goto label named as Case1
bra Loop1 ;goto label Loop1, infinite loop

Case1:
ldaa #$55 ;register A = 0101_0101
staa PTU ;make even leds on
bra Loop1 ;go back to loop1

Case2:
ldaa #$0F ;register A = 0000_1111
staa PTU ;make lower 4 leds on, higher 4 off
bra Loop1 ;go back to loop1

Case3:
ldaa #$01 ;register A = 0000_0001
staa PTU ;led 0 is on
call delay1
lsla
staa PTU ;led 1 is on
call delay1
lsla
staa PTU ;led 2 is on
call delay1
lsla
staa PTU ;led 3 is on
call delay1
lsla
staa PTU ;led 4 is on
call delay1
lsla
staa PTU ;led 5 is on
call delay1
lsla
staa PTU ;led 6 is on
call delay1
lsla
staa PTU ;led 7 is on
call delay1
lsla
staa PTU ;all leds off
call delay1
ldaa #$80 ;register A = 1000_0000
staa PTU ;led 7 is on
call delay1
lsra
staa PTU ;led 6 is on
call delay1
lsra
staa PTU ;led 5 is on
call delay1
lsra
staa PTU ;led 4 is on
call delay1
lsra
staa PTU ;led 3 is on
call delay1
lsra
staa PTU ;led 2 is on
call delay1
lsra
staa PTU ;led 1 is on
call delay1
lsra
staa PTU ;led 0 is on
call delay1
lsra
staa PTU ;turn off all led
call delay1

bra Loop1 ;go back to loop1

delay1:
ldaa #$FF ;A = 255
loop2:
deca
cmpa #$00
bne loop2
rts ;return from subroutine


Related Solutions

Write an assembly program which will read the value of the switches on the board, parse...
Write an assembly program which will read the value of the switches on the board, parse this number by looking at the 4 least-significant bits, using the lookup table from the prelab to get the value necessary to display this hex number on a 7-segment display, using shift instructions to adjust registers as necessary to parse the next set of values. Repeat until all four displays are accounted for. Finally, when one register has a bit-stream necessary to display all...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Code using assembly language Create a program using the Irvine32 procedures were the user can input...
Code using assembly language Create a program using the Irvine32 procedures were the user can input a list of 32-bit unsigned integers an “x” number of times, then display these integers to the console in reverse order. Hint: Use loops and PUSH & POP instructions. Extra Challenge: Inform the user with a message what to do; also, tell them what they are seeing.
1. How to create a newline subroutine in micro assembly language that sends the CR and...
1. How to create a newline subroutine in micro assembly language that sends the CR and LF codes to putchUSART0 (write down the full code in micro assembly language). Terminal programs move the cursor to the beginning of a line with a Carriage Return (CR) code 0x0D and down a line with the Line Feed (LF) code 0x0A.
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
Write an assembly program using the super simple cpu instruction set for the following problem. Take...
Write an assembly program using the super simple cpu instruction set for the following problem. Take input an integer from the user. Output three times the input to the output box. For example, if the user inputs 10 (base-10) then output box should show 30 (base-10). Hint: 3 * p can be calculated by doing p+p+p. ONLY write your assembly instructions here.
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT