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...
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the...
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the user. Determine the smallest of these three numbers and display this result. Don’t use loops. Prompt the user for each entered integer. Your output should look something like the following example. Enter an integer: 7556 Enter an integer: -22984 Enter an integer: 8875 -22984
Assembly language program create a program that outputs a picture that represents halloween in ASCll art...
Assembly language program create a program that outputs a picture that represents halloween in ASCll art (jack-o-lantern, witch's hat, etc)
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 a MARIE assembly language program that will read an “array” of positive decimal values stored...
Write a MARIE assembly language program that will read an “array” of positive decimal values stored in memory and output the smallest value. Use variable addr to store the location of the first data item. Use variable length to store the number of items in your array. Your code should be organized such that adding an additional array item would only involve adding the data line (ie. 021 dec 400) and updating the length variable (ie. length, dec 5). You...
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
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers...
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers from the console (Dn and Up), Call a recursive function to compute the result int RecurseFunc( int Dn, int Up ) { if( Dn < 1 ) return 0; return Dn * Up + RecurseFunc( Dn - 1, Up + 1 ); } Print out the results
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers...
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers from the console (Dn and Up), Call a recursive function to compute the result int RecurseFunc( int Dn, int Up ) { if( Dn < 1 ) return 0; else return Dn * Up + RecurseFunc( Dn - 1, Up + 1 ); } Print out the results Submit your code and report here.
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers...
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers from the console (Dn and Up), Call a recursive function to compute the result int RecurseFunc( int Dn, int Up ) { if( Dn < 1 ) return 0; return Dn * Up + RecurseFunc( Dn - 1, Up + 1 ); } Print out the results
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT