Monday, 27 August 2018

Assuming that there is a spelling of “Europe” in an electronic dictionary and a user types in “Euorope”, write a program that compares these two and displays the following message, depending on a result: 1. If they are equal, display “The spelling is correct” 2. If they are not equal, display “Wrong Spelling”

.MODEL SMALL
.STACK 100H
.DATA
;from the data segment
DAT_DIC DB 'Europe'
DAT_TYPED DB 'Euorope'
MESSAGE1 DB 'The spelling is correct$'
MESSAGE2 DB 'Wrong spelling$'

;from code segment:
.CODE
MAIN PROC
   
    MOV AX, @DATA
    MOV DS, AX
   
    CLD                         ;DF=0 for increment
    MOV SI,OFFSET DAT_DIC       ;SI=offset of DAT_DIC
    MOV DI,OFFSET DAT_TYPED     ;DI=offset of DAT_TYPED
    MOV CX,06                   ;load the counter
    REPE CMPSB                  ;repeat as long as equal or until CX=0
    JE OVER                     ;if ZF=1 then display MESSAGE1
   
    MOV DX,OFFSET MESSAGE2      ;if ZF=0 then display MESSAGE2
    JMP DISPLAY
   
OVER:
    MOV DX,OFFSET MESSAGE1

DISPLAY:
    MOV AH,09
    INT 21H

    MOV AH, 4CH
    INT 21H
    MAIN ENDP
END MAIN

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hire Full Stack Developers Texas
    Hire Full Stack Developer
    https://www.inwizards.com/hire-full-stack-developer.php
    I am a regular reader of your blog. I found that your all blogs are quite informative, interesting and helpful. Thank You for sharing with users such a useful information and guide a different techniques.

    ReplyDelete