Write a subroutine to calculate the string length-00860

Online Quiz This subjective question is related to the book/course vu cs507 Information Systems. It can also be found in vu cs507 Mid Term Solved Past Paper No. 4.

Question 1: Write a subroutine to calculate the string length?
Answer:

subroutine to calculate the length of a string; takes the segment and offset of a string as parameters

strlen: push bp
mov bp,sp
push es
push cx
push di
les di, [bp+4] ; point es:di to string
mov cx, 0xffff ; load maximum number in cx
xor al, al ; load a zero in al
repne scasb ; find zero in the string
mov ax, 0xffff ; load maximum number in ax
sub ax, cx ; find change in cx
dec ax ; exclude null from length
pop di
pop cx
pop es
pop bp
ret 4

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background