Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use INCLUDE Irvine32.inc language and Create an Asembly program that does the fo

ID: 3841307 • Letter: U

Question

Use INCLUDE Irvine32.inc language and Create an Asembly program that does the following (look at the picture):

DO NOT USE x86 language

Please Test the program before posting answer

1) Simple questions a. Read in two strings, write a method to combine them in to one string. Example: hot dog hotdog b. Nested addition i. Make a method to add n numbers from 1 to 10 1. First read in n (the number of numbers) 2. The read in the n numbers and add them up 3. Print the sum only ii. Put the method in a loop and repeat it 3 times, using the delay of 2000 clear the screen between each loop

Explanation / Answer

Answer

1.

a.

.LC0:
.string "Enter first string: "
.LC1:
.string "%s"
.LC2:
.string "Enter second string: "
.LC3:
.string "After concatenation: %s"
main:
; start of function
; framesize_regs: 2
; framesize_locals: 202
; framesize_outgoing: 4
; framesize: 208
; elim ap -> fp 4
; elim fp -> sp 206
; saved regs: R4
; start of prologue
PUSHM.W #1, R4
MOV.W R1, R4
SUB.W #206, R1
; end of prologue
MOV.W #.LC0, @R1
CALL #printf
MOV.W R4, R12
ADD.W #-102, R12
MOV.W R12, 2(R1)
MOV.W #.LC1, @R1
CALL #scanf
MOV.W #.LC2, @R1
CALL #printf
MOV.W R4, R12
ADD.W #-202, R12
MOV.W R12, 2(R1)
MOV.W #.LC1, @R1
CALL #scanf
MOV.B #0, -1(R4)
.L3:
MOV.B -1(R4), R12
MOV.W R4, R13
ADD.W #-102, R13
ADD.W R13, R12
MOV.B @R12, R12
CMP.W #0, R12 { JEQ .L2
ADD.B #1, -1(R4)
BR #.L3
.L2:
MOV.B #0, -2(R4)
.L5:
MOV.B -2(R4), R12
MOV.W R4, R13
ADD.W #-202, R13
ADD.W R13, R12
MOV.B @R12, R12
CMP.W #0, R12 { JEQ .L4
MOV.B -1(R4), R12
MOV.B -2(R4), R13
MOV.W R4, R14
ADD.W #-202, R14
ADD.W R14, R13
MOV.B @R13, R13
MOV.W R4, R14
ADD.W #-102, R14
ADD.W R14, R12
MOV.B R13, @R12
ADD.B #1, -2(R4)
ADD.B #1, -1(R4)
BR #.L5
.L4:
MOV.B -1(R4), R12
MOV.W R4, R13
ADD.W #-102, R13
ADD.W R13, R12
MOV.B #0, @R12
MOV.W R4, R12
ADD.W #-102, R12
MOV.W R12, 2(R1)
MOV.W #.LC3, @R1
CALL #printf
MOV.B #0, R12
; start of epilogue
ADD.W #206, R1
POPM.W #1, r4
RET

b.

.LC0:
.string "Enter the count of numbers you'll enter in this loop::"
.LC1:
.string "%d"
.LC2:
.string "Enter number::"
.LC3:
.string "The sum of the entered number is %d."
main:
; start of function
; framesize_regs: 2
; framesize_locals: 12
; framesize_outgoing: 4
; framesize: 18
; elim ap -> fp 4
; elim fp -> sp 16
; saved regs: R4
; start of prologue
PUSHM.W #1, R4
MOV.W R1, R4
SUB.W #16, R1
; end of prologue
MOV.W #0, -12(R4)
MOV.W #3, -8(R4)
MOV.W #0, -2(R4)
.L5:
CMP.W -8(R4), -2(R4) { JGE .L2
MOV.W #0, -4(R4)
MOV.W #.LC0, @R1
CALL #printf
MOV.W R4, R12
ADD.W #-12, R12
MOV.W R12, 2(R1)
MOV.W #.LC1, @R1
CALL #scanf
MOV.W #0, -6(R4)
.L4:
MOV.W -12(R4), R12
CMP.W R12, -6(R4) { JGE .L3
MOV.W #.LC2, @R1
CALL #printf
MOV.W R4, R12
ADD.W #-10, R12
MOV.W R12, 2(R1)
MOV.W #.LC1, @R1
CALL #scanf
MOV.W -10(R4), R12
ADD.W R12, -4(R4)
ADD.W #1, -6(R4)
BR #.L4
.L3:
MOV.W -4(R4), 2(R1)
MOV.W #.LC3, @R1
CALL #printf
ADD.W #1, -2(R4)
BR #.L5
.L2:
MOV.B #0, R12
; start of epilogue
ADD.W #16, R1
POPM.W #1, r4
RET

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote