Question

In: Computer Science

Assembly Language Visual Studio. Problem 1 College Registration Using the College Registration example from Section 6.7.3...

Assembly Language Visual Studio.

Problem 1
College Registration
Using the College Registration example from Section 6.7.3 (textbook) as a starting point, do the
following:
1. Recode the logic using CMP and conditional jump instructions (instead of the .IF and .ELSEIF
directives).
2. Perform range checking on the credits value; it cannot be less than 1 or greater than 30. If
an invalid entry is discovered, display an appropriate error message.
3. Prompt the user for the grade average and credits values.
4. Display a message that shows the outcome of the evaluation, such as “The student can registe”r or “The student cannot register”.
(The Irvine32 library is required for this solution program.)
50 points

Problem 2
Validating a PIN
Banks use a Personal Identification Number (PIN) to uniquely identify each customer. Let us
assume that our bank has a specified range of acceptable values for each digit in its customers’
5-digit PINs. The table shown below contains the acceptable ranges, where digits are numbered
Page 1
from left to right in the PIN. Then we can see that the PIN 52413 is valid. But the PIN 43534 is
invalid because the first digit is out of range. Similarly, 64535 is invalid because of its last digit.
Digit Number Range
1 5 to 9
2 2 to 5
3 4 to 8
4 1 to 4
5 3 to 6
Your task is to create a procedure named Validate PIN that receives a pointer to an array of
byte containing a 5-digit PIN. Declare two arrays to hold the minimum and maximum range
values, and use these arrays to validate each digit of the PIN that was passed to the procedure. If
any digit is found to be outside its valid range, immediately return the digit’s position (between 1
and 5) in the EAX register. If the entire PIN is valid, return 0 in EAX. Preserve all other register
values between calls to the procedure. Write a test program that calls Validate PIN at least four
times, using both valid and invalid byte arrays. By running the program in a debugger, verify that
the return value in EAX after each procedure call is valid. Or, if you prefer to use the book’s
library, you can display ”Valid” or ”Invalid” on the console after each procedure call.

Solutions

Expert Solution

Answer :

2) The assembly code for pin validation is:

code:

INCLUDE Irvine32.inc
.data
str1 BYTE "valid",0
str2 BYTE "Invalid",0
minArr BYTE 5,2,4,1,3
maxArr BYTE 9,5,8,4,6
arr1 BYTE 5,1,5,3,6
arr2 BYTE 8,4,5,2,5
arr3 BYTE 6,4,5,3,5
arr4 BYTE 5,4,9,2,6
.code
main PROC
call Clrscr
mov ebx OFFSET arr1
mov esi OFFSET minArr
mov edi,OFFSET maxArr
call Validate_PIN
.IF eax==0
mov edx,OFFSET str1
call WriteString
call Crlf
.ELSE
mov edx,OFFSET str2
call WriteString
call Crlf
.ENDIF
mov ebx OFFSET arr1
call Validate_PIN
.IF eax==0
mov edx,OFFSET str1
call WriteString
call Crlf
.ELSE
mov edx,OFFSET str2
call WriteString
call Crlf
.ENDIF
mov ebx,OFFSET arr3
call Validate_PIN
.IF eax==0
mov edx,OFFSET str1
call WriteString
call Crlf
.ELSE
mov edx,OFFSET str2
call WriteString
call Crlf
.ENDIF
mov ebx,OFFSET arr4
call Validate_PIN
.IF eax==0
mov edx,OFFSET str1
call WriteString
call Crlf
.ELSE
mov edx,OFFSET str2
call WriteString
call Crlf
.ENDIF
exit
main ENDP
Validate_PIN PROC USES ecx edx esi edi
mov ecx,5
mov eax,0
L1:
mov a1[ebx]
.IF(a1>=[esi])&&(a<=[edi])
inc ebx
inc esi
inc edi
.ELSE
mov eax,6
sub eax,ecx
ja L2
.ENDIF
loop L1
mov eax,0
l2:
ret
Validate_PIN ENDP
END main

Result:

Invalid

valid

valid

Invalid

=============================================================================

ANSWERED AS PER MY KNOWLEDGE

IF ANY DOUBTS COMMENT IT


Related Solutions

MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course. Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio...
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio development environment 3. To practice on writing a C# program Task 1: Create documentation for the following program which includes the following: a. Software Requirement Specification (SRS) b. Use Case Task 2: Write a syntactically and semantically correct C# program that models telephones. Your program has to be a C# Console Application. You will not implement classes in this program other than the class...
Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the...
Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from 0 to 100, computes the average of those scores and then writes out a letter grade using the typical grading scale. Your program will also: 1. Allow the user to enter any number of scores he or she wishes but assume there will be at least one score entered. 2. Use a sentinel-controlled loop variable to terminate the loop when the user has no...
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ...
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ based exams.It takes input from a file having questions and their answers and presents randomly before the exam takers. Required skill set: OOP, STL(Vector), Arrays and file handling
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT