TITLE: Boolean Calculator:Part1 Menu (BooleanCalcMenu.asm) ;------------------------------------------------------------ ; Name: ; ; Filename: BooleanCalcMenu.asm ; ; Project #: 4 ; ; Completed: March 2, 2003 ; ; Description: My fourth assembly program. Will later function as ; a simple boolean calculator for 32-bit integers. The ; current output will only be the name of the operation ; about to be performed as selected by the user. ; From Assembly Language For Intel-Based Computers, ; 4th Ed. by Kip R. Irvine. Problem #7 on pg. 226. ; ; Reference: Assembly Language For Intel-Based Computers, ; 4th Ed. by Kip R. Irvine ; (ProcTble.asm Pages 208-210) ;------------------------------------------------------------ INCLUDE Irvine32.inc .data caseTable byte '1' ;lookup value dword Process_1 ;address of lookup value entrySize = ($ - caseTable ) byte '2' dword Process_2 byte '3' dword Process_3 byte '4' dword Process_4 byte '5' dword Process_5 numberOfEntries = 5 msgIntro byte "This is Your Name's fourth assembly program which will later",0dh,0ah byte "function as a simple boolean calculator for 32-bit integers. The",0dh,0ah byte "current output will only be the name of the operation about to be",0dh,0ah byte "performed as selected by the user.",0dh,0ah,0 msgSelMn byte "-------------------------------------",0dh,0ah byte " 32-Bit 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 byte "-------------------------------------",0dh,0ah byte "Please enter selection 1,2,3,4 or 5: ",0 msg1 byte "Calling Process 1 (x AND y)",0dh,0ah,0 msg2 byte "Calling Process 2 (x OR y)",0dh,0ah,0 msg3 byte "Calling Process 3 (NOT x)",0dh,0ah,0 msg4 byte "Calling Process 4 (x XOR y)",0dh,0ah,0 msg5 byte "Calling Process 5 (Exit Program)",0dh,0ah,0 .code main PROC ;///////Intro Message///////////////////////////////// mov edx,OFFSET msgIntro ;intro message into edx call WriteString ;display msgIntro call Crlf ;endl call WaitMsg ;pause message call Clrscr ;clear screen call Menu ;menu procedure ExitProg::exit ;global label to exit main ENDP ;------------------------------------------------ Menu PROC ; ; Receives: Nothing ; Returns: Nothing ;------------------------------------------------ mov edx,OFFSET msgSelMn ;ask user for input call WriteString ;display msgSelMn call ReadChar ;read one character mov ebx,OFFSET caseTable;point EBX to the table mov ecx,numberOfEntries ;loop counter L1: cmp al,[ebx] ;match found? jne L2 ;no: continue call NEAR PTR [ebx + 1] ;yes: call the procedure call WriteString ;display message call Crlf ;endl call WaitMsg ;pause message call Clrscr ;clear screen jmp L3 ;exit the search L2: add ebx,5 ;point to the next entry loop L1 ;repeat until ECX = 0 L3: jmp Menu ;run Menu again Menu EndP ;------------------------------------------------ Process_1 PROC ; ; Receives: Nothing ; Returns: EDX = offset of message ;------------------------------------------------ mov edx,OFFSET msg1 ;msg1 into edx call Crlf ;endl call Crlf ;endl ret ;return Process_1 ENDP ;------------------------------------------------ Process_2 PROC ; ; Receives: Nothing ; Returns: EDX = offset of message ;------------------------------------------------ mov edx,OFFSET msg2 ;msg2 into edx call Crlf ;endl call Crlf ;endl ret ;return Process_2 ENDP ;------------------------------------------------ Process_3 PROC ; ; Receives: Nothing ; Returns: EDX = offset of message ;------------------------------------------------ mov edx,OFFSET msg3 ;msg3 into edx call Crlf ;endl call Crlf ;endl ret ;return Process_3 ENDP ;------------------------------------------------ Process_4 PROC ; ; Receives: Nothing ; Returns: EDX = offset of message ;------------------------------------------------ mov edx,OFFSET msg4 ;msg4 into edx call Crlf ;endl call Crlf ;endl ret ;return Process_4 ENDP ;------------------------------------------------ Process_5 PROC ; ; Receives: Nothing ; Returns: EDX = offset of message ; Sets CF = 1 to signal end of program ;------------------------------------------------ mov edx,OFFSET msg5 ;msg5 into edx call Crlf ;endl call Crlf ;endl call WriteString ;display message call Crlf ;endl stc ;CF = 1 jc ExitProg ;if CF=1 then jump to Global ExitProg Process_5 ENDP END main