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

Problem 1. Code Development (50 points) Write an SRC subroutine that counts the

ID: 3913914 • Letter: P

Question

Problem 1. Code Development (50 points) Write an SRC subroutine that counts the number of upper-case characters in a null-terminated string. Your subroutine should accept its argument, a pointer to the string, in Register rO; and return its result, the count of upper-case characters in Register r4. Your subroutine should adhere to the coding convention as used in class. a. Develop a STEP-BY-STEP algorithm for the subroutine in the right side of the table below b. Write the SRC instructions that implement your algorithm in the left side of the table below Code Algorithm

Explanation / Answer

The Given Ans By :

DATA SEGMENT

STR1 DB 'WELCOME TO'

STR2 DB 'CHEGG'

MSG1 DB 10,13,'Length of the string1:-$'

MSG2 DB 10,13,'Length of the string2:-$'

MSG3 DB 10,13,'Strings are equal length $'

MSG4 DB 10,13,'First string is longer than the second string $'

MSG5 DB 10,13,'First string is shoter than the second string $'

LEN1 DB 0H

LEN2 DB 0H

R4 DB 0H

DATA ENDS

DISPLAY MACRO MSG

MOV AH,9

LEA DX,MSG

INT 21H

ENDM

CODE SEGMENT

ASSUME CS:CODE,DS:DATA

START:

MOV AX,DATA
MOV DS,AX

LEA SI,STR1
NEXT1:
CMP [SI],'$'
JE DONE1
INC LEN1
INC SI
JMP NEXT1
DONE1:
DISPLAY MSG1
MOV AL,LEN1
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
LEA DI,STR2
NEXT2:
CMP [DI],'$'
JE DONE2
INC LEN2
INC DI
JMP NEXT2

DONE2:
DISPLAY MSG2
MOV AL,LEN2
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
MOV AL,LEN1
CMP AL,LEN2
MOV R4,AL
CMP R4,0
JE EQUAL
CMP R4,'-$'

JE NEGATIVE
DIPLAY MSG4
JMP EXIT
EQUAL:
DISPLAY MSG3

NEGATIVE:

DISPLAY MSG5
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START

ALGORITHM:

STEP1: Define data segment give the two input strings to the variables,delare the variables and end the data segment.

STEP2: Define macro and end the macro section.

STEP3:Strat the code segment in that we can write the code.

STEP4:Move data to the register and length of the string is stored in a pointers.

STEP5:And length of the strings is stored in a register and compare those register.

STEP6:Comparision value stored in to R4 register.

STEP7:If comparision value is equal to zero then go to the 'EQUAL' label and execute the instructions in that label.

STEP8:If comparision value equal to negative then control go to negative label and execute the instructions in the label.

STEP9:If comparsion value is positive than execute the instruction and display coressponding output

STEP10:cursor go to the exit block and execute corressponding instructions exit block.

STEP11:Code block end and end start.

Code Algorithm

DATA SEGMENT

STR1 DB 'WELCOME TO'

STR2 DB 'CHEGG'

MSG1 DB 10,13,'Length of the string1:-$'

MSG2 DB 10,13,'Length of the string2:-$'

MSG3 DB 10,13,'Strings are equal length $'

MSG4 DB 10,13,'First string is longer than the second string $'

MSG5 DB 10,13,'First string is shoter than the second string $'

LEN1 DB 0H

LEN2 DB 0H

R4 DB 0H

DATA ENDS

DISPLAY MACRO MSG

MOV AH,9

LEA DX,MSG

INT 21H

ENDM

CODE SEGMENT

ASSUME CS:CODE,DS:DATA

START:

MOV AX,DATA
MOV DS,AX

LEA SI,STR1
NEXT1:
CMP [SI],'$'
JE DONE1
INC LEN1
INC SI
JMP NEXT1
DONE1:
DISPLAY MSG1
MOV AL,LEN1
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
LEA DI,STR2
NEXT2:
CMP [DI],'$'
JE DONE2
INC LEN2
INC DI
JMP NEXT2

DONE2:
DISPLAY MSG2
MOV AL,LEN2
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
MOV AL,LEN1
CMP AL,LEN2
MOV R4,AL
CMP R4,0
JE EQUAL
CMP R4,'-$'

JE NEGATIVE
DIPLAY MSG4
JMP EXIT
EQUAL:
DISPLAY MSG3

NEGATIVE:

DISPLAY MSG5
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START

ALGORITHM:

STEP1: Define data segment give the two input strings to the variables,delare the variables and end the data segment.

STEP2: Define macro and end the macro section.

STEP3:Strat the code segment in that we can write the code.

STEP4:Move data to the register and length of the string is stored in a pointers.

STEP5:And length of the strings is stored in a register and compare those register.

STEP6:Comparision value stored in to R4 register.

STEP7:If comparision value is equal to zero then go to the 'EQUAL' label and execute the instructions in that label.

STEP8:If comparision value equal to negative then control go to negative label and execute the instructions in the label.

STEP9:If comparsion value is positive than execute the instruction and display coressponding output

STEP10:cursor go to the exit block and execute corressponding instructions exit block.

STEP11:Code block end and end start.

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