mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-20 01:46:06 +00:00
pdp10-arith: add pdp10_sext_uint18()
This commit is contained in:
parent
5e2ad04250
commit
54ea34d560
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* pdp10-arith.h -- arithmetic on PDP10 integer types
|
||||
* Copyright (C) 2013-2015 Mikael Pettersson
|
||||
* Copyright (C) 2013-2018 Mikael Pettersson
|
||||
*
|
||||
* This file is part of pdp10-tools.
|
||||
*
|
||||
@ -44,6 +44,14 @@ static inline pdp10_int36_t pdp10_sext_int36(pdp10_uint36_t x)
|
||||
return ((x & PDP10_UINT36_MAX) ^ PDP10_UINT36_SBIT) - PDP10_UINT36_SBIT;
|
||||
}
|
||||
|
||||
/* Sign-extend a pdp10_uint18_t to the full width of its representation type. */
|
||||
static inline pdp10_uint18_t pdp10_sext_uint18(pdp10_uint18_t x)
|
||||
{
|
||||
const pdp10_uint18_t PDP10_UINT18_SBIT = ~(PDP10_UINT18_MAX >> 1) & PDP10_UINT18_MAX;
|
||||
|
||||
return ((x & PDP10_UINT18_MAX) ^ PDP10_UINT18_SBIT) - PDP10_UINT18_SBIT;
|
||||
}
|
||||
|
||||
static inline pdp10_uint36_t pdp10_neg_int36(pdp10_uint36_t x)
|
||||
{
|
||||
return pdp10_zext_uint36(-pdp10_sext_int36(x));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user