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

This is for LC3 op codes Write a program to reverse a sentence and store the rev

ID: 3714722 • Letter: T

Question

This is for LC3 op codes

Write a program to reverse a sentence and store the reversed string in place (In place reversal implies that the original string is replaced with the reversed string at its location). Also, display the reversed string on the screen. (The string should start at memory location 0x5000 and your code should start at memory location 0x3000). For example, if the original starting at 0x5000 was “Dazzling!”, the reversed string should be “!gnilzzaD” occupying the same location from 0x5000.

Explanation / Answer

Below lc3 code used to reverse a given string.

hope this helps...

Thankyou... :)

*        Reverse a string

REVERSE CSECT

         USING REVERSE,R13        base register

         B      72(R15)            skip savearea

         DC     17F'0'             savearea

         STM    R14,R12,12(R13)    prolog

         ST     R13,4(R15)         "

         ST     R15,8(R13)         "

         LR     R13,R15            "

         MVC    TMP(L'C),C         tmp=c

         LA     R8,C               @c[1]

         LA     R9,TMP+L'C-1       @tmp[n-1]

         LA     R6,1               i=1

         LA     R7,L'C             n=length(c)

LOOPI    CR     R6,R7              do i=1 to n

         BH     ELOOPI             leave i

         MVC    0(1,R8),0(R9)        substr(c,i,1)=substr(tmp,n-i+1,1)

         LA     R8,1(R8)            @c=@c+1

         BCTR   R9,0                 @tmp=@tmp-1

         LA     R6,1(R6)             i=i+1

         B      LOOPI              next i

ELOOPI   XPRNT C,L'C              print c

         L      R13,4(0,R13)       epilog

         LM     R14,R12,12(R13)    "

         XR     R15,R15            "

         BR     R14                exit

C        DC     CL12'dlrow olleH'

TMP      DS     CL12

         YREGS

         END    REVERSE

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