9front - general discussion about 9front
 help / color / mirror / Atom feed
* strchr definition
@ 2014-12-07  5:06 brz-systemd-dev
  2014-12-07  5:46 ` [9front] " Iruatã Souza
  2014-12-07 13:25 ` cinap_lenrek
  0 siblings, 2 replies; 3+ messages in thread
From: brz-systemd-dev @ 2014-12-07  5:06 UTC (permalink / raw)
  To: 9front

I seem to be finding conflicting definitions of strchr

strcat(2)
	char* strchr(char *s, char c)

/sys/src/libc/port/strchr.c
	char* strchr(char *s, int c)

/sys/include/libc.h:/strchr/
	extern	char*	strchr(char*, int);

So it seems like it takes an int, rather than a char.
But referencing the 386 asm, this is seen.
/sys/src/libc/386/strchr.s:4: MOVB c+4(FP), AX
                                           (^ Why a 16-bit register?)
Is there a reason for these seemingly divergent definitions?


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

* Re: [9front] strchr definition
  2014-12-07  5:06 strchr definition brz-systemd-dev
@ 2014-12-07  5:46 ` Iruatã Souza
  2014-12-07 13:25 ` cinap_lenrek
  1 sibling, 0 replies; 3+ messages in thread
From: Iruatã Souza @ 2014-12-07  5:46 UTC (permalink / raw)
  To: 9front

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

Em 07/12/2014 03:06, <brz-systemd-dev@intma.in> escreveu:
>
> I seem to be finding conflicting definitions of strchr
>
> strcat(2)
>         char* strchr(char *s, char c)
>
> /sys/src/libc/port/strchr.c
>         char* strchr(char *s, int c)
>
> /sys/include/libc.h:/strchr/
>         extern  char*   strchr(char*, int);
>
> So it seems like it takes an int, rather than a char.
> But referencing the 386 asm, this is seen.
> /sys/src/libc/386/strchr.s:4: MOVB c+4(FP), AX
>                                            (^ Why a 16-bit register?)
> Is there a reason for these seemingly divergent definitions?

The 386 assembler does not do 16 bit, i.e. AX there is 32 bits long.

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

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

* Re: [9front] strchr definition
  2014-12-07  5:06 strchr definition brz-systemd-dev
  2014-12-07  5:46 ` [9front] " Iruatã Souza
@ 2014-12-07 13:25 ` cinap_lenrek
  1 sibling, 0 replies; 3+ messages in thread
From: cinap_lenrek @ 2014-12-07 13:25 UTC (permalink / raw)
  To: 9front

in plan9 assembler, AX is like EAX (or RAX in 64bit mode) in intel assembler.
the operand size is specified by the instruction like MOVB, MOVW, MOVL and MOVQ.

in the MOVB c+4(FP), AX case, it would load a byte, zero extend it to
32bit and store it in AX.

and yes, the manpage should to be fixed in this case. :)

--
cinap


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

end of thread, other threads:[~2014-12-07 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-07  5:06 strchr definition brz-systemd-dev
2014-12-07  5:46 ` [9front] " Iruatã Souza
2014-12-07 13:25 ` cinap_lenrek

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