TITLE MASM Template						(main.asm)

; Description:
;   This program will initialize an array with values and do some simple math stuff to each element.
; Author:
; Revision date:

INCLUDE Irvine32.inc
.data
introMsg  BYTE  "Bob Markham - Week 3",0dh,0ah,"CSPG 360 - Panos Mastrogiannis",0dh,0ah,0
incMsg    BYTE  "INC - ADD 5 - DEC - SUB 10 (Shows Regs) - Original Number", 0dh, 0ah, 0
newLine   BYTE  0dh, 0ah, 0
twoLine   BYTE  2 DUP (0dh, 0ah), 0

; Problem 1: Create an array of 5 numbers with the values of 1, 5, 10, 15, 20
zArray    BYTE 1, 5, 10, 15, 20

DATAsize EQU   1

.code
main PROC
	call Clrscr

	mov	 edx,OFFSET introMsg
	call WriteString
  mov  edx,OFFSET newLine
	call WriteString

; Problem 2: Use LENGTHOF, Loop through the array and in each loop do the following:
  mov  ecx, LENGTHOF zArray    ; for (ecx=5; ecx>0; ecx--)
  mov  esi, 0                  ; 

doStuff:
; Problem 3: Save the original value of the loop for output at the end
    movzx ebx,  zArray[esi]
    
; Problem 4: Use INC
    inc [zArray + esi]
    
; Introduction Message
    mov  edx,OFFSET incMsg
    call WriteString

; Problem 5: Output the value
    movzx eax,zArray[esi]
    call  WriteInt

; Problem 6: Add 5 to the number
    add zArray[esi], 5

; Problem 7: Output the value
    mov  al,zArray[esi]
    call WriteInt

; Problem 8: Use DEC
    dec zArray[esi]

; Problem 9: Output the value
    mov  al,zArray[esi]
    call WriteInt

; Problem 10: Subtract 10 from the number
    sub zArray[esi], 10

; Problem 11: Check carry, sign, and overflow flags and output the results
    mov  al,zArray[esi]
    call DumpRegs
    call WriteInt

; Problem 12: For each element in the array, output the original value 
;             before any modifications were performed on it
    mov  al,bl
    call WriteInt

; Problem 13: call WaitMsg
    mov edx, OFFSET twoLine
    call WriteString
    call WaitMsg
    call WriteString

; Problem 14: End of loop
    add esi, DATAsize    ; Set up for the next loop
  loop doStuff

	call DumpRegs
	call WaitMsg
    
  exit
main ENDP

END main