aboutsummaryrefslogtreecommitdiff
path: root/sys/osb/miiupk32.x
blob: 183805f701ecbdba82527fc04e512bac6c124783 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mach.h>

# MIIUPK32 -- Unpack a 32 bit signed MII array into an SPP array of the
# indicated datatype.

procedure miiupk32 (mii, spp, nelems, spp_datatype)

int	mii[ARB]		#I input MII format array
int	spp[ARB]		#O output SPP format array
int	nelems			#I number of integers to be converted
int	spp_datatype		#I SPP datatype code

int	mii_bytes
int	spp_bytes
int	sizeof()

begin
	mii_bytes = 32 / NBITS_BYTE
	spp_bytes = sizeof(spp_datatype) * SZB_CHAR

        if ( mii_bytes == spp_bytes ) {
	    if (BYTE_SWAP4 == YES) {
		call bswap4 (mii, 1, spp, 1, nelems * (mii_bytes))
		call achtl (spp, spp, nelems, spp_datatype)
	    } else if (BYTE_SWAP2 == YES) {
		call bswap2 (mii, 1, spp, 1, nelems * (mii_bytes))
		call achtl (spp, spp, nelems, spp_datatype)
	    } else
		call achtl (mii, spp, nelems, spp_datatype)

	} else if ( 2 * mii_bytes == spp_bytes ) {
	    call i32to64 (mii, spp, nelems) 		# for 64bit integer
	    if (BYTE_SWAP8 == YES) {
		call bswap8 (spp, 1, spp, 1, nelems * (spp_bytes))
		call achtl (spp, spp, nelems, spp_datatype)
	    } else if (BYTE_SWAP4 == YES) {
		call bswap4 (spp, 1, spp, 1, nelems * (spp_bytes))
		call achtl (spp, spp, nelems, spp_datatype)
	    } else if (BYTE_SWAP2 == YES) {
		call bswap2 (spp, 1, spp, 1, nelems * (spp_bytes))
		call achtl (spp, spp, nelems, spp_datatype)
	    } else
		call achtl (spp, spp, nelems, spp_datatype)

	} else {
	    call eprintf("[ERROR] miiupk32.x: unexpected integer size\n")
	}
end