•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 427,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,603 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 2848 | Replies: 5
![]() |
The behavior is equivalent to:
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:
But that makes use of two extra registers. Better to simply use push, no?
sub sp,2 mov [sp],[si]
sub sp,2 mov bp,sp mov ax,[si] mov [bp],ax
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
•
•
Join Date: Mar 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 0
YA PUSH IS EASY , BUT THIS IS A QUESTION IN MY TEST
I WAS SOLVE IT IN ANOTHER WAY :
is it true ?? :o
I WAS SOLVE IT IN ANOTHER WAY :
push [SI] MOV BX,[SI] MOV DI,SP DEC DI MOV [DI],BH DEC DI MOV [DI],BL MOV SP,DI
is it true ?? :o
•
•
Join Date: Mar 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 0
is it false when i use DI instead of Bpsub sp,2 mov di,sp mov ax,[si] mov [di],ax
i wait 4 ur reply >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:
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:
push [SI] MOV BX,[SI] MOV DI,SP DEC DI MOV [DI],BX MOV SP,DI
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- addcc instruction (Assembly)
- push ndps printer driver settings? (Novell)
- I just need a push! (C)
- "Error Message - tried to execute invalid instruction" (C++)
- Using x86 Assembly Language with Microsoft Visual C++ (C++)
Other Threads in the Assembly Forum
- Previous Thread: does anybody know any asm site for g4 (macintosh) assembly ?
- Next Thread: ASM Problem[Please help me]



Linear Mode