I ran into a problem while writing code for my task. What the program is supposed to do is this: at the end of the sentence, when i encounter a period (.) I am supposed to check if there is a space after the period and if the first letter of the next sentence is capital. So this is a part of my code which does the job. However when I run the program it doesn't do anything and the cursor just blinks without the program ever closing or displaying the edited sentences.
MOV cx, ax
MOV si, offset readBuff ;read buffer
MOV di, offset writeBuff ;write buffer
MOV bl, 97 ;lowercase 'a'
MOV bh, 122 ;lowercase 'z'
work:
MOV dl, [si] ;
CMP dl, '.' ;check if symbol is a period
JNE continue ;if no, then just print the symbol
MOV dh, [si+1] ;if it is a period move next symbol to dh
CMP dh, ' ' ; check if it is a space
JNE add_space ;if no, then go to add space
MOV dh, [si+2] ;put the first letter of the sentence to dh
cmp dh, bl ;compare it to 'a'
jb continue ;if below then print the symbol
cmp dh, bh ;compare it to 'z'
ja continue ;if above then print the symbol
sub byte ptr [si+2], 32 ;if lowercase, then make it uppercase
continue:
MOV [di], dl ;write symbol to writeBuffer
INC si
INC di
LOOP work
add_space:
MOV [di], '.' ;first add a period
INC di
MOV [di], ' ' ;then a space; argument needs type override error
INC di
INC si
CMP cx, 0
JNE work ;go back to work