I'm working under visual studio 2005 with assembly (I'm a newbie) and I want to create a program that calculate arithmetic progression with that rule: An = 2*An-1 + An-2 but. I really don't know how to work with registers and I need just one example from you to continue with my exercises.
This is my code:
.386
.MODEL flat,stdcall
.STACK 4096
extern ExitProcess@4:Near
.data
arraysize DWORD 10
setarray DWORD 0 DUP(arraysize)
firstvar DWORD 1
secondvar DWORD 2
.code
_main:
mov eax,[firstvar]
mov [setarray+0],eax
mov eax,[secondvar]
mov [setarray+4],eax
mov ecx, arraysize ;loop definition
mov ax, 8
Lp:
mov eax,[setarray+ax-4]
add eax,[setarray+ax-4]
add eax,[setarray+ax-8]
mov [setarray+ax],eax
add ax,4;
loop Lp
add ax,4;
push 0 ;Black box. Always terminate
call ExitProcess@4 ;program with this sequence
end _main ;End of program. Label is the entry point.