I need help with assembly language by moving the backward li
I need help with assembly language by moving the backward line next to the input line? Thank you.
when displaying their name backwards, display it on the first line of the console but not overwriting the first prompt (10 points) Solution
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\'edoC attesoR\' TMP DS CL12 YREGS END REVERSE text reverse(text s) { data b; integer i; i = length(s); while (i) { i -= 1; b_insert(b, -1, s[i]); } return b_string(b); } integer main(void) { o_text(reverse(\"Hello, World!\")); o_byte(\'\ \'); return 0; } PROC reverse = (REF STRING s)VOID: FOR i TO UPB s OVER 2 DO CHAR c = s[i]; s[i] := s[UPB s - i + 1]; s[UPB s - i + 1] := c OD; main: ( STRING text := \"Was it a cat I saw\"; reverse(text); print((text, new line)) ) -- Using either a generic foldr(f, a, xs) -- reverse1 :: [a] -> [a] on reverse1(xs) script rev on lambda(a, x) a & x end lambda end script if class of xs is text then foldr(rev, {}, xs) as text else foldr(rev, {}, xs) end if end reverse1 -- or the built-in reverse method for lists -- reverse2 :: [a] -> [a] on reverse2(xs) if class of xs is text then (reverse of characters of xs) as text else reverse of xs end if end reverse2 -- TESTING reverse1 and reverse2 with same string and list on run script test on lambda(f) map(f, [\"Hello there !\", {1, 2, 3, 4, 5}]) end lambda end script map(test, [reverse1, reverse2]) end run -- GENERIC LIBRARY FUNCTIONS -- foldr :: (a -> b -> a) -> a -> [b] -> a on foldr(f, startValue, xs) tell mReturn(f) set v to startValue set lng to length of xs repeat with i from lng to 1 by -1 set v to lambda(v, item i of xs, i, xs) end repeat return v end tell end foldr -- map :: (a -> b) -> [a] -> [b] on map(f, xs) tell mReturn(f) set lng to length of xs set lst to {} repeat with i from 1 to lng set end of lst to lambda(item i of xs, i, xs) end repeat return lst end tell end map -- Lift 2nd class handler function into 1st class script wrapper -- mReturn :: Handler -> Script on mReturn(f) if class of f is script then f else script property lambda : f end script end if end mReturn