xref: /haiku/src/system/libroot/os/arch/ppc/system_time_asm.S (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
1e55e1a0eSIngo Weinhold/*
2e55e1a0eSIngo Weinhold** Copyright 2003, Axel D�fler, axeld@pinc-software.de. All rights reserved.
3*2ca13760SColdfirex** Distributed under the terms of the MIT License.
4e55e1a0eSIngo Weinhold*/
5e55e1a0eSIngo Weinhold
6e55e1a0eSIngo Weinhold#define FUNCTION(x) .global x; .type x,@function; x
7e55e1a0eSIngo Weinhold
8e55e1a0eSIngo Weinhold.text
9e55e1a0eSIngo Weinhold
10e55e1a0eSIngo Weinhold/* int64 __ppc_get_time_base(void)
11e55e1a0eSIngo Weinhold * r3/r4
12e55e1a0eSIngo Weinhold */
13e55e1a0eSIngo WeinholdFUNCTION(__ppc_get_time_base):
14e55e1a0eSIngo Weinhold		/* get TB (time base) register */
15e55e1a0eSIngo Weinholdcarry:	mftbu	%r3
16e55e1a0eSIngo Weinhold		mftb	%r4
17e55e1a0eSIngo Weinhold		mftbu	%r5			// read the upper half again
18e55e1a0eSIngo Weinhold		cmpw	%r3, %r5	// and check if the values have changed
19e55e1a0eSIngo Weinhold		bne		carry		// try again, if they had
20e55e1a0eSIngo Weinhold		blr
21e55e1a0eSIngo Weinhold
22