Dec 122017
Hex routines in Turbo Pascal 4.0 – BASIC “USING”-like syntax. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
HEXDMP.DOC | 4956 | 1471 | deflated |
HEXDMP.TPU | 7152 | 2851 | deflated |
HEXTEST.PAS | 4282 | 1302 | deflated |
Download File HEXDMP.ZIP Here
Contents of the HEXDMP.DOC file
Unit HexDmp;
{ -----------------------------------------------------------------------
HEXDMP.TPU
Version 1.0
Copyright 1987 Lawrence R. Steeger
Permission is granted to distribute this unit and its associated files
for both commercial and non-commercial use, if all copyright statements
and the following liability statements are included.
No liability for any damage caused by the use of this unit, or by
programming errors in this unit, can be assumed by the author.
Programming errors may be reported to Lawrence R. Steeger [72260,107]
on CompuServe.
-----------------------------------------------------------------------
{ This unit provides hexadecimal dump/display routines. }
Interface
Type HexString = string[5];
Procedure HexArea(F: string; { hexadecimal format control string }
A: integer; { ASCII options:
Normal ASCII 0 [32..126]
HiBit Masked 1 [32..126,160..206]
IBM Graphics 2 [32..255] }
B: boolean; { True if base line is offset 0 }
P: pointer; { start of area to dump }
W: word { length of area to dump }
); { writes output using Writeln(Hexline()) }
Function HexLine(F: string; { hexadecimal format control string }
A: integer; { ASCII options:
Normal ASCII 0 [32..126]
HiBit Masked 1 [32..126,160..206]
IBM Graphics 2 [32..255] }
var B: boolean; { 1st line flag (updated) }
var P: pointer; { start of area to dump (updated) }
var I: word; { bytes left to display (updated) }
var D: word { bytes displayed (returned) }
): string; { hexadecimal output (returned) }
Function HexWord(W: word; { word to be formatted }
B: boolean { if True use Hi-Lo format else Lo-Hi }
): HexString; { hexadecimal output (returned) }
{ The next fourteen constants may be used in hex format strings.
Any characters not defined below will be displayed as entered
in the format string.
To display one of the following character tokens as itself,
the HexEsc token must precede any such character. }
Const HexOfs = '@'; { offset tokens: }
HexOfsMask = '@@@@'; { current HexByte offset display }
HexOfsLMask = '@LLL'; { starting HexLine offset display }
HexSeg = '%'; { segment tokens: }
HexSegMask = '%%%%'; { current HexByte segment display }
HexSegLMask = '%LLL'; { starting HexLine segment display }
HexByt = '#'; { byte tokens: }
HexBytMask = '##'; { HexByte display }
HexHiB = '^'; { vertical HexHi display }
HexLoB = '&'; { vertical HexLo display }
HexAsc = '~'; { ASCII character display }
HexVAsc = '!'; { vertical ASCII character display }
HexNL = '_'; { start new line }
HexEsc = '/'; { next character displayed as is }
{ The next three constants define the HexLine and HexArea ASCII option. }
HexASCII = 0; { display normal ASCII only }
HexHiBit = 1; { mask hi-bits and display normal ASCII only }
HexIBMGraph = 2; { display all bytes in IBM graphics format }
{ The next five constants are samples of hexadecimal formatting strings
for use with HexArea and Hexline.
These constants do not exist in the unit itself. The user of the unit
must provide any such definitions.
Const HexBytes: string[79] =
'%%%%:@@@@ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ~~~~~~~~ ~~~~~~~~';
HexDebug: string[78] =
'%%%%:@@@@ ## ## ## ## ## ## ## ##-## ## ## ## ## ## ## ## ~~~~~~~~~~~~~~~~';
Note: The following three constants would be concatenated
to create a format string for a Vertical Hex Format.
Notice the use of the HexNL token to generate multiple
lines of output.
HexVline1: string[77] =
' !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!!_';
HexVline2: string[77] =
'%LLL: ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^_';
HexVline3: string[77] =
'@LLL &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&_';
}
Implementation
{ -----------------------------------------------------------------------
HEXDMP.TPU
Version 1.0
Copyright 1987 Lawrence R. Steeger
Permission is granted to distribute this unit and its associated files
for both commercial and non-commercial use, if all copyright statements
and the following liability statements are included.
No liability for any damage caused by the use of this unit, or by
programming errors in this unit, can be assumed by the author.
Programming errors may be reported to Lawrence R. Steeger [72260,107]
on CompuServe.
-----------------------------------------------------------------------
{ This unit provides hexadecimal dump/display routines. }
Interface
Type HexString = string[5];
Procedure HexArea(F: string; { hexadecimal format control string }
A: integer; { ASCII options:
Normal ASCII 0 [32..126]
HiBit Masked 1 [32..126,160..206]
IBM Graphics 2 [32..255] }
B: boolean; { True if base line is offset 0 }
P: pointer; { start of area to dump }
W: word { length of area to dump }
); { writes output using Writeln(Hexline()) }
Function HexLine(F: string; { hexadecimal format control string }
A: integer; { ASCII options:
Normal ASCII 0 [32..126]
HiBit Masked 1 [32..126,160..206]
IBM Graphics 2 [32..255] }
var B: boolean; { 1st line flag (updated) }
var P: pointer; { start of area to dump (updated) }
var I: word; { bytes left to display (updated) }
var D: word { bytes displayed (returned) }
): string; { hexadecimal output (returned) }
Function HexWord(W: word; { word to be formatted }
B: boolean { if True use Hi-Lo format else Lo-Hi }
): HexString; { hexadecimal output (returned) }
{ The next fourteen constants may be used in hex format strings.
Any characters not defined below will be displayed as entered
in the format string.
To display one of the following character tokens as itself,
the HexEsc token must precede any such character. }
Const HexOfs = '@'; { offset tokens: }
HexOfsMask = '@@@@'; { current HexByte offset display }
HexOfsLMask = '@LLL'; { starting HexLine offset display }
HexSeg = '%'; { segment tokens: }
HexSegMask = '%%%%'; { current HexByte segment display }
HexSegLMask = '%LLL'; { starting HexLine segment display }
HexByt = '#'; { byte tokens: }
HexBytMask = '##'; { HexByte display }
HexHiB = '^'; { vertical HexHi display }
HexLoB = '&'; { vertical HexLo display }
HexAsc = '~'; { ASCII character display }
HexVAsc = '!'; { vertical ASCII character display }
HexNL = '_'; { start new line }
HexEsc = '/'; { next character displayed as is }
{ The next three constants define the HexLine and HexArea ASCII option. }
HexASCII = 0; { display normal ASCII only }
HexHiBit = 1; { mask hi-bits and display normal ASCII only }
HexIBMGraph = 2; { display all bytes in IBM graphics format }
{ The next five constants are samples of hexadecimal formatting strings
for use with HexArea and Hexline.
These constants do not exist in the unit itself. The user of the unit
must provide any such definitions.
Const HexBytes: string[79] =
'%%%%:@@@@ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ~~~~~~~~ ~~~~~~~~';
HexDebug: string[78] =
'%%%%:@@@@ ## ## ## ## ## ## ## ##-## ## ## ## ## ## ## ## ~~~~~~~~~~~~~~~~';
Note: The following three constants would be concatenated
to create a format string for a Vertical Hex Format.
Notice the use of the HexNL token to generate multiple
lines of output.
HexVline1: string[77] =
' !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!!_';
HexVline2: string[77] =
'%LLL: ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^_';
HexVline3: string[77] =
'@LLL &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&_';
}
Implementation
December 12, 2017
Add comments