0

My homework says:

Write an assembly language program that, when given an integer n, will calculate the value of the expression (2n^2-1)2 + n^3. Your program is to get the value for n from ECX and is to leave the value of the expression in EAX. (Note: The name of the integer multiplication instruction is imul.)

This is what I have:

```
;;
;; Register usage:
;; EAX Sum
;; ECX Original value of n
;; K Placeholder for n
;; D Placeholder for n
[SECTION .text]
global main
main:
push EBP
mov EBP, ESP
push EBX
push ESI
push EDI
first:
add ECX, 0
add EAX, 0
var K, D: integer;
top:
K := 0;
D :=0;
mov K, ECX
imul K, K
imul K, 2
sub K, 1
imul K, K
mov D, ECX
imul ECX, ECX
imul ECX, D
add ECX, K
mov EAX, ECX
last:
pop EDI
pop ESI
pop EBX
mov ESP, EBP
pop EBP
ret
```

I dont think Im assigning variables correctly and I have no clue how to...I believe I have the right arithmetic but cant get past declaring variables.

```
hw1_1.asm:26: error: parser: instruction expected
hw1_1.asm:28: error: parser: instruction expected
hw1_1.asm:29: error: parser: instruction expected
```

Please help, I am so lost in assembly, Im used to java

*Edited 5 Years Ago by rcossy1023*: n/a