|
|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 896 (0x380)
Types: TextFile
Names: »HEXIO.PAS«
└─⟦d482c3728⟧ Bits:30005987 Turbo Pascal v2.00A (Jet80)
└─⟦this⟧ »HEXIO.PAS«
(* Include-File HEXIO.PAS *)
type string2= string(.2.);
Function HexVal(s: string2): integer;
var i, j, m, n: integer;
Function NibbleVal(c: char): integer;
begin
c :=UpCase(c);
if not(c in(.'0'..'9','A'..'F'.)) then NibbleVal:= 257
else if (c>'9') then NibbleVal:= ord(c)-$37
else NibbleVal:= ord(c)-$30
end;
begin (* HexVal *)
m:= NibbleVal(s(.1.));
if (length(s)=1) then HexVal:= m
else begin
n:= NibbleVal(s(.2.));
HexVal:= 16*m+n
end
end;
Procedure WriteHex(b: byte);
var b1: byte;
Procedure WriteNibble(b: byte);
begin
b := b+$30;
if (b>$39) then b := b+7;
write(chr(b))
end;
begin
b1 := b shr 4; WriteNibble(b1);
b1 := b and $0F; WriteNibble(b1)
end;
«eof»