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...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a file. Each pair will then be multiplied together with the results being accumulated (added together) forming a sum-of-products operation. Submit your report and code here.
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to 2FFF & transfer to 4000 to 4FFF
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
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
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...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT