elf2boot: move uint36_to_c36 conversion to extint

This commit is contained in:
Mikael Pettersson
2025-08-14 16:04:45 +02:00
parent 15434fdd34
commit 0667130fc4
2 changed files with 11 additions and 7 deletions

View File

@@ -288,13 +288,7 @@ outfp_fseekw({h36, OutFP}, WordOffset) ->
stdio9:fseek(OutFP, {bof, WordOffset*4}).
outfp_fputw(Word, {c36, IoDev}) ->
B4 = Word band 15,
B3 = (Word bsr 4) band 255,
B2 = (Word bsr 12) band 255,
B1 = (Word bsr 20) band 255,
B0 = (Word bsr 28) band 255,
Bytes = [B0, B1, B2, B3, B4],
stdio8:fputs(Bytes, IoDev);
stdio8:fputs(extint:uint36_to_c36(Word), IoDev);
outfp_fputw(Word, {h36, OutFP}) ->
stdio9:fputs(extint:uint36_to_ext(Word), OutFP).

View File

@@ -32,6 +32,7 @@
, uint32_from_ext/1
, uint32_to_ext/1
, uint36_from_ext/1
, uint36_to_c36/1
, uint36_to_ext/1
, uint64_from_ext/1
, uint64_to_ext/1
@@ -83,6 +84,15 @@ uint36_to_ext(U36) ->
_B2 = (U36 bsr 9) band ?UINT9_MAX,
_B3 = U36 band ?UINT9_MAX].
%% This converts a 36-bit word to 5 octets in KLH10's C36 format.
-spec uint36_to_c36(uint36_t()) -> [uint8_t()].
uint36_to_c36(U36) ->
[_B0 = (U36 bsr 28) band 255,
_B1 = (U36 bsr 20) band 255,
_B2 = (U36 bsr 12) band 255,
_B3 = (U36 bsr 4) band 255,
_B4 = U36 band 15].
-spec uint64_from_ext([uint8_t()]) -> uint64_t().
uint64_from_ext([B0, B1, B2, B3, B4, B5, B6, B7]) ->
((B0 band ?UINT8_MAX) bsl 56) bor