Push Instruction

Reply

Join Date: Mar 2006
Posts: 10
Reputation: -EMAN- is an unknown quantity at this point 
Solved Threads: 0
-EMAN- -EMAN- is offline Offline
Newbie Poster

Push Instruction

 
0
  #1
Mar 30th, 2006
What is the set of Instructions that equivallent to

Push [si]?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,567
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 707
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Push Instruction

 
0
  #2
Mar 30th, 2006
The behavior is equivalent to:
  1. sub sp,2
  2. mov [sp],[si]
But that's not valid code because sp can't be used for addressing and memory to memory moves are illegal. To get the same effect legally, you could do this:
  1. sub sp,2
  2. mov bp,sp
  3. mov ax,[si]
  4. mov [bp],ax
But that makes use of two extra registers. Better to simply use push, no?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 10
Reputation: -EMAN- is an unknown quantity at this point 
Solved Threads: 0
-EMAN- -EMAN- is offline Offline
Newbie Poster

Re: Push Instruction

 
0
  #3
Mar 30th, 2006
YA PUSH IS EASY , BUT THIS IS A QUESTION IN MY TEST

I WAS SOLVE IT IN ANOTHER WAY :


  1. push [SI]
  2.  
  3. MOV BX,[SI]
  4. MOV DI,SP
  5. DEC DI
  6. MOV [DI],BH
  7. DEC DI
  8. MOV [DI],BL
  9. MOV SP,DI

is it true ?? :o
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 10
Reputation: -EMAN- is an unknown quantity at this point 
Solved Threads: 0
-EMAN- -EMAN- is offline Offline
Newbie Poster

Re: Push Instruction

 
0
  #4
Apr 1st, 2006
is it false when i use DI instead of Bp


  1. sub sp,2
  2. mov di,sp
  3. mov ax,[si]
  4. mov [di],ax

i wait 4 ur reply
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,567
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 707
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Push Instruction

 
0
  #5
Apr 1st, 2006
>is it false when i use DI instead of Bp
No, di can be used for addressing just as easily as bp. However, it benefits clarity to use the registers that are traditionally expected, and bp is expected as a reference to the stack pointer even if it isn't required. Thats like using bx as a loop counter instead of cx. Readers will pause to wonder why you chose to do something different.

>is it true ??
No. If you're using bx then I'll wager you're working in 16-bit mode rather than 8-bit mode. In that case, the stack is set at 16 bits, no matter what you try to push onto it. So when you decrement di, you're moving it by 16 bits instead of 8, which will give you *two* pushes. Even worse, the first value you push has an indeterminate low byte and the second value has an indeterminate high byte. This would be better:
  1. push [SI]
  2.  
  3. MOV BX,[SI]
  4. MOV DI,SP
  5. DEC DI
  6. MOV [DI],BX
  7. MOV SP,DI
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 10
Reputation: -EMAN- is an unknown quantity at this point 
Solved Threads: 0
-EMAN- -EMAN- is offline Offline
Newbie Poster
 
0
  #6
Apr 1st, 2006
:o thnkx
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC