Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an HLA Assembly language program that implements the following function: p

ID: 3666206 • Letter: W

Question

Write an HLA Assembly language program that implements the following function:

procedure strlen( baseStringAddress: dword ); @nodisplay; @noframe;

This function should return in AL the number of characters in the string parameter, passed by its base address. Here is a sample program dialogue:

Feed Me: asdfasdf
The String You Entered: asdfasdf Has Length = 8

Feed Me: asdf
The String You Entered: asdf Has Length = 4

Explanation / Answer

DATA SEGMENT STR1 DB "ENTER YOUR STRING HERE ->$" STR2 DB "YOUR STRING IS ->$" STR3 DB "LENGTH OF STRING IS(DIRECT) ->$" STR4 DB "LENGTH OF STRING IS(COUNT) ->$" INSTR1 DB 20 DUP("$") NEWLINE DB 10,13,"$" LN DB 5 DUP("$") N DB "$" S DB ? DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX LEA SI,INSTR1 ;GET STRING strlen( baseStringAddress: dword ); @nodisplay; @noframe; MOV AH,09H LEA DX,STR1 INT 21H MOV AH,0AH MOV DX,SI INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT THE STRING MOV AH,09H LEA DX,STR2 INT 21H MOV AH,09H LEA DX,INSTR1+2 INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT LENGTH OF STRING (DIRECT) MOV AH,09H LEA DX,STR3 INT 21H MOV BL,INSTR1+1 ADD BL,30H MOV AH,02H MOV DL,BL INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT LENGTH OF STRING ANOTHER WAY MOV AH,09H LEA DX,STR4 INT 21H ADD SI,2 MOV AX,00 L2:CMP BYTE PTR[SI],"$" JE L1 INC SI ADD AL,1 JMP L2 L1:SUB AL,1 ADD AL,30H MOV AH,02H MOV DL,AL INT 21H MOV AH,4CH INT 21H CODE ENDS END START ;OUTPUT:- ;Z:SEM3SS-30>P24 ;ENTER YOUR STRING HERE ->dword ;YOUR STRING IS ->dword ;LENGTH OF STRING IS(DIRECT) ->:5 ;LENGTH OF STRING IS(COUNT) ->:5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote