.model small
.stack 100h
.data
max db 255
len db ?
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!',13,10,'$'
VariantMessage db 'You have entered the home-task program of variant 1',13,10,'$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
EnterAgainMessage db 13,10,'Would you like to enter one more string',13,10,'$'
ResultMessage db 13,10,'Resulting string after changing every capital letter into small one',13,10,'$'
GoodbYeMessage db 13,10,'Thank you for your attention. Have a nice day!',13,10,'$'
RightMessage db 'Copyright AnyaB',13,10,'$'
.code
begin:
mov ax, 003h
int 10h ;ocistka ekrana
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
push ax
lea dx, GreetingMessage
call Write_Proc
lea dx, VariantMessage
call Write_Proc
lea dx, InputMessage
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
mov ah,9
lea dx,EnterAgainMessage ;vivod soobs4eniya-result
int 21h
mov ah,9
lea dx, string ;vivod vvedennoi stroki
int 21h
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
mov ah,9
lea dx, string ;vivod soobs4eniya-result
int 21h
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
call Write_Proc
;lea dx, RightMessage ;vivod soobs4eniya-result
;call Write_Proc
Write_Proc proc ;procedure for dispalying the messages
push ax
mov ah,09h
int 21h
pop ax
ret
Write_Proc endp
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
end begin
[TASM]Преобразование строки
Еще один вопрос, может ли использование цветных букв в программе вызивать ее закрытие сразу после выполнения программы. Спасибо! :)
Код:
2. Замечание. push ax вначале программы, нужно делать самой первой записью, иначе ты сохраняеш уже не тот ax, что нужно.
Собственно исправленый мною код
Код:
.model small
.stack 100h
.data
max db 255
len db ?
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!',13,10,'$'
VariantMessage db 'You have entered the home-task program of variant 1',13,10,'$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
EnterAgainMessage db 13,10,'Would you like to enter one more string',13,10,'$'
ResultMessage db 13,10,'Resulting string after changing every capital letter into small one',13,10,'$'
GoodbYeMessage db 13,10,'Thank you for your attention. Have a nice day!',13,10,'$'
RightMessage db 'Copyright AnyaB',13,10,'$'
.code
begin:
push ax
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
mov ax, 004h
int 10h ;ocistka ekrana
lea dx, GreetingMessage
call Write_Proc
lea dx, VariantMessage
call Write_Proc
lea dx, InputMessage
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
mov ah,9
lea dx,EnterAgainMessage ;vivod soobs4eniya-result
int 21h
mov ah,9
lea dx, string ;vivod vvedennoi stroki
int 21h
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
mov ah,9
lea dx, string ;vivod soobs4eniya-result
int 21h
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
call Write_Proc
;lea dx, RightMessage ;vivod soobs4eniya-result
;call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc ;procedure for dispalying the messages
push ax
mov ah,09h
int 21h
pop ax
ret
Write_Proc endp
end begin
.stack 100h
.data
max db 255
len db ?
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!',13,10,'$'
VariantMessage db 'You have entered the home-task program of variant 1',13,10,'$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
EnterAgainMessage db 13,10,'Would you like to enter one more string',13,10,'$'
ResultMessage db 13,10,'Resulting string after changing every capital letter into small one',13,10,'$'
GoodbYeMessage db 13,10,'Thank you for your attention. Have a nice day!',13,10,'$'
RightMessage db 'Copyright AnyaB',13,10,'$'
.code
begin:
push ax
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
mov ax, 004h
int 10h ;ocistka ekrana
lea dx, GreetingMessage
call Write_Proc
lea dx, VariantMessage
call Write_Proc
lea dx, InputMessage
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
mov ah,9
lea dx,EnterAgainMessage ;vivod soobs4eniya-result
int 21h
mov ah,9
lea dx, string ;vivod vvedennoi stroki
int 21h
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
mov ah,9
lea dx, string ;vivod soobs4eniya-result
int 21h
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
call Write_Proc
;lea dx, RightMessage ;vivod soobs4eniya-result
;call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc ;procedure for dispalying the messages
push ax
mov ah,09h
int 21h
pop ax
ret
Write_Proc endp
end begin
Не могли бы вы еще мне подсказать. Как сделать условие для того чтобы цветным выводился не только первый символ, а и вся строка. И как избавится от ошибки - Relational jump is out of range in 00Ah bytes , когда я в конце программы делаю запрос на возможность еще одного повтора ее выполнения.
Код:
.model small
.stack 100h
.data
max db 255
len db ' '
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!',13,10,'$'
VariantMessage db 'You have entered the home-task program of variant 1',13,10,'$'
ChoiceMessage db 13,10,'Would you like to enter the new line of characters (YES/NO) - [1/0]',13,10,'$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
ResultMessage db 13,10,'Resulting string after changing every capital letter into small one',13,10,'$'
GoodbYeMessage db 13,10,'Thank you for your attention. Have a nice day!',13,10,'$'
.code
begin:
push ax
mov ax, 003h
int 10h ;ocistka ekrana
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
lea dx, GreetingMessage
call Write_Proc
lea dx, VariantMessage
call Write_Proc
work:
lea dx, InputMessage
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
colour1:
mov ah,09h
lea dx, string ;vivod vvedennoi stroki
mov al, string
mov bh,0 ;delaem tekuus4uu stranicu nulevoi
mov bl,2 ;cvet dlya simvola
mov cx,1 ;colicestvo povtoreni symvola
int 10h
loop colour1
int 21h
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
colour:
mov ah,9
lea dx, string ;vivod soobs4eniya-result
mov al, string
mov bh,0 ;delaem tekuus4uu stranicu nulevoi
mov bl,4 ;cvet dlya simvola
mov cx,1 ;colicestvo povtoreni
int 10h
loop colour
int 21h
lea dx, ChoiceMessage
call Write_Proc
mov ah,0ah
mov dx, offset string
mov [string], 253d
int 21h
mov ah,08h ;cteniye symvola v tekuscei posicii kursora
int 10h
cmp al, 31h ;esli 'yes' - perehodim na metku work
je work ;esli 'no' -perehodim na metku escape
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc near ;procedure for dispalying the messages
push ax
xor ax,ax
mov ah,09h
int 21h
pop ax
ret
Write_Proc endp
end begin
.stack 100h
.data
max db 255
len db ' '
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!',13,10,'$'
VariantMessage db 'You have entered the home-task program of variant 1',13,10,'$'
ChoiceMessage db 13,10,'Would you like to enter the new line of characters (YES/NO) - [1/0]',13,10,'$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
ResultMessage db 13,10,'Resulting string after changing every capital letter into small one',13,10,'$'
GoodbYeMessage db 13,10,'Thank you for your attention. Have a nice day!',13,10,'$'
.code
begin:
push ax
mov ax, 003h
int 10h ;ocistka ekrana
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
lea dx, GreetingMessage
call Write_Proc
lea dx, VariantMessage
call Write_Proc
work:
lea dx, InputMessage
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
colour1:
mov ah,09h
lea dx, string ;vivod vvedennoi stroki
mov al, string
mov bh,0 ;delaem tekuus4uu stranicu nulevoi
mov bl,2 ;cvet dlya simvola
mov cx,1 ;colicestvo povtoreni symvola
int 10h
loop colour1
int 21h
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
colour:
mov ah,9
lea dx, string ;vivod soobs4eniya-result
mov al, string
mov bh,0 ;delaem tekuus4uu stranicu nulevoi
mov bl,4 ;cvet dlya simvola
mov cx,1 ;colicestvo povtoreni
int 10h
loop colour
int 21h
lea dx, ChoiceMessage
call Write_Proc
mov ah,0ah
mov dx, offset string
mov [string], 253d
int 21h
mov ah,08h ;cteniye symvola v tekuscei posicii kursora
int 10h
cmp al, 31h ;esli 'yes' - perehodim na metku work
je work ;esli 'no' -perehodim na metku escape
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc near ;procedure for dispalying the messages
push ax
xor ax,ax
mov ah,09h
int 21h
pop ax
ret
Write_Proc endp
end begin
Код:
.........
begin:
push ax
jumps ; расширяет область действия jmp-ов
........
begin:
push ax
jumps ; расширяет область действия jmp-ов
........
Насчет цвета. Я бы в таком случае писал сразу в видео память, задавая нужный атрибут напрямую. А возможностей ДОС, для вывода всей строки определного цвета, я не знаю или не помню... возможно таких возможностей даже и нет.
P.S. могу на мыло выслать. очень полезный справочник. размер ~200к
и так, я модифицировал функцию вывода, теперь она выводит строку с нужным цветом, в определной позиции. параметры, к-рые передаются
si - адресс строки(тоже что dx и в для 9ой функции)
ch - номер столбца для вывода(нумерация с нуля)
cl - номер строки для вывода(нумераия с нуля)
bl - атрибут(цвет фона и цвет символов)
программа также запрашивает, повторный ввод строки, если нажать y, то прога пойдет заново, если что-то другое выход.
Конечно, этот код нужно еще править(я не особо старался, что бы было рационально), но все работает.
а вот и код
Код:
.model small
.386
.stack 100h
.data
max db 255
len db ?
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!$'
VariantMessage db 'You have entered the home-task program of variant 1$'
InputMessage db 'You are welcome to enter the string with any characters$'
EnterAgainMessage db 'Would you like to enter one more string. input y to try again$'
ResultMessage db 'Resulting string after changing every capital letter into small one$'
GoodbYeMessage db 'Thank you for your attention. Have a nice day!$'
RightMessage db 'Copyright AnyaB$'
crcl db 13,10,'$'
.code
begin:
push ax
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
start:
mov ax, 003h
int 10h ;ocistka ekrana
lea si, GreetingMessage
xor ch,ch
mov cl,0
mov bl,0eh
call Write_Proc
lea si, VariantMessage
mov ch,1
mov cl,1
mov bl,0eh
call Write_Proc
lea si, InputMessage
mov ch,2
mov cl,0
mov bl,0eh
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
lea si, string ;vivod vvedennoi stroki
mov ch,5
mov cl,0
mov bl,0eh
call Write_Proc
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea si, ResultMessage ;vivod soobs4eniya-result
mov ch,6
mov cl,0
mov bl,0eh
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
lea si, string ;vivod soobs4eniya-result
mov ch,7
mov cl,0
mov bl,0eh
call Write_Proc
lea si,EnterAgainMessage ;vivod soobs4eniya-result
mov ch,8
mov cl,0
mov bl,0eh
call Write_Proc
mov ah,0
int 16h
cmp al,'y'
je start
lea si, GoodbyeMessage ;vivod soobs4eniya-result
mov ch,9
mov cl,0
mov bl,0eh
call Write_Proc
mov ax, 003h
int 10h ;ocistka ekrana
;lea dx, RightMessage ;vivod soobs4eniya-result
;call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
comment @
На вход подается:
si - адресс строки(тоже что dx и в для 9ой функции)
ch - номер столбца для вывода(нумерация с нуля)
cl - номер строки для вывода(нумераия с нуля)
bl - атрибут(цвет фона и цвет символов)
@
Write_Proc proc ;procedure for dispalying the messages
pusha
push es
push 0b800h
pop es
push cx
mov al,ch
mov dl,80
mul dl
mov di,ax
and cx,00ffh
add di,cx
shl di,1
pop cx
_rep:
lodsb
cmp al,'$'
je _endo
mov ah,bl
stosw
jmp _rep
_endo:
lea dx, crcl
mov ah,09
int 21h
pop es
popa
ret
Write_Proc endp
end begin
.386
.stack 100h
.data
max db 255
len db ?
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!$'
VariantMessage db 'You have entered the home-task program of variant 1$'
InputMessage db 'You are welcome to enter the string with any characters$'
EnterAgainMessage db 'Would you like to enter one more string. input y to try again$'
ResultMessage db 'Resulting string after changing every capital letter into small one$'
GoodbYeMessage db 'Thank you for your attention. Have a nice day!$'
RightMessage db 'Copyright AnyaB$'
crcl db 13,10,'$'
.code
begin:
push ax
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
start:
mov ax, 003h
int 10h ;ocistka ekrana
lea si, GreetingMessage
xor ch,ch
mov cl,0
mov bl,0eh
call Write_Proc
lea si, VariantMessage
mov ch,1
mov cl,1
mov bl,0eh
call Write_Proc
lea si, InputMessage
mov ch,2
mov cl,0
mov bl,0eh
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
lea si, string ;vivod vvedennoi stroki
mov ch,5
mov cl,0
mov bl,0eh
call Write_Proc
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea si, ResultMessage ;vivod soobs4eniya-result
mov ch,6
mov cl,0
mov bl,0eh
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
lea si, string ;vivod soobs4eniya-result
mov ch,7
mov cl,0
mov bl,0eh
call Write_Proc
lea si,EnterAgainMessage ;vivod soobs4eniya-result
mov ch,8
mov cl,0
mov bl,0eh
call Write_Proc
mov ah,0
int 16h
cmp al,'y'
je start
lea si, GoodbyeMessage ;vivod soobs4eniya-result
mov ch,9
mov cl,0
mov bl,0eh
call Write_Proc
mov ax, 003h
int 10h ;ocistka ekrana
;lea dx, RightMessage ;vivod soobs4eniya-result
;call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
comment @
На вход подается:
si - адресс строки(тоже что dx и в для 9ой функции)
ch - номер столбца для вывода(нумерация с нуля)
cl - номер строки для вывода(нумераия с нуля)
bl - атрибут(цвет фона и цвет символов)
@
Write_Proc proc ;procedure for dispalying the messages
pusha
push es
push 0b800h
pop es
push cx
mov al,ch
mov dl,80
mul dl
mov di,ax
and cx,00ffh
add di,cx
shl di,1
pop cx
_rep:
lodsb
cmp al,'$'
je _endo
mov ah,bl
stosw
jmp _rep
_endo:
lea dx, crcl
mov ah,09
int 21h
pop es
popa
ret
Write_Proc endp
end begin
Киев - rules!
Я тоже из Киева! :)
Извините, что все-же настоятельно продвигаю свою программу, просто по ней не так видно, что это не моих рук творчество. Спасибо!
Код:
.model small
.386
.stack 100h
.data
max db 255
len db ' '
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!$'
VariantMessage db 'You have entered the home-task program of variant 1$'
ChoiceMessage db 'Would you like to enter the new line of characters (YES/NO) - [Y/N]$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
ResultMessage db 'Resulting string after changing every capital letter into small one$'
GoodbYeMessage db 'Thank you for your attention. Have a nice day!$'
crcl db 13,10,'$'
.code
begin:
push ax
jumps ;rozshirenie deistviya uslovnih perehodov
mov ax, 003h
int 10h ;ocistka ekrana
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
lea dx, GreetingMessage
xor ch,ch
mov cl,0
mov bl,0fh
call Write_Proc
lea dx, VariantMessage
mov ch,1
mov cl,0
mov bl,0fh
call Write_Proc
work:
lea dx, InputMessage
mov ch,2
mov cl,0
mov bl,0fh
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
mov bl,03h
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
mov ch,4
mov cl,0
mov bl,0fh
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
lea si, string ;vivod soobs4eniya-result
mov ch,5
mov cl,0
mov bl, 0bh
call Write_Proc
lea dx, ChoiceMessage
mov ch,6
mov cl,0
mov bl,0fh
call Write_Proc
mov ah,0ah
mov dh, max
int 21h
mov ah,08h ;cteniye symvola v tekuscei posicii kursora
int 10h
cmp al, 59h ;esli 'yes' - perehodim na metku work
je work ;esli 'no' -perehodim na metku escape
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
mov ch,8
mov cl,0
mov bl,0fh
call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc ;procedure for dispalying the messages
pusha
push es
push 0b800h
pop es
push cx
mov al,ch
mov dl,80
mul dl
mov di,ax
and cx,00ffh
add di,cx
shl di,1
pop cx
_rep:
lodsb
cmp al,'$'
je _endo
mov ah,bl
stosw
jmp _rep
_endo:
lea dx, crcl
mov ah,09
int 21h
pop es
popa
ret
Write_Proc endp
end begin
.386
.stack 100h
.data
max db 255
len db ' '
string db 255 dup (' ')
GreetingMessage db 'Good Afternoon Olena Anatoliyvna!$'
VariantMessage db 'You have entered the home-task program of variant 1$'
ChoiceMessage db 'Would you like to enter the new line of characters (YES/NO) - [Y/N]$'
InputMessage db 'You are welcome to enter the string with any characters',13,10,'$'
ResultMessage db 'Resulting string after changing every capital letter into small one$'
GoodbYeMessage db 'Thank you for your attention. Have a nice day!$'
crcl db 13,10,'$'
.code
begin:
push ax
jumps ;rozshirenie deistviya uslovnih perehodov
mov ax, 003h
int 10h ;ocistka ekrana
mov ax, @data
mov ds, ax ;ustanavlivaem registr ds takim obrazom 4to bi on ukazival na segment dannih
lea dx, GreetingMessage
xor ch,ch
mov cl,0
mov bl,0fh
call Write_Proc
lea dx, VariantMessage
mov ch,1
mov cl,0
mov bl,0fh
call Write_Proc
work:
lea dx, InputMessage
mov ch,2
mov cl,0
mov bl,0fh
call Write_Proc
mov ah,0ah ;vvod stroki
lea dx,max
mov bl,03h
int 21h
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;zakancivaem stroku simvovlom $
lea si,string
xor cx,cx
mov cl,len
push ds
pop es
lea di,string
cwd
go:
xor ax,ax
lodsb
cmp al, 41h
jl scip
cmp al, 5Ah
jg scip
add al, 20h
scip:
stosb
loop go
lea dx, ResultMessage ;vivod soobs4eniya-result
mov ch,4
mov cl,0
mov bl,0fh
call Write_Proc
xor bx,bx
mov bl,len
mov di,bx
mov byte ptr string[di],'$' ;end the string with symbol $
lea si, string ;vivod soobs4eniya-result
mov ch,5
mov cl,0
mov bl, 0bh
call Write_Proc
lea dx, ChoiceMessage
mov ch,6
mov cl,0
mov bl,0fh
call Write_Proc
mov ah,0ah
mov dh, max
int 21h
mov ah,08h ;cteniye symvola v tekuscei posicii kursora
int 10h
cmp al, 59h ;esli 'yes' - perehodim na metku work
je work ;esli 'no' -perehodim na metku escape
lea dx, GoodbyeMessage ;vivod soobs4eniya-result
mov ch,8
mov cl,0
mov bl,0fh
call Write_Proc
pop ax
mov ax,4c00h ;obicnoe zavershenie programi
int 21h
Write_Proc proc ;procedure for dispalying the messages
pusha
push es
push 0b800h
pop es
push cx
mov al,ch
mov dl,80
mul dl
mov di,ax
and cx,00ffh
add di,cx
shl di,1
pop cx
_rep:
lodsb
cmp al,'$'
je _endo
mov ah,bl
stosw
jmp _rep
_endo:
lea dx, crcl
mov ah,09
int 21h
pop es
popa
ret
Write_Proc endp
end begin