Reverse a string: Difference between revisions

m
Line 1,397:
 
=={{header|LC3 Assembly}}==
A string is stored as a zero-terminated array of character codes. To reverse it, we first scan forwards until we find the end; we then move backwards again, copying each code into a block of memory we have reserved for the purpose; and finally, when we have reachedgot back to the beginning again, we append a terminal zero to the new string we have created. We can then call <tt>PUTS</tt> to print it.
<lang lc3asm> .ORIG 0x3000
 
519

edits