flat assembler
Message board for the users of flat assembler.

Index > DOS > Is popping into variable is possible?

Author
Thread Post new topic Reply to topic
ght2142



Joined: 11 Oct 2012
Posts: 3
ght2142 23 Oct 2012, 13:36
I am new to assembly. I can't get this code running in fasm but i can use the same code using inline assembly. What am I doing wrong?

org 100h

a dd 1
b dd 2

push a
push b
pop a
pop b

Is using dd wrong cause i also used dw,db but all doesn't work. While in inline assembly i declared a and b using int datatype and used the code below and it worked.

_asm{
push a
push b
pop a
pop b}

And just as the title says, is popping into variable possible in fasm? I used registers for pushing and popping ang the code works fine.

(Thanks in advance to all).
Post 23 Oct 2012, 13:36
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1403
Location: Piraeus, Greece
Picnic 23 Oct 2012, 14:01
Hi ght2142,

Notice that in fasm

Code:
push a          ; pushes a variable address on stack.
push [a]        ; pushes a variable contents on stack.
pop [a]         ; pops value from stack in variable a.
    


Read more about in manual, section 2.1.1 Data movement instructions
Post 23 Oct 2012, 14:01
View user's profile Send private message Visit poster's website Reply with quote
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr 24 Oct 2012, 16:28
When you pop a register, the last item on the stack is popped. In your example above, after popping, a will have the original value of b, and b will have the original value of a. Is that what you wanted to do?
Post 24 Oct 2012, 16:28
View user's profile Send private message Send e-mail Reply with quote
ght2142



Joined: 11 Oct 2012
Posts: 3
ght2142 27 Oct 2012, 12:02
Ok, my problem is all solved. Thanks to PICNIC. U the man!
Post 27 Oct 2012, 12:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.