From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 Date: Mon, 1 Feb 2016 17:47:46 +0100 Message-ID: From: Giacomo Tesio To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1148d7caf7d2a0052ab8242f Subject: [9fans] FP register usage in Plan9 assembler Topicbox-Message-UUID: 80edfb7c-ead9-11e9-9d60-3106f5b1d025 --001a1148d7caf7d2a0052ab8242f Content-Type: text/plain; charset=UTF-8 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 --001a1148d7caf7d2a0052ab8242f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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

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

=C2=A0=C2=A0=C2=A0 MOVQ=C2=A0=C2=A0=C2=A0 i= nfo+8(FP), BP
=C2=A0=C2=A0=C2=A0 MOVL=C2=A0=C2=A0=C2=A0 AX, 0(BP)
=C2= =A0=C2=A0=C2=A0 MOVL=C2=A0=C2=A0=C2=A0 BX, 4(BP)
=C2=A0=C2=A0=C2=A0 MOVL= =C2=A0=C2=A0=C2=A0 CX, 8(BP)
=C2=A0=C2=A0=C2=A0 MOVL=C2=A0=C2=A0=C2=A0 D= X, 12(BP)
=C2=A0=C2=A0=C2=A0 RET

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

Apparently = the GAS equivalent is:

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


=
Thus apparently info+8(FP) b= ecomes 0x10(%rsp)=C2= =A0
Why? I know that FP is a pseudo register, but shouldn't it be d= ifferent from SP?

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

<= div>Another example:

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

should be equivalent to
<= div>
= .align 4
.globl insb
insb:
=C2=A0=C2=A0=C2=A0 mov=C2=A0=C2=A0=C2= =A0 %ebp,%edx
=C2=A0=C2=A0=C2=A0 mov=C2=A0=C2=A0=C2=A0 0x10(%rsp),%rdi=C2=A0=C2=A0=C2=A0 mov=C2=A0=C2=A0=C2=A0 0x18(%rsp),%ecx
=C2=A0=C2=A0= =C2=A0 cld=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 rep insb
=C2=A0=C2= =A0=C2=A0 retq


Again I cannot find a definit= ion of address and <= span style=3D"font-family:monospace,monospace">count, but both seem = to be be valued as 8, why?


Giacomo

=
--001a1148d7caf7d2a0052ab8242f--