Professional Documents
Culture Documents
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
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.
**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)
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
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