;=======================================================
; File:    Add2.asm
; Purpose: Add 2 to a number read in from the keyboard
;          Uses a procedure for the addition
;=======================================================

include 'emu8086.inc'

        org  100h           ; set location counter to 100h
        jmp  CodeStart

DataStart:

prompt  db   "Enter a number> ", 0
numIs   db   "The number is ", 0
newline db   13, 10, 0
num1    dw   ?
num2    dw   ?

CodeStart:

        mov  si, offset prompt   ; prompt user to enter in a number
        call print_string
        call scan_num            ; read in the number into cx
        mov  num1, cx            ; copy the number to a variable

        mov  si, offset newline  ; advance cursor to the next line
        call print_string

        mov  si, offset numIs    ; display the number
        call print_string
        mov  ax, num1
        call print_num

        mov  si, offset newline  ; advance cursor to the next line
        call print_string

        mov  ax, num1            ; retrieve num1 from memory
        call Add2                ; call Add2 to add 2 to the number
        mov  num2, ax            ; store updated number in num2

        mov  si, offset numIs    ; display the updated number
        call print_string
        mov  ax, num2
        call print_num

        mov  si, offset newline  ; advance cursor to the next line
        call print_string

        ret                      ; return to caller (terminate program)


Add2    proc                     ; the add two procedure begins here
        add  ax, 2               ; ax contains the input value; add 2
        ret                      ; return to caller
Add2    endp

DEFINE_PRINT_STRING
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
