;=======================================================
; File:    Add1.asm
; Purpose: Add 1 to a number read in from the keyboard
;=======================================================

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  bx, num1            ; retrieve num1 from memory
        inc  bx                  ; increment it
        mov  num2, bx            ; 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)

DEFINE_PRINT_STRING
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
