Hello, this is a 2 part question for my beginning assembly class. Thank you in a
ID: 653902 • Letter: H
Question
Hello, this is a 2 part question for my beginning assembly class. Thank you in advance for your help
Boolean Calculator (1)
Create a program that functions as a simple boolean calculator for 32-bit integers. It should display a menu that asks the user to make a selection from the following list:
1. x AND y
2. x OR y
3. NOT x
4. x XOR y
5. Exit Program
When the user makes a choice, call a procedure that displays the name of the operation about to be performed.
Boolean Calculator (2)
Continue the solution program from the preceeding exercise by implementing the following procedures:
- AND_op: Prompt the user for two hexadecimal integers. AND them together and display the result in hexadecimal.
-OR_op: Prompt the user for two hexadecimal integers. OR them together and display the result in hexadecimal.
- NOT_op: Prompt the user for two hexadecimal integers. NOT the integer and display the result in hexadecimal.
- XOR_op: Prompt the user for two hexadecimal integers. Exclusive-OR them together and display the result in hexadecimal.
The following is what our professor has given us help with:
Include Irvine32.inc
.data
msgMenu "---- Boolean Calculator ------------", 0dh, 0ah
BYTE 0dh, 0ah
BYTE "1. x AND y" , 0dh, 0ah
BYTE "2. x OR y" , 0dh, 0ah
BYTE "3. NOT x" , 0dh, 0ah
BYTE "4. x XOR y" , 0dh, 0ah
BYTE "5. Exit program" , 0dh, 0ah, 0dh, 0ah
BYTE "Enter integer>" , 0
msgAND BYTE "Boolean AND", 0
msgOR BYTE "Boolean OR", 0
msgNOT BYTE "Boolean NOT", 0
msgXOR BYTE "Boolean XOR", 0
msgOperand1 BYTE "Input the first 32--bit hexadecimal operand: ", 0
msgOperand2 BYTE "Input the second 32--bit hexadecimal operand: ", 0
msgResult BYTE "The 32-bit hexadecimal result is: ", 0
Thank you so much for the help again.
Explanation / Answer
INCLUDE Irvine32.inc
.data
msgMenu BYTE "---- Boolean Calculator ----", 0dh,0ah
BYTE 0dh,0ah
BYTE "1. x AND y" ,0dh,0ah
BYTE "2. x OR y" ,0dh,0ah
BYTE "3. NOT x" ,0dh,0ah
BYTE "4. x XOR y" ,0dh,0ah
BYTE "5. Exit program",0
msgAND BYTE "Boolean AND",0
msgOR BYTE "Boolean OR",0
msgNOT BYTE "Boolean NOT",0
msgXOR BYTE "Boolean XOR",0
msgOperand1 BYTE "Input the first 32-bit hexadecimal operand: ",0
msgOperand2 BYTE "Input the second 32-bit hexadecimal operand: ",0
msgResult BYTE "The 32-bit hexadecimal result is: ",0
caseTable BYTE '1' # lookup value
DWORD _AND_op # address of the procedure
EntrySize = ($ - caseTable )
BYTE '2'
DWORD _OR_op
BYTE '3'
DWORD _NOT_op
BYTE '4'
DWORD _XOR_op
BYTE '5'
DWORD _ExitProgram
NumberOfEntries=($ - caseTable)/EntrySize
.code
main08stub PROC
call Clrscr
Menu:
mov edx, OFFSET msgMenu # menu choices
call WriteString
call Crlf
L1: call ReadChar
cmp al, '5' # is selection valid (1-5)?
ja L1 # if above 5, go back
cmp al, '1'
jb L1 # if below 1, go back
call Crlf
call **BLANK**
jc quit # if CF = 1 exit
call Crlf
jmp Menu # display menu again
quit: exit
main08stub ENDP
#----------------------------------------
**BLANK** PROC
#
# It selects a procedure from the case table
# Receives: AL = number of procedure
# Returns: nothing
#-----------------------------------
ret
**BLANK** ENDP
#------------------------------------------------
_AND_op PROC
#
# Performs a boolean AND operation
# Receives: Nothing
# Returns: Nothing
#------------------------------------------------
ret
_AND_op ENDP
#------------------------------------------------
_OR_op PROC
#
# Performs a boolean OR operation
# Receives: Nothing
# Returns: Nothing
#------------------------------------------------
ret
_OR_op ENDP
#------------------------------------------------
_NOT_op PROC
#
# Performs a boolean NOT operation.
# Receives: Nothing
# Returns: Nothing
#------------------------------------------------
ret
_NOT_op ENDP
#------------------------------------------------
_XOR_op PROC
#
#
# Performs an Exclusive-OR operation
# Receives: Nothing
# Returns: Nothing
#------------------------------------------------
ret
_XOR_op ENDP
#------------------------------------------------
_ExitProgram PROC
#
# Receives: Nothing
# Returns: Sets CF = 1 to signal end of program
#------------------------------------------------
ret
_ExitProgram ENDP
END main08stub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.