Question

In: Computer Science

With the code below a) Perform two-pass hand assembly to produce the list file. b) Make...

With the code below

a) Perform two-pass hand assembly to produce the list file.

b) Make a list of all the labels and give the value assigned to each label

c) Write the addressing mode and effective address or target address for branch instructions, for the first time each instruction executes

ORG $0080

MaxVal: DS.B 1

;# ROM Section

ORG $FC00 ;

Start: ldhx #DataX ;

clr MaxVal ;

Top: cphx #DataY ;

beq Done ;

lda 0,X ;

cmp MaxVal ;

bls GetNext ;

sta MaxVal ;

GetNext: aix #$01 ;

bra Top ;

Done: bra Done ;

DataX: DC.B $2A,$14,$A3

DataY: EQU *

ORG $FFFE ;

DC.W Start ;

Solutions

Expert Solution

.text
main:
j mm

mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2

li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart 2d for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, two # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = two bytes of c[i][j]
loop3:
sll $t0, $s2, two # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = two bytes of b[k][j]
sll $t0, $s0, two # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = two bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) head to loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1
lw $a0, ($a2)
syscall
li $v0, 4
la $a0, new_row
syscall
#----------TEST-------------

addiu $s1, $s1, one # $j = j + one
addi $a2, $a2, 4
bne $s1, $t1, loop2 # if (j != 4) head to loop2

addiu $s0, $s0, one # $i = i + one
bne $s0, $t1, loop1 # if (i != 32) head to L1

Exit:
li $v0, 10 #exits
syscall

.data
array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
output_row_string_C: .asciiz "Matrix C Output Row "
colon_string: .asciiz ":
space_string: .asciiz " "
new_row: .asciiz "\n"
char_space: .space 2


Related Solutions

Would you make separated this code by one .h file and two .c file? **********code************* #include...
Would you make separated this code by one .h file and two .c file? **********code************* #include <stdlib.h> #include <stdbool.h> #include <stdio.h> #include<time.h> // Prints out the rules of the game of "craps". void print_game_rule(void) { printf("Rules of the game of CRAPS\n"); printf("--------------------------\n"); printf("A player rolls two dice.Each die has six faces.\n"); printf("These faces contain 1, 2, 3, 4, 5, and 6 spots.\n"); printf("After the dice have come to rest, the sum of the spots\n on the two upward faces is...
Make a list of the specific substances that pass through the filtration membrane. Make another list...
Make a list of the specific substances that pass through the filtration membrane. Make another list of the substances that do not. Are there any advantages for using a non-selective process in producing filtrate? Are there any disadvantages
Explain the differences between an assembly language source code file, the listing file produced by 'nasm',...
Explain the differences between an assembly language source code file, the listing file produced by 'nasm', the object file (.o) and the final executable program.
Suppose there are two firms, A and B, that make a mess when they produce. Firm...
Suppose there are two firms, A and B, that make a mess when they produce. Firm A can clean up “mess” for $10/unit while firm B can only do it for $20/unit. Suppose further that firm A produces 100 units of mess per week while firm B produces 200 units of mess per week. The government decides that there should be no more than 150 units of mess produced per week. What would the total costs of cleanup be if...
Write the following assembly code file into C code. .globl main .text main:    # Tests...
Write the following assembly code file into C code. .globl main .text main:    # Tests simple looping behaviour    li t0, 60    li t1, 0 loop:    addi t1, t1, 5    addi t0, t0, -1    bne t1, t0, loop    bne t1, zero, success failure:    li a0, 0    li a7, 93 # a7 is what determines which system call we are calling and we what to call write (64)     ecall # actually issue...
Using pseudocode, write the code that will perform the necessary file operations as described in the...
Using pseudocode, write the code that will perform the necessary file operations as described in the short scenario below: “During registration at a college, student’s details will be captured by a staff member and written to a file called “studentDetails.dat”. The following student details will be captured: name, surname, studentNumber, registeredCourse. The staff member will be prompted for the student details. After every record added to the file, the staff member will be asked whether they would like to add...
Below is my source code for file merging. when i run the code my merged file...
Below is my source code for file merging. when i run the code my merged file is blank and it never shows merging complete prompt. i dont see any errors or why my code would be causing this. i saved both files with male names and female names in the same location my source code is in as a rtf #include #include #include using namespace std; int main() { ifstream inFile1; ifstream inFile2; ofstream outFile1; int mClientNumber, fClientNumber; string mClientName;...
Create a file and change the file permissions to (a) make it executable, (b) enable the...
Create a file and change the file permissions to (a) make it executable, (b) enable the SUID, and (c) use the ACL to add a permission for the root user. Do a long listing of this file. LINUX command line / virtual box.
Please make my Code working and pass the test but do NOT change anything in main...
Please make my Code working and pass the test but do NOT change anything in main function, thank you. #include <iostream> using namespace std; void sort(int *A, int n){    for(int passes = 0;passes < 2;passes++) { // shift can have only two values either 0 or 16, used for shifting purpose int shift = passes * 16; int N = 1<<(16 + 1);    // Temporary array for storing frequency of upper or lower 16 bits int temp[N];   ...
X86 Assembly MASM Questions below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Answer each question below by writing code at the...
X86 Assembly MASM Questions below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Answer each question below by writing code at the APPROPRIATE places at the end ;;;;; of the file as indicated. ;;;;; Q2: Write the directive to bring in the IO library           ;;;;; Q3: Create a constant called DAYS_PER_WEEK and initialize it to 5 ;;;;;     Create a constant called WEEKS_PER_YEAR and initialize it to 49 ;;;;; Q4: Create a constant called DAYS_PER_YEAR by using DAYS_PER_WEEK and ;;;;;     WEEKS_PER_YEAR (of Q3) in an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT