9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] assembly syntax in plan 9
@ 2012-01-16 12:30 Alexander Kapshuk
  2012-01-16 13:08 ` Charles Forsyth
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Kapshuk @ 2012-01-16 12:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

i have a question about putting things on the stack for x86 arch under plan
9...

under unix/linux, when defining a function, i would:
(1). push the address the base pointer is pointing to prior to this
function being called, onto the stack; e.g. pushl %ebp
(2). then i would have the base pointer point to the current stack pointer;
e.g. movl %esp, %ebp
(3). then i would allocate space on the stack for local variables, if any;
e.g. subl $n, %esp;
(4). then follows the function body;
to return from the function i would:
(1). restore the stack pointer; e.g. movl %ebp, %esp;
(2). restore the base pointer, e.g. popl %ebp;
(3). then return to the calling function;

i searched the 9fans archives for posts on assembly programming under plan
9; found some bits and pieces; e.g. in one of the posts it was mentioned
that BP is a general purpose register, not the base pointer; and that FP is
what ebp is under unix/linux;

in the paper for the plan 9 assembler, it says that there are three
registers available to manipulate the stack, FP, SP, and TOS; would the
following comparison stand true then?
plan9    unix/linux
-------     -------------
FP        EBP
SP        -4(%EBP)...-n(%EBP) /* local variables */
TOS     ESP

thanks;

sasha kapshuk

[-- Attachment #2: Type: text/html, Size: 1527 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-01-18 18:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16 12:30 [9fans] assembly syntax in plan 9 Alexander Kapshuk
2012-01-16 13:08 ` Charles Forsyth
2012-01-16 13:27   ` Alexander Kapshuk
2012-01-16 15:41   ` Bakul Shah
2012-01-16 18:51     ` Comeau At9Fans
2012-01-16 19:03       ` Bakul Shah
2012-01-16 19:39         ` Charles Forsyth
2012-01-17 19:27           ` Comeau At9Fans
     [not found]         ` <CAOw7k5iYxoVUHYYxf1Dg9ESWwTon_aGFxhNkuyUGbkXwiKO9DA@mail.gmail.c>
2012-01-16 19:49           ` erik quanstrom
2012-01-17 19:29             ` Comeau At9Fans
2012-01-16 20:11         ` Joel C. Salomon
2012-01-16 23:18           ` Bakul Shah
2012-01-17 19:31           ` Comeau At9Fans
2012-01-17 19:21         ` Comeau At9Fans
2012-01-18 17:48           ` Bakul Shah
2012-01-18 18:32             ` Comeau At9Fans
2012-01-16 16:07   ` Joel C. Salomon
2012-01-16 16:27     ` erik quanstrom
2012-01-16 16:40     ` Charles Forsyth
2012-01-16 16:54     ` Bakul Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).