MAIN START RPUSH ; Init Variables LAD GR1,I002 XOR GR2,GR2 LAD GR3,258 CALL C010 ; Print "Swapcase Alphabet" OUT LB001,LL001 ; Input s IN SB001,SL001 XOR GR0,GR0 ST GR0,EOF LD GR0,SL001 JPL J001 JZE J001 ST GR0,EOF XOR GR0,GR0 ST GR0,SL001 J001 NOP ; For i = 0 To (Len(s) - 1) Step 1 LD GR7,SL001 LAD GR7,-1,GR7 ST GR7,T001 XOR GR7,GR7 ST GR7,I002 J002 NOP LD GR1,I002 CPA GR1,T001 JPL J004 ; If ((s(i) >= "A"c) And (s(i) <= "Z"c)) Then LD GR7,I002 LD GR1,GR7 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR7,GR0 LD GR6,='A' XOR GR0,GR0 CPA GR7,GR6 JMI J011 LAD GR0,#FFFF J011 LD GR7,GR0 LD GR6,I002 LD GR1,GR6 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR6,GR0 LD GR5,='Z' XOR GR0,GR0 CPA GR6,GR5 JPL J012 LAD GR0,#FFFF J012 LD GR6,GR0 AND GR7,GR6 AND GR7,GR7 JZE J006 ; s( i ) = ((s(i) + "a"c) - "A"c) LD GR7,I002 LD GR1,GR7 LD GR2,SL001 CALL C013 LAD GR7,SB001 ADDL GR7,GR0 LD GR6,I002 LD GR1,GR6 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR6,GR0 ADDA GR6,='a' SUBA GR6,='A' ST GR6,0,GR7 JUMP J005 ; ElseIf Not(((s(i) < "a"c) Or (s(i) > "z"c))) Then J006 NOP LD GR7,I002 LD GR1,GR7 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR7,GR0 LD GR6,='a' LAD GR0,#FFFF CPA GR7,GR6 JMI J013 XOR GR0,GR0 J013 LD GR7,GR0 LD GR6,I002 LD GR1,GR6 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR6,GR0 LD GR5,='z' LAD GR0,#FFFF CPA GR6,GR5 JPL J014 XOR GR0,GR0 J014 LD GR6,GR0 OR GR7,GR6 XOR GR7,=#FFFF AND GR7,GR7 JZE J005 ; s( i ) = ((s(i) + "A"c) - "a"c) LD GR7,I002 LD GR1,GR7 LD GR2,SL001 CALL C013 LAD GR7,SB001 ADDL GR7,GR0 LD GR6,I002 LD GR1,GR6 LD GR2,SL001 LAD GR3,SB001 CALL C011 LD GR6,GR0 ADDA GR6,='A' SUBA GR6,='a' ST GR6,0,GR7 ; End If J005 NOP ; Next i J003 NOP LAD GR1,I002 LD GR2,0,GR1 LAD GR2,1,GR2 ST GR2,0,GR1 JUMP J002 J004 NOP ; Print s OUT SB001,SL001 EXIT NOP RPOP RET ; Dim i As Integer I002 DS 1 ; Dim s As String SL001 DS 1 SB001 DS 256 EOF DS 1 T001 DS 1 LL001 DC 17 LB001 DC 'Swapcase Alphabet' ; UtilFill C010 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 ADDL GR3,GR1 J015 CPL GR1,GR3 JZE J016 ST GR2,0,GR1 LAD GR1,1,GR1 JUMP J015 J016 POP GR3 POP GR2 POP GR1 RET ; UtilLoadElement C011 AND GR2,GR2 JNZ J007 XOR GR0,GR0 RET J007 CALL C013 PUSH 0,GR3 ADDL GR3,GR0 LD GR0,0,GR3 POP GR3 RET ; UtilSafeIndex C013 AND GR2,GR2 JNZ J008 XOR GR0,GR0 RET J008 LD GR0,GR1 JPL J009 XOR GR0,GR0 RET J009 CPL GR0,GR2 JMI J010 LAD GR0,-1 ADDL GR0,GR2 J010 RET END