rendered paste body .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 #32,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
Sub.b #1,D2
BEQ.W FULL
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
addq.l #1,(A4) |LOAD CAP FLAG
jsr Grammer_Loop
|ERORRING
Suba.l D1,A3
movea.l A3,A0
jsr PrintMsg
jsr NewLine
move.b #0x00,D1 |Nulls out pointer to start of string
jmp Get_Cha
Set_Cap_Flag:
addq.l #1,(A4)
addq.l #1,A3 |MOVE TO NEXT CHAR
jmp Grammer_Loop
Upper_Case:
sub.b #32,(A3)
|sub.b #1,(A4)
jmp Grammer_Loop
Is_Lower_Case:
cmp.b #0x61,(A3) |if ascii value bigger or equal to Hex61 (a) then
bge.w Upper_Case
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 #0x20,(A3) |if characert enter is a space
beq.w Set_Cap_Flag
|bge.w Set_Cap_Flag
cmp.b #1,(A4) |if cap flag was set then make upper case
beq.w Is_Lower_Case
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************/