Question

In: Computer Science

Make assembly code that accomplishes the following: load a number into accumulator A 2. logical shift...

Make assembly code that accomplishes the following: load a number into accumulator A 2. logical shift right of A 3. If the carry bit of CCR sets (use instruction “bcs”), then steadily display a “1” on a seven- segment display block. 4. If the carry bit is not set, then steadily display a “0” on a seven-segment display block. 5. Change to another number and run the code, again, so that you can see either 1 or 0 displayed.

Solutions

Expert Solution

Answer : Given data

EXPLANATION of each line of code is given in comments after ;

Begin : LDAA #$55   ;to load any number into accumulator
lsra; Accumulator A is shifted right one place
lbcs display_one; jump to display_one if the C flag (= LSB bits) is 1
org $1000 ;if Carry flag is not set (0) then display zero, follow this code
four equ $30; seven-segment pattern of digit 0
org $1500 ; origin address of code
movb #$0F,DDRP; to configure PORT P for output
movb #$FF,DDRB; to configure PORT B for output
bset PTP,$0D ;disable the remaining digits by setting the digits to 1
bclr PTP,$02 ;enable the required digit by setting it to 0
movb #$3f,PTB; output the seven-segment pattern to PORTB
swi
jmp begin ; jump to start of program after displaying 1

display_one : org $1000 ; code of display 1 when carry flag is set
four equ $7E; seven-segment pattern of digit 0
org $1500 ; origin address of code
movb #$0F,DDRP; configure PORT P for output
movb #$FF,DDRB; configure PORT B for output
bset PTP,$0D ;disable the remaining digits by setting the digits to 1
bclr PTP,$02 ;enable the required digit by setting it to 0
movb #$3f,PTB; output the seven-segment pattern to PORTB
swi
jmp begin ; jump back to start of program after displaying 0

____________THE END_______________


Related Solutions

2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a,...
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds the base address of the array A (add comments to your MIPS code). j = 0; for(i=0 ; i<a ; i++) A[i]=i+j++;
develop an algorithm and then a C program that accomplishes the following. determines the minimum number...
develop an algorithm and then a C program that accomplishes the following. determines the minimum number of quarters, dimes, nickels, and pennies to make change for any amount of cents from 1 cent to 99 cents inclusive; produces an error message if 0 or more than 99 is entered as input, but the program will keep running and ask for another input; terminate if 0 or a negative number is entered. Here is possible example of the program running (remember...
develop an algorithm and then a C program that accomplishes the following. determines the minimum number...
develop an algorithm and then a C program that accomplishes the following. determines the minimum number of quarters, dimes, nickels, and pennies to make change for any amount of cents from 1 cent to 99 cents inclusive; produces an error message if 0 or more than 99 is entered as input, but the program will keep running and ask for another input; terminate if 0 or a negative number is entered. Here is possible example of the program running (remember...
HCS12 Assembly code please. Translate the following code into assembly. Allocate each variable on the stack....
HCS12 Assembly code please. Translate the following code into assembly. Allocate each variable on the stack. Simulate your program and screenshot the final value of the variables in memory. { char A,B,C; int F; A = 2; B = 6; C = - 10; F = (A + B)*C; C = F +10 }
Write an assembly code the counts the number of accuracies of the byte AAh in memory...
Write an assembly code the counts the number of accuracies of the byte AAh in memory from address 120Ah to address 130Ah. You need to use a subroutine and call it 'COUNT' to do so. You also need to provide the count in BCD if it was less than 64h so that you need to include another subroutine called 'ToBCD' to do so. assembly 8086
Translate following pseudo-code to MIPS assembly language cout << “\n Please input a number for $s0”;...
Translate following pseudo-code to MIPS assembly language cout << “\n Please input a number for $s0”; cin >> $s0; cout << “\n Please input a number for $s1”; cin >> $s1; cout << “\n Please input a number for $s2”; cin >> $s2; $t0 = $s0 / 8 - 2 * $s1 + $s2; cout << “\n the Value of the expression “$s0 / 8 - 2 * $s1 + $s2” is ”; cout >> $t0; return;
Please write a pep/9 assembly code that checks if a word or number is a palindrome
Please write a pep/9 assembly code that checks if a word or number is a palindrome
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that...
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that it is equivalent to the following C code. int counter; int x = 5; int y = 6; for (counter =10; counter >0;counter--) IF(X==Y) Y = Y + 1 ; ELSE Y = Y + 2} Fill in the blanks in the following code: MOV__________ ;loop counter into r0-ten times round the loop MOV__________ ;Value of y loaded into r1 MOV__________ ;Value of x...
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT