home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
PUDD.ARC
/
GENTOOLS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-08-11
|
4KB
|
102 lines
{**************************************************************************
* setbitB(bit, byte) - set bit #bit in byte
*
* input -> (char), (integer)
*
* Results -> The 'bit'th bit in `byte` is set. Bits are numbered as laid
* out below:
* 7 6 5 4 3 2 1 0
*************************************************************************}
procedure setbitB(bit : integer; var subject : byte);
var tmp : integer;
i : integer;
temp : byte;
begin
temp := subject;
tmp := 1;
for i := 1 to bit do
tmp := tmp * 2;
inline($3A/temp/ { ld A,(nn) ;get the byte }
$21/tmp/ { ld HL,nn ;get the mask adr }
$56/ { ld D,(HL) ;get the mask }
$B2/ { or D ;use it }
$32/temp); { ld (nn),A :put it back }
subject := temp;
end; { setbitB }
{**************************************************************************
* clrbitB(bit, byte) - clear bit #bit in byte
*
* input -> (char), (integer)
*
* Results -> The 'bit'th bit in `byte` is cleared. Bits are numbered as
* laid out below:
* 7 6 5 4 3 2 1 0
*************************************************************************}
procedure clrbitB(bit : integer; var subject :byte);
var tmp : integer;
i : integer;
temp : byte;
begin
temp := subject;
tmp := 1;
for i := 1 to bit do
tmp := tmp * 2;
inline($21/tmp/ { ld HL,nn ;get the mask adr }
$7E/ { ld A,(HL) ;get the mask }
$2F/ { cpl ;compliment }
$21/temp/ { ld HL,nn ;get the byte adr }
$56/ { ld D,(HL) ;get the byte }
$A2/ { and D ;mask it }
$32/temp); { ld (nn),A :put it back }
subject := temp;
end; { clrbitB }
{**************************************************************************}
{* ReadByte will return a charactor string with the correct a series *}
{* 1's and 0's in an 8 charactor string to represent the actual bits *}
{* in the byte. *}
{**************************************************************************}
procedure ReadByte(sample:byte; var Bitlist:Blist);
var ListLocal :Blist;
ByteLocal :byte;
begin
ListLocal := '00000000';
ByteLocal := sample;
inline($3A/ByteLocal/ { LD A,(ByteLocal) }
$21/ListLocal/ { LD HL,ListLocal }
$06/$30/ { LD B,0 }
$0E/$31/ { LD C,1 }
$16/$08/ { LD D,8 }
$23/ { INC HL :top }
$CB/$47/ { BIT 1,A }
$20/$03/ { JR NZ,one }
$70/ { LD (HL),B }
$18/$01/ { JR done }
$71/ { LD (HL),C :one }
$CB/$1F/ { RR A :done }
$15/ { DEC D }
$20/$F2 ); { JR NZ,top }
Bitlist := ListLocal;
end; {........................ ......ReadByte}
{**************************************************************************}
procedure FlipList(var BitList:Blist);
var i,j :integer;
temp :Blist;
begin
temp := '';
for i := 8 downto 1 do
begin
temp := temp + copy(BitList,i,1);
end;
BitList := temp;
end;