Advertisement
Guest User

6A TASM

a guest
May 24th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .MODEL SMALL
  2. .STACK
  3. .DATA
  4.         M1 DB 13,10,'ENTER THE FIRST STRING:$'
  5.         M2 DB 13,10,'ENTER THE SECOND STRING:$'
  6.         M3 DB 13,10,'LENGTH OF THE FIRST STRING:$'
  7.         M4 DB 13,10,'LENGTH OF THE SECOND STRING:$'
  8.         M5 DB 13,10,'THE TWO STRING ARE EQUAL:$'
  9.         M6 DB 13,10,'THE TWO STRING ARE NOT EQUAL:$'
  10.         STR1 DB 80 DUP(20)
  11.         STR2 DB 80 DUP(20)
  12.         LEN1 DB ?
  13.         LEN2 DB ?
  14.         DISP MACRO MSG
  15.         LEA DX,MSG
  16.         MOV AH,09H
  17.         INT 21H
  18.         ENDM
  19. .CODE
  20.  
  21.     ;Linking up the Datasegment
  22.     MOV AX,@DATA
  23.     MOV DS,AX
  24.     MOV ES,AX
  25.    
  26.     ;Getting first string from user
  27.     DISP M1
  28.     LEA DX,STR1
  29.     CALL READS
  30.    
  31.     ;Getting second string from user
  32.     DISP M2
  33.     LEA DX,STR2
  34.     CALL READS
  35.    
  36.     ;Getting length of the first string
  37.     MOV AL,[STR1+1]
  38.     MOV LEN1,AL
  39.    
  40.     ;Getting length of the second string
  41.     MOV AL,[STR2+1]
  42.     MOV LEN2,AL
  43.    
  44.     ;Comparing the length of both the strings and jumping to STRNOTE if they're not equal
  45.     CMP AL,LEN1
  46.     JNE STRNOTE
  47.    
  48.     ;Comparing each characters of string incase both the lengths are equal
  49.     MOV CH,0
  50.     MOV CL,LEN1
  51.     LEA SI,STR1+2
  52.     LEA DI,STR2+2
  53.     CLD
  54.     REPE CMPSB
  55.     JNE STRNOTE
  56.    
  57.     ;Displaying that both strings are qual
  58.     DISP M5
  59.     JMP NEXT
  60.    
  61.     ;Displaying that both strings are not equal
  62.     STRNOTE:
  63.         DISP M6
  64.    
  65.     NEXT:
  66.    
  67.         ;Displaying the length of first string
  68.         DISP M3
  69.         MOV AL,LEN1
  70.         CALL DISPLAY
  71.        
  72.         ;Displaying the length of second string
  73.         DISP M4
  74.         MOV AL,LEN2
  75.         CALL DISPLAY
  76.        
  77.         ;Quitting the program
  78.         MOV AH,4CH
  79.         INT 21H
  80.    
  81.     ;Procedure to read an entire string
  82.     READS PROC
  83.         MOV AH,0AH
  84.         INT 21H
  85.         RET
  86.     READS ENDP
  87.    
  88.     ;Procedure to dispaly a number in string format using AAM
  89.     DISPLAY PROC
  90.    
  91.         ;ASCII Adjustment After Multiplication
  92.         AAM
  93.         MOV BX,AX
  94.        
  95.         ;Adding 3030 to conver the data to its ASCII form to display on screen
  96.         ADD BX,3030H
  97.        
  98.         ;Displaying MSB
  99.         MOV DL,BH
  100.         MOV AH,02H
  101.         INT 21H
  102.        
  103.         ;Displaying LSB
  104.         MOV DL,BL
  105.         INT 21H
  106.         RET
  107.     DISPLAY ENDP
  108. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement