xboxmods
xboxmods

Reputation: 53

How can I clear a variable in assembler?

I'm using a BYTE variable in assembler to hold partial statements before they're copied to a permanent location. I'm trying to figure out how I could clear that after each new entry. I tried moving an empty variable into it, but that only replaced the first character space of the variable. Any help would be much appreciated, thanks!

Upvotes: 0

Views: 13107

Answers (2)

Desu_Never_Lies
Desu_Never_Lies

Reputation: 690

For a variable (assuming your var is stored in the memory):

mov var1, 0

For an array (as far as I got, that's what you are talking about?):

xor al, al
lea edi, var1
mov ecx, <var1_array_size>
cld
rep stosb

Upvotes: 1

Trevor Arjeski
Trevor Arjeski

Reputation: 2168

Use XOR instead of MOV. It's faster.

XOR r1, r1

Upvotes: 3

Related Questions