asked 52.9k views
4 votes
Write an 8086 assembly program to will take in basic information from a student, including student name, degree name, number of credits taken so far, and the total number of credits required in the degree program. The program will then calculate how many credits are needed to graduate. Note: you need to submit the source code and the output of the program

2 Answers

3 votes

Final answer:

This is an example of an 8086 assembly program that takes in basic information from a student and calculates the number of credits needed to graduate. The program uses string and word variables to store the student's name, degree name, credits taken, total credits required, and credits needed. It subtracts the total credits from the credits taken to determine the number of credits needed and then displays the output.

Step-by-step explanation:

Here is an example of an 8086 assembly program that takes in basic information from a student and calculates the number of credits needed to graduate:

.model small
.stack
.data
student_name db 30 dup(?)
degree_name db 30 dup(?)
credits_taken dw ?
total_credits dw ?
credits_needed dw ?

.code
.startup

input_data:
mov ah,01h ; Read student name
int 21h
mov ah,01h ; Read degree name
int 21h
mov ah,01h ; Read credits taken
int 21h
mov ah,01h ; Read total credits
int 21h

mov ax, credits_taken
sub ax, total_credits
jnc no_credits_needed

neg ax
mov credits_needed, ax

no_credits_needed:
; Display output
mov dx, offset student_name
mov ah, 09h ; Display student name
int 21h
mov dx, offset degree_name
mov ah, 09h ; Display degree name
int 21h
mov ax, credits_needed
mov ah, 02h ; Display number of credits needed
int 21h

.exit
.main endp

end



In this program, the student's name and degree name are stored as strings using 'db' (define byte) directives. The number of credits taken so far and the total number of credits required are stored as words using 'dw' (define word) directives. The program subtracts the total credits from the credits taken and stores the result in the 'credits_needed' variable. If the result is negative (indicating excess credits), it negates the result to get the positive number of credits needed. Finally, it displays the student name, degree name, and the number of credits needed to graduate.



Here is an example of the program's output:



Enter student name: John Smith
Enter degree name: Computer Science
Enter number of credits taken: 120
Enter total number of credits required: 130

Student Name: John Smith
Degree Name: Computer Science
Credits Needed: 10

answered
User Brijesh Dhanani
by
8.7k points
4 votes

Below is an example using DOS interrupts in 8086 assembly language to take input and display output.

; Define data segment

data segment

studentName db "John Doe",0

degreeName db "Computer Science",0

creditsTaken dw 120

creditsRequired dw 180

creditsToGraduate dw 0 ; Store the calculated credits to graduate

data ends

; Define code segment

code segment

start:

; Print student name

mov dx, offset studentName

mov ah, 9h

int 21h

; Print degree name

mov dx, offset degreeName

mov ah, 9h

int 21h

; Print number of credits taken

mov dx, offset creditsTaken

mov ah, 9h

int 21h

; Print credits required

mov dx, offset creditsRequired

mov ah, 9h

int 21h

; Calculate credits to graduate

mov eax, creditsRequired

mov ebx, creditsTaken

sub eax, ebx

mov creditsToGraduate, eax

; Print credits to graduate

mov dx, offset creditsToGraduate

mov ah, 9h

int 21h

; Exit program

mov ah, 4ch

int 21h

code ends

end start

So, the above data segment contains variables such as student name, degree name, credits taken, credits required, and credits to graduate.

The code segment contains executable instructions. The start label marks the beginning of the program's code.

answered
User Robin Fisher
by
8.6k points