.TITLE "Asign1" .PSIZE 1000,1000 .NOLIST .INCLUDE "..\\include\\ascii.i" .LIST /*************CONSTANT DATA************/ .TEXT 1 MsgProgramID: .ASCIZ "WELCOME!" .BYTE CR,LF,0 MsgKeyPress: .ASCIZ "Please Enter A String" .BYTE CR,LF,0 MsgExit: .ASCIZ "Thank You Come Again!" .BYTE CR,LF,0 MsgStrFull: .ASCIZ "Sorry your memory is full!" .BYTE CR,LF,0 /*******************VARIABLE******************/ .DATA string: .SPACE 1024,0 .EQU CLF,0x0D .EQU EOF,0x04 .EQU PER,0x2E .EQU EXP,0x21 .EQU QUE,0x3F .EQU CAP,0x20 CapFlag: .WORD 1 GrammerCount: .WORD 1 /*****************PROCESS****************/ .TEXT 0 .GLOBAL Asign1 Asign1: movea.l #CapFlag,A4 Addq.l #1,(A4) |movea.l (A3),#CapFlaag move.b #64,D2 movea.l #MsgProgramID,a0 jsr PrintMsg jsr NewLine movea.l #MsgKeyPress,a0 jsr PrintMsg jsr NewLine Get_Cha: jsr ConsoleIn |D0 CMP.L #CLF,D0 BEQ.W New_Line CMP.L #EOF,D0 BEQ.W End_Of_Reading move.b D0,(A1) ADDQ.l #1,A1 ADDQ.l #1,D1 jsr ConsoleOut CMP.L #0,D2 BEQ.W FULL Sub.b #1,D2 move.b D0,D3 JMP Get_Cha New_Line: jsr NewLine |addq.l #1,D1 move.b #0x00,D0 move.b D0,(A1) movea.l A1,A3 Suba.l D1,A3 |point to start of string move.b #1,(A4) |LOAD CAP FLAG jsr Grammer_Loop |ERORRING Suba.l D1,A3 movea.l A3,A0 jsr PrintMsg jsr NewLine move.b #64,D2 move.b #0x00,D1 |Nulls out pointer to start of string jmp Get_Cha Set_Cap_Flag: move.b #1,(A4) addq.l #1,A3 |MOVE TO NEXT CHAR jmp Grammer_Loop Upper_Case: sub.b #32,(A3) move.b #0,(A4) addq.l #1,A3 |MOVE TO NEXT CHAR jmp Grammer_Loop Is_Lower_Case: cmp.b #0x61,(A3) |if ascii value bigger or equal to Hex61 (a) then bge.w Upper_Case addq.l #1,A3 |MOVE TO NEXT CHAR jmp Grammer_Loop Next_Char: addq.l #1,A3 jmp Grammer_Loop I_Cap: suba.l #1,A3 cmp.b #0x20,(A3) |Next pervious char is a space bne.w Next_Char addq.l #2,A3 cmp.b #0x20,(A3)|check pervious char for space bne.w Next_Char suba.l #1,A3 jmp Upper_Case jmp Grammer_Loop Lower_Case: |add.l #32,(A3) move.b (A3),D0 jsr ToLower move.b D0,(A3) addq.l #1,A3 |MOVE TO NEXT CHAR jmp Grammer_Loop Grammer_Loop: |loops from start of string till end of string cmp.b #0x00,(A3) |if end of string then exit beq.w Exit cmp.b #0x69,(A3) |if characert enter is a 'i' beq.w I_Cap cmp.b #0x2E,(A3) |For period beq.w Set_Cap_Flag cmp.b #0x21,(A3) |For '!' beq.w Set_Cap_Flag cmp.b #0x3F,(A3) |For '?' beq.w Set_Cap_Flag cmp.b #1,(A4) |if cap flag was set then make upper case beq.w Is_Lower_Case cmp.b #0x41,(A3) BGT.W Next_Char cmp.b #0x5A,(A3) BGT.W Next_Char MOVE.B (A3),D0 JSR ToLower MOVE.B D0,(A3) move.b #0,(A4) addq.l #1,A3 |Move to next character jmp Grammer_Loop Exit: rts End_Of_Reading: jsr ConsoleIn movea.l #MsgExit,a0 jsr PrintMsg jsr NewLine RTS FULL: movea.l #MsgStrFull,A0 jsr PrintMsg JMP End_Of_Reading RTS | exit program /************end of program************/