You are on page 1of 6

CSIT238-Project Description

Student1: Section: Grade: /10


Student2:
Student3:
Student4:
Student5:

Maximum number of students in a group: 5


Due Date: Monday, April 12, 2021 , submit this file on your account on Blackboard with
screenshots of the code and output
Task:

Create a program that do the basic calculation for unsigned 32-bit integers. It should display a menu with
the following options:

Calculater
Press 'A' For ADDITION
Press 'S' For SUBTRACTION
Press 'M' For MULTIPLICATION
Press 'D' For DIVISION
****************************
Enter Your CHOICE

1- Ask the user to make a selection by entering a character.


Note: the program should accept lower and upper case. For example: A or a

2- Prompt the user to enter two integers, and store each number in a variable.
hint: declare two uninitialized variables.

3- Call a procedure to perform the arithmetic operation, then display the result by printing “The
answer for the implemented operation”
for example if user chose: ‘A’ For Addition, display: “The answer for ADDITION”

4- After displaying the answer, use a Msgbox to ask if the user want to continue?
 When pressed ‘yes’ clear the screen, and return to the Main Menu
 When pressed ‘No’ print a msg indicating the end of the program, with different text and
background color, then exit the program

5- Use ADD, SUB, MUL, DIV, CDQ to perform the arithmetic operation.

6- Use WriteString, ReadChar, WriteInt, SetTextColor, ReadInt procedures by linking irvine32


library.

7- At least use the following once:


 Loop
 User define procedure
 Conditional jump
CSIT238-Project Description

**Hint
The MsgBoxAsk procedure displays a graphical popup message box with Yes and No buttons. Pass it the
offset of a question string in EDX, which will appear in the inside the box. Optionally, pass the offset of a
string for the box’s title in EBX. To leave the title blank, set EBX to zero.
MsgBoxAsk returns an integer in EAX that tells you which button was selected by the user. The value
will be one of two predefined Windows constants: IDYES (equal to 6) or IDNO (equal to 7).
Sample call:
.data
caption BYTE "Survey Completed",0
question BYTE "Thank you for completing the survey."
BYTE 0dh,0ah
BYTE "Would you like to receive the results?",0
.code
mov ebx,OFFSET caption
mov edx,OFFSET question
call MsgBoxAsk
;(check return value in EAX)

1-ScreenShot of the code:

2-ScreenShot of the output of each arithmetic operation (4 outputs):

2-ScreenShot of the MsgBoxAsk , and the output when pressed ‘Yes’, and ‘No’:

INCLUDE Irvine32.inc
BUFMAX = 128
.data
CaseTable BYTE 'A'
DWORD Process_A
BYTE 'B'
DWORD Process_B
BYTE 'C'
DWORD Process_C
BYTE 'D'
DWORD Process_D
BYTE 'E'
DWORD Process_E
NumberOfEntries = 5
Nameprompt BYTE "Please enter your name: ", 0
prompt BYTE "Choose a letter by pressing the corresponding capital letter: ",
0dh, 0ah
BYTE "A: Add two binary numbers", 0dh, 0ah
BYTE "B: Subtract two binary numbers", 0dh, 0ah
BYTE "C: Writing from decimal number to a binary form", 0dh, 0ah
BYTE "D: Converting a character to capital", 0dh, 0ah
BYTE "E: Reverse the case of an alphabetic character", 0dh, 0ah, 0
msgA BYTE "Add two binary numbers: ",0
msgB BYTE "Subtract two binary numbers: ",0
msgC BYTE "Writing out a decimal number in its binary form: ", 0
msgD BYTE "Convert a character to an uppercase: ", 0
msgE BYTE "Reverse the case of an alphabetic character: ", 0
CSIT238-Project Description

prompt1 BYTE "Enter a number: ", 0


prompt2 BYTE "Enter lowercase letter: ", 0
prompt3 BYTE "Enter a lowercase or capital letter: ", 0
promptAdd BYTE ", the binary sum is: ", 0
promptSub BYTE ", the binary difference is: ", 0
promptCon BYTE ", the binary number is: ", 0
promptUp BYTE ", this is the uppercase letter: ", 0
promptReverse BYTE ", this is the reverse case: ", 0
buffer BYTE BUFMAX+1 DUP(0)
bufSize DWORD ?
.code
main PROC
mov edx, OFFSET Nameprompt
call WriteString
mov ecx, BUFMAX
mov edx, OFFSET buffer
call ReadString
mov bufSize,eax
call Crlf
mov edx, OFFSET prompt
call WriteString
call Crlf
call ReadChar
mov ebx,OFFSET CaseTable
mov ecx,NumberOfEntries
L1:
cmp al,[ebx]
jne L2
call NEAR PTR [ebx + 1]
call Crlf
jmp L3
L2:
add ebx,5
loop L1
L3:
exit
main ENDP
Process_A PROC
mov edx,OFFSET msgA
call WriteString
call Crlf
call Process_A1
call Process_A2
ret
Process_A ENDP
Process_A1 PROC
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ebx, eax
call WriteBinB
call Crlf
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ecx, eax
call WriteBinB
CSIT238-Project Description

call Crlf
ret
Process_A1 ENDP
Process_A2 PROC
call Crlf
mov ax, blue + (white * 16)
call SetTextColor
mov edx,OFFSET buffer
call WriteString
mov edx,OFFSET promptAdd
call WriteString
add ebx, ecx
mov eax, ebx
call WriteBinB
call Crlf
mov eax, white + (black * 16)
call SetTextColor
ret
Process_A2 ENDP
Process_B PROC
mov edx,OFFSET msgB
call WriteString
call Crlf
call Process_B1
call Process_B2
ret
Process_B ENDP
Process_B1 PROC
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ebx, eax
call WriteBinB
call Crlf
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ecx, eax
call WriteBinB
call Crlf
ret
Process_B1 ENDP
Process_B2 PROC
call Crlf
mov eax, blue + (white * 16)
call SetTextColor
mov edx,OFFSET buffer
call WriteString
mov edx,OFFSET promptSub
call WriteString
sub ebx, ecx
mov eax, ebx
call WriteBinB
call Crlf
mov eax, red + (black * 16)
call SetTextColor
ret
Process_B2 ENDP
CSIT238-Project Description

Process_C PROC
mov edx,OFFSET msgC
call WriteString
call Crlf
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ebx, eax
call Crlf
mov eax, blue + (white * 16)
call SetTextColor
mov edx,OFFSET buffer
call WriteString
mov edx,OFFSET promptCon
call WriteString
mov eax, ebx
call WriteBinB
call Crlf
mov eax, white + (black * 16)
call SetTextColor
ret
Process_C ENDP
Process_D PROC
mov edx,OFFSET msgD
call WriteString
call Crlf
mov edx,OFFSET prompt2
call WriteString
call ReadChar
call WriteChar
and al, 11011111b
mov bl, al
call Crlf
mov eax, blue + (white * 16)
call SetTextColor
mov edx,OFFSET buffer
call WriteString
mov edx,OFFSET promptUp
call WriteString
mov eax, 0
mov al, bl
call WriteChar
call Crlf
mov eax, white + (black * 16)
call SetTextColor
ret
Process_D ENDP
Process_E PROC
mov edx,OFFSET msgE
call WriteString
call Crlf
mov edx,OFFSET prompt3
call WriteString
call ReadChar
call WriteChar
L1: cmp al, 01100001b
jl L2
and al, 11011111b
CSIT238-Project Description

mov bl, al
jmp L3
L2: or al, 00100000b
mov bl, al
jmp L3
L3: call Crlf
mov eax, blue + (white * 16)
call SetTextColor
mov edx,OFFSET buffer
call WriteString
mov edx,OFFSET promptReverse
call WriteString
mov eax, 0
mov al, bl
call WriteChar
call Crlf
mov eax, white + (blue * 16)
call SetTextColor
ret
Process_E ENDP
END main

You might also like