9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] FP register usage in Plan9 assembler
@ 2016-02-01 16:47 Giacomo Tesio
  2016-02-01 22:38 ` Charles Forsyth
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Giacomo Tesio @ 2016-02-01 16:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

I'm studying the 9front's amd64 kernel, and I'm pretty new to assembler
programming, so sorry if my question is too dumb...

I cannot understand the FP pseudo register usage.
The cpuid function, for example, is implemented as

/*
 * The CPUID instruction is always supported on the amd64.
 */
TEXT cpuid(SB), $-4
    MOVL    RARG, AX            /* function in AX */
    CPUID

    MOVQ    info+8(FP), BP
    MOVL    AX, 0(BP)
    MOVL    BX, 4(BP)
    MOVL    CX, 8(BP)
    MOVL    DX, 12(BP)
    RET

What I miss is where "info" comes from. I cannot

Apparently the GAS equivalent is:

.align 4
.globl cpuid
cpuid:
    mov    %ebp,%eax
    cpuid
    mov    0x10(%rsp),%rbp
    mov    %eax,0x0(%rbp)
    mov    %ebx,0x4(%rbp)
    mov    %ecx,0x8(%rbp)
    mov    %edx,0xc(%rbp)
    retq

Thus apparently info+8(FP) becomes 0x10(%rsp)
Why? I know that FP is a pseudo register, but shouldn't it be different
from SP?

And why info's value is 8? Is it the pointer size?

Another example:

TEXT insb(SB), 1, $-4
    MOVL    RARG, DX            /* MOVL    port+0(FP), DX */
    MOVQ    address+8(FP), DI
    MOVL    count+16(FP), CX
    CLD
    REP;    INSB
    RET

should be equivalent to

.align 4
.globl insb
insb:
    mov    %ebp,%edx
    mov    0x10(%rsp),%rdi
    mov    0x18(%rsp),%ecx
    cld
    rep insb
    retq

Again I cannot find a definition of address and count, but both seem to be
be valued as 8, why?


Giacomo

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

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

end of thread, other threads:[~2016-02-04 20:34 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-01 16:47 [9fans] FP register usage in Plan9 assembler Giacomo Tesio
2016-02-01 22:38 ` Charles Forsyth
2016-02-01 22:44   ` Charles Forsyth
2016-02-01 22:48 ` cinap_lenrek
2016-02-01 23:34   ` Giacomo Tesio
2016-02-02  0:36     ` Charles Forsyth
2016-02-02  0:58       ` Giacomo Tesio
2016-02-02 12:39         ` Aram Hăvărneanu
2016-02-02 16:42 ` Steven Stallion
2016-02-02 17:16   ` lucio
2016-02-03 15:24   ` erik quanstrom
2016-02-03 15:51     ` Steven Stallion
2016-02-03 16:36       ` erik quanstrom
2016-02-04 10:08     ` Aram Hăvărneanu
2016-02-04 12:04       ` lucio
2016-02-04 15:58         ` Ryan Gonzalez
2016-02-04 16:09           ` lucio
2016-02-04 18:06             ` Ryan Gonzalez
2016-02-04 18:14               ` balaji
2016-02-04 18:28             ` Ryan Gonzalez
2016-02-04 19:31           ` Skip Tavakkolian
2016-02-04 12:24       ` Brantley Coile
2016-02-04 12:53         ` lucio
2016-02-04 14:57           ` erik quanstrom
2016-02-04 14:05         ` Aram Hăvărneanu
2016-02-04 14:10           ` Aram Hăvărneanu
2016-02-04 14:30             ` Aram Hăvărneanu
2016-02-04 15:07         ` Charles Forsyth
2016-02-04 15:16           ` erik quanstrom
2016-02-04 15:11         ` erik quanstrom
2016-02-04 15:22           ` erik quanstrom
2016-02-04 15:26             ` Charles Forsyth
2016-02-04 20:34               ` erik quanstrom

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).