flat assembler
Message board for the users of flat assembler.

Index > DOS > PUSH -> "clear" code doesn't work

Author
Thread Post new topic Reply to topic
dieboy



Joined: 30 Dec 2004
Posts: 41
Location: Poland, Elblag
dieboy 18 May 2005, 18:37
Hello!
Code:
push ax
;is like :
sub sp, 2
mov ss:[sp], ax
;but in TASM    

and how to write this code in FASM? if I write ... [ss:sp] i have an error. Can you tell me ?

_________________
...
Post 18 May 2005, 18:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 7997
Location: 22° 15' N | 114° 10' E
YONG 18 May 2005, 19:45
Try this:
Code:
                sub     sp, 2
                mov     bp, sp
                mov     [bp], ax
    


Your error was not related to ss. It was about [sp] which is illegal.

Listed below are the legal 16-bit Memory Addressing Modes:
- Displacement
- bx or bp
- si or di
- Any combinations of the above three

YONG
Post 18 May 2005, 19:45
View user's profile Send private message Visit poster's website Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 18 May 2005, 19:53
In 16-bit code there is no SP-relative addressing (only BP,BX,SI,DI can be used). But you can probably write
Code:
sub sp, 2
mov [esp], ax     
Post 18 May 2005, 19:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 7997
Location: 22° 15' N | 114° 10' E
YONG 18 May 2005, 20:21
One more point.

Even though the [bp] addressing mode uses ss by default,
you may code [ss:bp] to make it clear and unambiguous.

YONG
Post 18 May 2005, 20:21
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 18 May 2005, 20:59
mike.dld wrote:
In 16-bit code there is no SP-relative addressing (only BP,BX,SI,DI can be used). But you can probably write
Code:
sub sp, 2
mov [esp], ax     

You can never be sure that high word of ESP is zero, so MOVZX ESP,SP should be used before such code.

_________________
x86asm.net
Post 18 May 2005, 20:59
View user's profile Send private message Visit poster's website Reply with quote
dieboy



Joined: 30 Dec 2004
Posts: 41
Location: Poland, Elblag
dieboy 19 May 2005, 06:15
Ok. Thank you very much! Smile

_________________
...
Post 19 May 2005, 06:15
View user's profile Send private message Visit poster's website ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.