Need your guys's opinion on how to get this program woikin'

IA-32 Assembly
Code:
```TITLE Chinchilla Madness

;this program will calculate population growth of
;the wild chinchilla over a 14 year span

INCLUDE Irvine32.inc

counter = 12    ;this will start counter on the 3rd element of the array

.data

prompt1 BYTE  "Enter semi-annual rate of chinchilla offspring",0
prompt2 BYTE  "Total number of chinchillas at a rate of ",0
prompt3 BYTE  " chinchillas semi-annually is: ",0
array   DWORD 112 DUP(?)  ;14 years..  semi-annually = 28, multiplied by 4 (for 32bit array) = 112

.code
main PROC

call Clrscr
mov esi, OFFSET array
mov ecx, 27
call RatePrompt
call ChinchillaCalculate
call DisplayTotal
exit

main ENDP

RatePrompt PROC

mov edx, OFFSET prompt1
call WriteString

ret

RatePrompt ENDP

ChinchillaCalculate PROC

mov [esi],   2  ;first and second elements will always
mov [esi+4], 2  ;be set to '2' (representing the parents)

L1:

;This algorithm represents, "go back two elements from the
;current element, and divide it's contents by '2'..  then
;multiply the resultant by the user entered rate (in eax) then
;add to the contents in [current element - 1]...   and put
;the final result in [current element]

subcounter = counter

sub subcounter, 4  ;address of [current element - 1]
mov eax, subcounter
sub subcounter, 4  ;address of [current element - 2]
mov ebx, subcounter

mov edx, esi
sub edx,bx
div edx, 2
mul edx, eax

loop L1

ret

ChinchillaCalculate ENDP

DisplayTotal PROC

mov edx, OFFSET prompt2
call WriteString
call WriteInt
mov edx, OFFSET prompt3
call WriteString
move eax, [esi+112]
call WriteInt

ret

DisplayTotal ENDP

END main```

Here are the specific error messages... brought to you by the MASM615 assembler:

Microsoft (R) Macro Assembler Version 6.15.8803

Assembling: chinchilla.asm
chinchilla.asm(50) : error A2070: invalid instruction operands
chinchilla.asm(51) : error A2070: invalid instruction operands
chinchilla.asm(57) : error A2001: immediate operand not allowed
chinchilla.asm(59) : error A2001: immediate operand not allowed
chinchilla.asm(64) : error A2008: syntax error : ,
chinchilla.asm(65) : error A2008: syntax error : ,
chinchilla.asm(70) : error A2001: immediate operand not allowed
chinchilla.asm(85) : error A2008: syntax error : in instruction
chinchilla.asm(88) : error A2008: syntax error : eax
chinchilla.asm(63) : error A2022: instruction operands must be the same size
chinchilla.asm(66) : error A2032: invalid use of register
Press any key to continue . . .

I haven't coded that much in assembly.. i think the code looks good... just need some help on convincing the compiler it's good

Help the assembly noob.

2. >>INCLUDE Irvine32.inc

It would be easier if you could provide a more simple example not relying on headers which most people wont have

3. Well.. after days of troubleshooting.. I got me' program to work!!!

My main problems were:

the edx register needs to be cleared when using the 'div' operator.. because division uses both the edx:eax registers as the dividend. setting edx to zero will eliminate garbage data from any previous operations using this register.

also, I used a different approach to array indexing.. instead of continually manipulating the array offset in the esi register, I used a style of array indexing.. that resembles more of what you would see in a high-level language:
Code:
`array[ebx]`
where the ebx is a dedicated array counter. This style is better, because one does not have to increment an array pointer by units of 4 (in a 32-bit array).. there is now a 1:1 relationship between the array counter and the array address.. (just like with a high level language )

Anywhoo.. Here is the finished product Let me know what you think!! Feedback = good

i'll also be putting this up on flashdaddy.com (thanks axon)

Code:
```TITLE Chinchilla Madness

;this program will calculate population growth of
;the wild chinchilla over a 14 year span

INCLUDE Irvine32.inc

.data

prompt1 BYTE  "Enter semi-annual rate of chinchilla offspring: ",0
prompt2 BYTE  "Total number of chinchillas at a rate of ",0
prompt3 BYTE  " chinchillas semi-annually is: ",0
array   DWORD 28 DUP(?)  ;14 years..  semi-annually = 28
loopcount	DWORD ?
rate		DWORD ?

.code
main PROC

mov esi, 0
call Clrscr
mov esi, OFFSET array
mov ecx, 26
call RatePrompt
call ChinchillaCalculate
call DisplayTotal
exit

main ENDP

RatePrompt PROC

mov edx,0
mov edx, OFFSET prompt1
call WriteString
mov rate, eax

ret

RatePrompt ENDP

ChinchillaCalculate PROC

mov array[0], 2 ;first and second elements will always
mov array[1], 2 ;be set to '2' (representing the parents)
mov ebx, 2	;ebx will be my dedicated array counter (starting on 3rd element)

L1:

;This algorithm represents, "go back two elements from the
;current element, and divide it's contents by '2'..  then
;multiply the quotient by the user entered rate.. then
;add to the contents in [current element - 1]...   and put
;the final result in [current element]

mov loopcount, ecx		;free up ecx for use in calculations

mov eax, array[ebx-2]	 	;"two elements back from current element" mov to eax in preperation for divide
mov ecx, 2			;use ecx as register operand for 'mul' and 'div'
mov edx, 0			;clear edx to perform low-end division
div ecx				;divide eax/2 and store quotient into eax
mov edx, 0			;throw away any remainder
mov ecx, rate			;move rate to ecx as a register operand for use with 'mul'
mul ecx				;multiply answer (in eax) by rate and store in edx:eax
mov array[ebx], eax		;store final result into current element
mov ecx, loopcount		;restore ecx as a loop counter
inc ebx				;increment the array to next element

loop L1
ret

ChinchillaCalculate ENDP

DisplayTotal PROC

mov edx, OFFSET prompt2
call WriteString
mov eax, rate
call WriteInt
mov edx, OFFSET prompt3
call WriteString
mov eax, array[ebx]
call WriteInt

ret

DisplayTotal ENDP

END main```

For all of you who ever wanted to know the number of chinchillas you would have after 14 years.