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

I need the following program written in x86 assembly using only the Irvine Libra

ID: 3578329 • Letter: I

Question

I need the following program written in x86 assembly using only the Irvine Library:

Create a program that will allow a user to type in the names of each student in the class, and then enter their letter grades (A, B, C, D, F). Once all of the data has been entered, clear the screen, and display the names and grades as described below.

Please use the following Irvine library procedures to write this (You may use other but you shouldn't need them):

ReadChar - ReadChar reads a single character from keyboard and returns in the AL register. the character is not echoed in the console window.

sample of ReadChar - .data

char BYTE ?

.code

call ReadChar

mov char, al

ReadString - Reads a string from the keyboard, stopping when the user presses the enter key. Pass the offset of a buffer in EDX and set ECX to the maximum number of characters the user can enter, plus 1 (to save space for the terminating null byte). The procedure returns the count of the number of characters typed by the user in EAX.

Sample of ReadString - .data

buffer BYTE 21 DUP(0) ;input buffer

byteCount DWORD ? ; holds counter

.code

mov edx, OFFSET buffer ; point to the buffer

mov ecx, SIZEOF buffer ; specify max characters

call ReadString ; input the string

mov byteCount, eax ; number of characters

WriteString - Writes a null-terminated string to the console window. Pass the string's offset in EDX.

sample of WriteString - .data

prompt BYTE "Enter your name: ", 0

.code

mov edx, OFFSET promt

call WriteString

GoToXY - locates the cursor at a given row and column in the console-window. By default, the console window's X-coordinate range is 0 - 79 and the Y-coordinate range is 0 - 24. When you call GoToXY, pass the Y-coordinate (row) in DH and the x-coordinate (col) in DL.

Sample of GoToXY - mov dh, 12 ; row 12

mov dl, 26 ; row 26

call Gotoxy ; locate cursor

WriteChar - Writes a single character to the console window. Pass the character (or its ASCII code) in AL.

sample of WriteChar - mov al, 'A'

call WriteChar ; displays: "A"

SetTextColor - gets the current foreground and background colors of the console window. It has no input parameters. It returns the background color in the upper four bits of AL and the foreground color in the lower four bits.

Sample of SetTextColor: .data

color byte ?

.code

call GetTextColor

mov color, AL

Requirements of Program:

1.) The first input prompt should be a message that asks for a students name. Your program should be able to accept names of up to 25 characters in length.

2.) After a name has been entered, you should display a prompt requesting the student's grade. The prompt should resemble: Please enter John Doe's grade. Where John Doe is the student's name that was collected in step 1.

3.) Make sure to validate the grade to confirm that it is one of the valid grades (A, B, C, D, F). If a lowercase 'a' is input the program should capitiliaze it so it looks like 'A'. This should happen with all the grades input. If an invalid grade is entered then the program should prompt for the letter grade again, until a valid grade is entered.

4.) Continue to request names and grades until a maximum of 20 student names have been entered. If the maximum number of 20 students has been reached or ther user hits enter instead of typing in a name then the input should terminate and move on to step 5, 6, then 7.

5.) After all the data has been entered be sure to clear the screen.

6.) Display the student's names one per row starting at Row 3, Column 5. The students grades should be in Column 32 of each Row. Example: Joe Smith A

Jill Jones A

John Henry C

7.) The student's names can be displayed in any attributes. The display color of the student's grade should depend on the grade. That is A's, B's, and C's should be white, D's should be yellow, and F's should be red.

Explanation / Answer

; Program template
INCLUDE Irvine32.inc

bufsize =100

Student STRUCT
       nameBuffer BYTE 26 DUP(?); Buffer for user name
        gradeBuffer BYTE 26 DUP(0); Buffer for grade? should be Char I think lol
   Student ENDS

.data
   temp BYTE ?
   row BYTE 3

    endl EQU <0dh,0ah>           ; end of line sequence
    consoleHandle HANDLE 0     ; handle to standard output device
    bytesWritten DWORD ?      ; number of bytes written

   buffers BYTE BufSize DUP(?)

displayResults MACRO StudentSize
      Movzx Ecx, StudentSize
      mov Esi,0
  
startGradeDisplay:

   AND (Student PTR studentArray[esi]).gradeBuffer, 0dfh  
  
   mov dh, row

   mov dl, 5
   call Gotoxy
   LEA EDX, (Student PTR studentArray[esi]).namebuffer
    Call writeString

   mov dh, row
   mov dl, 32
   call Gotoxy

   mov al, (Student PTR studentArray[esi]).gradeBuffer
   cmp al, 44h
   je gradeyellow
   cmp al, 46h
   je gradered
   mov eax, white + (black *16)
   call settextcolor
   jmp printgrade
  
    colorgrade:

   JMP startgradedisplay
   graded:

   gradeYellow:
   Mov EAX, Yellow + (2 * 16)
    Call SetTextColor
    JMP printGrade

   gradeRed:
   Mov EAX, Red + (2 * 16)
   Call SetTextColor
   JMP printGrade ; end of color validations

   printGrade:
   lea edx, (Student PTR StudentArray[esi]).gradebuffer
   call writeString
  
   movzx eax, temp +(Black*16)
   call SetTextcolor

   inc row
   add esi, SIZEOF Student
   loop colorgrade

EndM
   ; declare variables here
   askStudent BYTE "Please enter your name", 0dh, 0ah, 0 ; asks student for name

   gradeMSG1 BYTE "Please enter ", 0; Prompting user for grade  
   gradeMSG2 BYTE "'s grade ",0; Prompting user for grade
  
   studentArray Student 20 DUP(<>)
   MaxStuds BYTE 20
   numStuds BYTE 0
   validgrade BYTE "A B C D F"
   notvalid BYTE "This grade wrong enter again"


   .code
  
main proc

call GetTextColor
mov temp, al

movzx ecx, maxstuds

mov esi, 0

DisplayCode:
push ecx
call getName
cmp (STudent PTR studentArray[esi]).nameBuffer,0
jz next
push esi
call getGrade
pop esi
inc numstuds
add esi, SIZEOF student
pop ecx
Jmp displaycode
next:
call clrscr

displayResults numStuds

call Crlf

movzx eax, temp +(black *16)
call SetTextColor

mov dh,27
mov dl,5
call gotoxy
call waitmsg
call clrscr
exit

main endp

getname Proc
mov edx, offset askStudent
call writestring
lea edx, (STudent PTR studentArray[ESI]).nameBuffer
mov ecx, SIZEOF (STudent PTR studentArray[ESI]).namebuffer
call ReadSTring

ret
getname ENDP

GetGrade PROC

getThatgrade:

mov edx, OFFSET gradeMSG1
call writeSTring

lea edx, (STudent PTR studentArray[ESI]).namebuffer
call WriteSTring

mov edx, OFFSET grademsg2
call WriteSTring

lea edx, (STudent PTR studentArray[ESI]).gradebuffer
mov ecx, SIZEOF (STudent PTR studentArray[ESI]).gradebuffer

call ReadString

mov al, (Student PTR studentArray[ESI]).gradebuffer
push esi
mov esi, 0 - TYPE validGRade

mov ecx, LENGTHOF validGRade
Valid:
add esi, TYPE validGRade
cmp al, validgrade[esi]
Loopne Valid
pop esi
jne notFound

found:
ret
notfound:
jmp getThatgrade

getgrade endp

invoke ExitProcess,0

end main

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