Hi I'm making this program in assembly language 8086 where it can detect 'E' and replace that 'E' with 'Egg' Example: In english: English! In eggnglish: Eggnglish! Here's my attempt:
.MODEL SMALL
.STACK 100H
.DATA
english DB "In English$"
result DB 100 dup(?)
;english DB "In english: English$"
;In english: You like english and espresso, excellent!
newline DB 10,13,'$'
bigegg DB "Egg$"
smallegg DB "egg$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
mov ah, 09h
lea dx, english
int 21h
mov ah, 09h
lea dx, newline
int 21h
lea si, english ;start from first char
lea di, result
mov cx, 19
loop1:
mov al, [si]
cmp al, 45h ;E
je bige
jne checke
bige:
mov bx, si
mov cx, si
loop2:
mov ah, 02h
mov dl, [di]
int 21h
loop loop2
inc si
mov ah, 09h
lea dx, bigegg
int 21h
jmp change
checke:
cmp al, 65h ;e
je smalle
jne again
smalle:
mov bx, si
mov cx, si
loop3:
mov ah, 02h
mov dl, [di]
int 21h
loop loop3
inc si
mov ah, 09h
lea dx, smallegg
int 21h
jmp change
again:
mov al, [si] ;save I
mov [di], al
inc si
inc di
loop loop1
change:
lea si, english + 3
sub cx, si
mov cx, cx
loop4:
mov ah, 02h
mov dl, [di]
int 21h
loop loop4
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
I actually want to make my system as below: If 'e' is detected, the system will take out the 'In' first, then ignore the 'e' and then it will print 'egg' followed by 'nglish'. However, when I run my code, it prints out blank space instead. I appreciate if anyone could guide me for this Thank you for reading!