Statement: Recode the program to do the following task: Array_A[k] = 20*Array_A[k] - 2*Array_B[k]; for k =
Question:
Statement: Recode the program to do the following task:
Array_A[k] = 20*Array_A[k] - 2*Array_B[k]; for k = 0~20
Note: A[] = {0,1, 2,3, …, 19}
B[] = A[]; Both sets are same.
.data # Data sesent
Array_A: .word 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Array_B: .word
.space 40
.text
.eqv Pointer $t0
.eqv offset $t1
.eqv BaseAddressRegA $t4
.eqv BaseAddressRegB $t5
.eqv EffectiveAddressA $t6
.eqv EffectiveAddressB $t7
.macro PrintAnyStringMessage(%message)
.data
ArbitraryMessage: .asciiz %message
.space 40
.text
li $v0, 4
la $a0, ArbitraryMessage
syscall
.end_macro
.macro PrintInteger(%n,%m)
li $v0,%n
move $a0,%m
syscall
.end_macro
.globl Main
Main:
PrintAnyStringMessage("Dr. Farmallah Jan Says Welcome to Assembly Proming Session!\n")
PrintAnyStringMessage("Perform Array = Array A+ 10 Using a for-loop!\n")
li Pointer, 0
li offset, 0
la BaseAddressRegA, Array_A
la BaseAddressRegB, Array_B
For_Loop:
add EffectiveAddressA, BaseAddressRegA, offset
add EffectiveAddressB, BaseAddressRegB, offset
lw $t8, 0(EffectiveAddressA)
PrintAnyStringMessage("\n Value Of Array A=")
PrintInteger(1, $t8)
addiu $t9, $t8, 10
PrintAnyStringMessage("\n Value Of Array B=")
PrintInteger(1, $t9)
sw $t9, 0(EffectiveAddressB)
addiu Pointer, Pointer, 1
sll offset, Pointer, 2
ble Pointer, 9, For_Loop
Stop:
li $v0, 10
syscall
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill