how can i increment a variable??

var1 = 5 ?? ive been sitting here all day programming and i feel like my brain is on overload
Posted on 2003-04-06 21:47:56 by ducativiper
inc eax; eax++
mov eax,5;eax=5
Posted on 2003-04-06 21:48:59 by roticv
i am programming in 80x86 assembly and i have used all of my registers...
and i know have a local array that i have created... i need to have an index to increment
so how can i increment var1 from 0 to 1 to 2 ect.
Posted on 2003-04-06 21:50:35 by ducativiper
add var,1

Well, you can use up to 7 registers including esp or ebp. I see no point in using a var to store increment.
Posted on 2003-04-06 21:59:12 by roticv
You can also do:


to increment a variable. How come you have run out of registers? Can you redesign so that a value that is not used often is stored in a LOCAL? It is normal practice to use esi or edi as the base pointer (i.e. to point to the base of your array), and then use ecx or edx as the indexer. Maybe another thing you could look at doing is to push either edx or ecx before using it as an index, and then restore it from the stack when you have finished.
Posted on 2003-04-07 02:59:12 by sluggy
%include "\lab\vasm\inc\"

section data

struc vars
.one resd 1
.two resd 1

var1 resb vars_size

section code

mov dword,"sim"
mov dword,"nao"

cmp dword,"sim"
jne .out
call MessageBoxA , 0,"info=sim !","title1",MB_OK
jmp .exit
call MessageBoxA , 0,"info nao !","title1",MB_OK
call ExitProcess , 0
Posted on 2003-04-07 18:44:00 by Nguga