program String include '/home/dbarker/182/examples/Strings' ; Program takes up to 10 alphanumeric strings as input. It will then reverse the case ; Of all letters in each string (uppercase to lower, and lowercase to upper). Numbers ; Are not affected. The program then prints the strings in the order opposite in which ; They were input. ; Grant Palin ; Created: 2003-02-25 ; Last modified: 2003-02-25 counter1 EQU -4 stack 100 data code String ;Program start point call Strings sys EXIT switchcase ;Switches the case of the strings push fp ;push the frame pointer onto the stack so we can remember it for when we return mov sp, fp ;moves stack pointer into fp so we remember it for use with Params push r2 ;push what's in r2,r3,r4, and r5 onto the stack so we can retrieve it later push r3 ;in case the previous part of the program was using values stored push r4 ;see above push r5 ;see above push r6 push r7 push r8 push r9 lodw counter1, fp, r2 ;load the number of strings into r2 add fp, counter1 -2, r9 mov 0 , r3 loop1 cmp r3, r2 ;compare r3 to r2 be endofswitch ;if they are equal you are done lodw 0, r9, r5 mov 0, r8 loop2 lodbu 0, r5, r6 ;load the next byte of r5 into r6 cmp r6, 0 be endofloop cmp r6, 'Z' bbe uppercase cmp r6, 'z' bbe lowercase br loop3 uppercase cmp r6 , 0x40 bbe loop3 br switch lowercase cmp r6, 0x60 bbe loop3 br switch switch xor r6, 0x20, r6 stobl 0,r5, r6 loop3 inc r5 br loop2 endofloop inc r3 sub r9, 2, r9 br loop1 ;Pop the stack to get the parameters ;Switch the case of each string (numbers are left alone) endofswitch pop r9 pop r8 pop r7 pop r6 pop r5 pop r4 pop r3 pop r2 pop fp ret putstringsreversed ;Reverses the order of the strings push fp ;push the frame pointer onto the stack so we can remember it for when we return mov sp, fp ;moves stack pointer into fp so we remember it for use with Params push r1 push r2 ;push what's in r2,r3,r4, and r5 onto the stack so we can retrieve it later push r3 ;in case the previous part of the program was using values stored push r4 ;see above push r5 ;see above push r6 push r7 push r8 push r9 lodw counter1, fp, r3 ;load the number of strings into r2 shl r3, 1, r4 add r4, 4 ,r4 sub fp, r4 , r4 print mov PUTSTR, r1 lodw 0, r4, r2 sys CONSOLE mov PUTCHAR, r1 mov 10,r2 sys CONSOLE mov 13,r2 sys CONSOLE add r4, 2, r4 dec r3 cmp r3, 0 be done br print done pop r9 pop r8 pop r7 pop r6 pop r5 pop r4 pop r3 pop r2 pop r1 pop fp ret end