TITLE ask1
DOSSEG
.MODEL SMALL
.STACK 100h
.DATA
str1 db 20,?,20 dup (?)
str2 db 20 dup (?)
.CODE
EXTRN _asm2pas:PROC
PUBLIC _length
start: MOV ax, @DATA
MOV ds, ax ;Initialising Data Seg
sub ax,ax
lea dx, str1
mov ah,0ah ;Reading the string
int 21h
;Calling the function and passing the arguments
;-------------------------------------------------------
LEA ax, str2 ;argument1
PUSH ax ;Saving the argument in the Stack
LEA ax, str1 ;argument2
ADD ax,2 ;Ignore the first 2 bytes
PUSH ax ;Saving the argument in the Stack
CALL _asm2pas ;Calling the procedure
POP cx ;Balance
POP cx ;Balance
;-------------------------------------------------------
mov ax,4C00h ;Termatizoume
int 21h ;to programma
;String Length
_length PROC NEAR
PUSH bp ;Saving bp
MOV bp,sp ;Keeping Current SP for Use
PUSH dx ;Saving dx
PUSH cx ;Saving cx
MOV bx,[bp+4] ;bx <- argument
MOV dl,[bp+6] ;EndOfString Character-argument2
SUB ax,ax ;ax = NULL , will be our counter
JMP jspot ;Start with compare
lp1: inc ax ;Counting the Size (1 byte per loop)
inc bx ;Moving to the Next Address (next letter)
jspot: mov cx,[bx]
CMP cl,dl ;compare if end of string
JNE lp1 ;If Not Equal jump lp1 (for next letter)
;else : return (ax opote dn xreiazete)
POP cx ;Restoring
POP dx ;Restoring
;POP ax ;Restoring
POP bp ;Restoring
RET ;Ending
_length ENDP
END start