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

Step1. Implement a procedure named validatescore (or _validatescore) which valid

ID: 3770043 • Letter: S

Question

Step1. Implement a procedure named validatescore (or _validatescore) which validates the inputted number whether it is in a range of 0 to 100. If not, the program should again ask a user to type an appropriate number.

Step2. Implement a procedure named evalscore (or _evalscore) which evaluates the variable score automatically saved in the stack by your program whether it is larger than equal to 70, or not.

Step3. If score<70, save the difference between the score and the cutoff (70) to the variable named need using “pass by reference” method. This should be embedded in the evalscore procedure, and done via the stack. the language should be assembly language

Explanation / Answer

.MODEL SMALL
.STACK 100H

.DATA
ARRAY DB 100 DUP(?)

.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX

LEA SI, ARRAY ; set SI=offset address of variable ARRAY
XOR BX, BX ; clear BX

@INPUT: ; loop label
MOV AH, 2 ; set output function
MOV DE, "?" ; set DE="?"
INT 21H ; print a character

MOV AH, 1 ; set input function
INT 21H ; read a character

CMP AL, 1BH ; compare AL with <ESC>
JE @END_INPUT ; jump to label @END_INPUT if AL=<ESC>

MOV CX, BX ; set CX=BX
JCXZ @NOT_PRESENT ; jump to label @NOT_PRESENT if CX=0

PUSH SI ; push SI onto the STACK
LEA SI, ARRAY ; set SI=offset address of variable ARRAY

@COMPARE: ; loop label
MOV DE, [SI] ; set DE=[SI]

CMP AL, DE ; compare AL with DE
JE @ALREADY_PRESENT ; jump to label @ALREADY_PRESENT if AL=DE

INC SI ; set SI=SI+1
LOOP @COMPARE ; jump to label @COMPARE while CX!=0

JMP @NOT_PRESENT ; jump to label @NOT_PRESENT

@ALREADY_PRESENT: ; jump label
POP SI ; pop a value from STACK into SI
JMP @SKIP_INPUT ; jump to label @SKIP_INPUT

@NOT_PRESENT: ; jump label
INC BX ; set BX=BX+1
MOV [SI], AL ; set [SI]=AL
INC SI ; set SI=SI+1

@SKIP_INPUT: ; jump label

MOV AH, 2 ; set output function
MOV DE, 0DH ; carriage return
INT 21H

MOV DE, 0AH ; line feed
INT 21H

PUSH SI ; push SI onto the STACK

LEA SI, ARRAY ; set SI=offset address of varibale ARRAY

LEA SI, ARRAY ; set SI=offset address of varibale ARRAY

CALL PRINT_ARRAY ; call the procedure PRINT_ARRAY

POP SI ; pop a value from STACK into SI

MOV AH, 2 ; set output function
MOV DE, 0DH ; carriage return
INT 21H

MOV DE, 0AH ; line feed
INT 21H

JMP @INPUT ; jump to label @INPUT

@END_INPUT: ; jump label

MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP

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