NetBSD Problem Report #3879

Received: (qmail 1630 invoked from network); 17 Jul 1997 17:31:20 -0000
Message-Id: <>
Date: Fri, 18 Jul 1997 02:31:18 +0900
From: Hiroshi HORIMOTO <>
Subject: Contribution: atoi(3) for m68k.
X-Send-Pr-Version: 3.95

>Number:         3879
>Category:       port-m68k
>Synopsis:       Contribution: atoi(3) for m68k.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    is
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 17 10:35:04 +0000 1997
>Closed-Date:    Sun Oct 27 20:21:40 +0000 2002
>Last-Modified:  Sun Oct 27 20:21:40 +0000 2002
>Originator:     Hiroshi Horimoto
>Release:        07/17/97
Shizuoka Institute of Science and Technology, Japan.
	atoi(3) in libc.a for all m68k-based machines.

System: NetBSD 1.2G NetBSD 1.2G (SILPHEED) #25: Thu Jul 17 04:53:18 JST 1997 x68k

	I wrote assembler version of atoi(3) (and atol(3)) for m68k.
	I contribute it. Please use it if you like.
	This is src/lib/libc/arch/m68k/stdlib/atoi.S.
	BTW, the codes of abs(3) and labs(3) are identical.
	Why don't you integrate them into one file `abs.S' ?
BEGIN -- cut here
#include <machine/asm.h>

#define ERANGE	34

#ifndef _REENTRANT
	.extern	_errno
	.extern	___errno

	movl	d2,sp@-
	movl	sp@(8),a0
	movq	#-9,d1
	addb	a0@+,d1
	cmpb	#23,d1		| space ?
	jeq	Lskipsp
	cmpb	#5,d1		| or something like ?
	jcs	Lskipsp
	movq	#0,d0		| accumulator
	movl	#214748364,a1	| limits (2147483640+7)
	movq	#7,d2
	cmpb	#34,d1		| plus ?
	jeq	Lgetnum
	cmpb	#36,d1		| minus ?
	jeq	Lnegative
	subqw	#1,a0		| re-fetch this char.
	jra	Lgetnum

	movq	#-8,d2		| limit (-(2147483640+8))
	negb	d2		| d2 = 0xffffff08
	jra	Lgetnum

	cmpl	a1,d0
	jcs	Lsafe
	jhi	Loverflow
	cmpb	d2,d1
	jhi	Loverflow	| jcc ?
	addl	d0,d0		| d0 = d0 * 10 + d1
	addl	d0,d1
	addl	d0,d0
	addl	d0,d0
	addl	d1,d0
	movq	#48,d1
	negb	d1
	addb	a0@+,d1
	cmpb	#10,d1
	jcs	Lchkoverflow
	tstl	d2
	jpl	0f
	negl	d0
	movl	sp@+,d2

#ifndef _REENTRANT
	movq	#ERANGE,d0
	movl	d0,_errno
	jbsr	___errno	| d2 is not modified.
	movl	d0,a0
	movq	#ERANGE,d0
	movl	d0,a0@
	movl	#0x7fffffff,d0
	tstl	d2
	jpl	1f
	addql	#1,d0
	movl	sp@+,d2
END -- cut here
Responsible-Changed-From-To: gnats-admin->jtc 
Responsible-Changed-By: mycroft 
Responsible-Changed-When: Thu Oct 9 22:39:30 PDT 1997 
jtc is our 68k optimization guru.   
Responsible-Changed-From-To: jtc->port-m68k-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Wed Mar 17 14:15:53 PST 1999 
JTC has timed out, and these really should be looked at; speeding 
up the large numbers of m68k ports we have would be a win. 
State-Changed-From-To: open->analyzed 
State-Changed-By: is 
State-Changed-When: Tue Nov 28 07:52:43 PST 2000 
- merging abs and labs would make of of them go away if an application defines 
its own other-one-of-them. Have to check with some standards wizard wether 
this is acceptable. 
- the provided atoi() code does not use isspace(), but a fixed charset version 
of it. I think this is bad. 

Responsible-Changed-From-To: port-m68k-maintainer->is 
Responsible-Changed-By: is 
Responsible-Changed-When: Tue Nov 28 07:52:43 PST 2000 
Looking at this. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: chs 
State-Changed-When: Sun Oct 27 12:20:00 PST 2002 
I doubt anyone is going write the assembler for an I18N-safe isspace(). 
if no one has felt motivated to do that for the past 5 years, 
it's unlikely to happen ever. 

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.