Hello, i want to make a simple app that loads the value '1000' into the memory, and then i want to decrease that value until its 998.
The thing is that i dont want to use a loop, but i need to use something like shl.
Here is an example of how i thought it's gonna be (sort of).


mov eax, 1000
shl eax, 999
shl eax, 998


So im trying to point to load the a new value in the next memory location, but im not sure if shl points to the next memory location...
I also would like to know how i could print the value of eax to the DOS screen so i can see where i go wrong.
Posted on 2006-09-20 06:42:22 by w00
Try this:

mov eax, 1000
dec eax ; Decrement the value in eax by 1
dec eax ; Decrement the value in eax by 1

eax will now contain 998.  Uses no loops :)

shl simply shifts all the bits to the left so, in binary it would look like this:

mov eax, 1000 ; 001111101000 - 1000 decimal
shl eax, 1 ; 011111010000 - 2000 decimal
shl eax, 1 ; 111110100000 - 4000 decimal

which doesn't do you decrementing like you had hoped.
Posted on 2006-09-20 08:04:07 by Timbo
Let's be more specific - what does SHL actually do?
It multiplies a number by a power of 2..

If you SHL by 1, its the same as multilpy by 2.
If you SHL by 2, its the same as multiply by 4.

Hope that was educational, now back to my glass of wine :)
Posted on 2006-09-20 08:46:40 by Homer
Ok thanks, that cleared things up about the shl opperator.

But i have a problem with assembling the code. I've got this right now:

.model small


main proc

mov eax, 1000
dec eax
dec eax
dec eax

main endp
end main

If i try to assemble this, then i get this error message

test.asm(4) : error A2085: instruction or register not accepted in current CPU

Im on Windows XP incase you're wondering. Any idea what could've gone wrong??
Posted on 2006-09-20 09:58:36 by w00
If you want to see what goes on in the registers and things when you use various instructions then there is the Ketman Interpreter which has a free version.

Its only for 16bit real mode, but at least you can see what happens as you fiddle with things.

Not needing to compile experimental snippets can save you a lot of time too.
Posted on 2006-09-20 11:32:12 by eek