Created
October 9, 2012 21:01
-
-
Save tanayseven/3861413 to your computer and use it in GitHub Desktop.
program to compare two strings using string instructions using 8086 asm lang.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;program to compare two strings using string instructions | |
INCLUDE io.h | |
Cr EQU 0ah | |
Lf EQU 0dh | |
data SEGMENT | |
p_str1 DB Cr, Lf, 'Enter 1st string: ',0 | |
p_str2 DB Cr, Lf, 'Enter 2nd string: ',0 | |
p_not DB Cr, Lf, 'The strings are not same',0 | |
p_same DB Cr, Lf, 'The strings are the same',0 | |
str1 DB 100 DUP (?) | |
str2 DB 100 DUP (?) | |
data ENDS | |
code SEGMENT | |
ASSUME cs:code, ds:data | |
start: mov ax, data | |
mov ds, ax | |
;input str1 | |
output p_str1 | |
inputs str1, 100 | |
;input str2 | |
output p_str2 | |
inputs str2, 100 | |
;initialize | |
lea si, str1 | |
lea di, str2 | |
;use string instructions | |
;to comapre the two strings | |
cld;clear direction flags | |
repe cmpsb;repeat compare string byte | |
je p_same | |
jmp p_not | |
l_not: output p_not | |
jmp quit | |
l_same: output p_same | |
quit: mov al, 00h | |
mov ah, 4ch | |
int 21h | |
code ENDS | |
END start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be following on line 33 and 34