| |
| /pliant/language/type/number/int_indian.pli |
| |
| 1 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
scope "/pliant/language/" "/pliant/install/" | |
| 17 |
module "/pliant/install/ring2.pli" | |
| 18 |
| |
| 19 |
| |
| 20 |
function revert16 ui -> rui | |
| 21 |
arg uInt ui rui | |
| 22 |
rui := (ui .and. 0FFh)*2^8 .or. (ui .and. 0FF00h)\2^8 | |
| 23 |
| |
| 24 |
function revert32 ui -> rui | |
| 25 |
arg uInt ui rui | |
| 26 |
rui := (ui .and. 0FFh)*2^24 .or. (ui .and. 0FF00h)*2^8 .or. (ui .and. 0FF0000h)\2^8 .or. (ui .and. 0FF000000h)\2^24 | |
| 27 |
| |
| 28 |
function revert ui -> rui | |
| 29 |
arg uInt ui rui | |
| 30 |
if uInt:size=4 | |
| 31 |
rui := (ui .and. 0FFh)*2^24 .or. (ui .and. 0FF00h)*2^8 .or. (ui .and. 0FF0000h)\2^8 .or. (ui .and. 0FF000000h)\2^24 | |
| 32 |
| |
| 33 |
| |
| 34 |
public | |
| 35 |
| |
| 36 |
| |
| 37 |
if processor_is_low_indian | |
| 38 |
alias uInt16_li uInt16 from "/pliant/language/type/number/int_sized.pli" | |
| 39 |
if processor_is_high_indian | |
| 40 |
type uInt16_li | |
| 41 |
field uInt16 value | |
| 42 |
function 'cast uInt16_li' i -> ii | |
| 43 |
arg uInt16 i ; arg uInt16_li ii | |
| 44 |
implicit | |
| 45 |
ii value := revert16 i | |
| 46 |
function 'cast uInt16' ii -> i | |
| 47 |
arg uInt16_li ii ; arg uInt16 i | |
| 48 |
implicit | |
| 49 |
i := revert16 ii:value | |
| 50 |
| |
| 51 |
if processor_is_high_indian | |
| 52 |
alias uInt16_hi uInt16 from "/pliant/language/type/number/int_sized.pli" | |
| 53 |
if processor_is_low_indian | |
| 54 |
type uInt16_hi | |
| 55 |
field uInt16 value | |
| 56 |
function 'cast uInt16_hi' i -> ii | |
| 57 |
arg uInt16 i ; arg uInt16_hi ii | |
| 58 |
implicit | |
| 59 |
ii value := revert16 i | |
| 60 |
function 'cast uInt16' ii -> i | |
| 61 |
arg uInt16_hi ii ; arg uInt16 i | |
| 62 |
implicit | |
| 63 |
i := revert16 ii:value | |
| 64 |
| |
| 65 |
| |
| 66 |
if processor_is_low_indian | |
| 67 |
alias uInt32_li uInt32 from "/pliant/language/type/number/int_sized.pli" | |
| 68 |
if processor_is_high_indian | |
| 69 |
type uInt32_li | |
| 70 |
field uInt32 value | |
| 71 |
function 'cast uInt32_li' i -> ii | |
| 72 |
arg uInt32 i ; arg uInt32_li ii | |
| 73 |
implicit | |
| 74 |
ii value := revert32 i | |
| 75 |
function 'cast uInt32' ii -> i | |
| 76 |
arg uInt32_li ii ; arg uInt32 i | |
| 77 |
implicit | |
| 78 |
i := revert32 ii:value | |
| 79 |
| |
| 80 |
if processor_is_high_indian | |
| 81 |
alias uInt32_hi uInt32 from "/pliant/language/type/number/int_sized.pli" | |
| 82 |
if processor_is_low_indian | |
| 83 |
type uInt32_hi | |
| 84 |
field uInt32 value | |
| 85 |
function 'cast uInt32_hi' i -> ii | |
| 86 |
arg uInt32 i ; arg uInt32_hi ii | |
| 87 |
implicit | |
| 88 |
ii value := revert32 i | |
| 89 |
function 'cast uInt32' ii -> i | |
| 90 |
arg uInt32_hi ii ; arg uInt32 i | |
| 91 |
implicit | |
| 92 |
i := revert32 ii:value | |
| 93 |
| |
| 94 |
| |
| 95 |
if processor_is_low_indian | |
| 96 |
alias uInt_li uInt from "/pliant/language/type/number/int.pli" | |
| 97 |
if processor_is_high_indian | |
| 98 |
type uInt_li | |
| 99 |
field uInt value | |
| 100 |
function 'cast uInt_li' i -> ii | |
| 101 |
arg uInt i ; arg uInt_li ii | |
| 102 |
implicit | |
| 103 |
ii value := revert i | |
| 104 |
function 'cast uInt' ii -> i | |
| 105 |
arg uInt_li iii ; arg uInt i | |
| 106 |
implicit | |
| 107 |
i := revert ii:value | |
| 108 |
| |
| 109 |
if processor_is_high_indian | |
| 110 |
alias uInt_hi uInt from "/pliant/language/type/number/int.pli" | |
| 111 |
if processor_is_low_indian | |
| 112 |
type uInt_hi | |
| 113 |
field uInt value | |
| 114 |
function 'cast uInt_hi' i -> ii | |
| 115 |
arg uInt i ; arg uInt_hi ii | |
| 116 |
implicit | |
| 117 |
ii value := revert i | |
| 118 |
function 'cast uInt' ii -> i | |
| 119 |
arg uInt_hi ii ; arg uInt i | |
| 120 |
implicit | |
| 121 |
i := revert ii:value | |
| |