; Title: CISS 360 Program Demo 2
;------------------------------------------------------------
; Description: This program prompts for and obtains two
; integer values and then computes and displays
; the sum of the two input values.
;------------------------------------------------------------
; Programmer: Ron Hart
;------------------------------------------------------------
; Date/Time: Thursday, January 13, 2011 4:07 PM
;------------------------------------------------------------
.586
.MODEL FLAT
INCLUDE console_io.h ; header file for console input/output
.STACK 4096 ; reserve 4096-byte (1024 DWORD) stack
;------------------------------------------------------------
; Input/Output Facility
;------------------------------------------------------------
;
; Macro Operand
;
; put_ch DWORD/Reg (Displays character in parameter)
;
; get_ch None (Loads character from keyboard into EAX)
;
; put_str BYTE (Displays string beginning at given address)
;
; put_i DWORD/Reg (Displays integer value in parameter)
;
; put_fp REAL4/Reg (Displays float value in parameter)
;
; get_i DWORD (Loads integer entered at keyboard into parameter)
;
; get_fp REAL4 (Loads float entered at keyboard into parameter)
;
; get_str BYTE (Loads string entered at keyboard into parameter)
;
;------------------------------------------------------------
.DATA ;****************************************************
;* Data Section *
;****************************************************
prompt1 BYTE "Enter 1st integer: ",0
prompt2 BYTE "Enter 2nd integer: ",0
result_str BYTE "Sum = ",0
value1 DWORD ?
value2 DWORD ?
newline DWORD 10
.CODE ;****************************************************
;* Code Section *
;****************************************************
_MainProc PROC ; start of main program
put_str prompt1 ; prompt for first integer value
get_i value1 ; get first integer value
put_ch newline ; output newline
put_ch newline ; output another newline
put_str prompt2 ; prompt for second integer value
get_i value2 ; get second integer value
put_ch newline ; output newline
put_ch newline ; output another newline
mov eax, value1 ; load EAX with first integer value
add eax, value2 ; add second integer value to EAX
put_str result_str ; display "result" string
put_i eax ; display sum of two integer values
done ; macro to display "done" message and get any key
xor eax, eax ; exit with return code 0
ret ; return
_MainProc ENDP ; end of main program
;------------------------------------------------------------
proc_name PROC ; sample procedure
push ebp ; save base pointer
mov ebp, esp ; establish stack frame
;; push registers used by this proc
;; proc code inserted here
;; pop registers used by this proc
pop ebp ; restore base pointer
ret
proc_name ENDP
;----------------------------------------------------------------------
stat_flags MACRO
fstsw ax ; FPU status word to AX
sahf ; condition code bits to flags
ENDM
;----------------------------------------------------------------------
END ; end of source code
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.