home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
USCX
/
TURBO-07.ZIP
/
MEMDISP.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1984-07-13
|
3KB
|
119 lines
PROGRAM Memory_Display;
{ This program displays the contents of memory onto the IBM PC's screen. }
{ The user may move though the memory by using the Page Up, Page Dn, Home, }
{ End, Left, Right, Up Arrow and Down Arrow keys. }
{ July 10, 1984. Jeff Firestone. }
CONST
EndOfMem = $9F88; { Top of mem. (640K) less one page (1920) }
MonoChromeScreen = $B00A; { Location of MonoChrome Card + 1 line }
ColorGraphScreen = $B80A; { Location of Color Graphics Card + 1 line }
Esc = #27;
VAR
i : INTEGER;
Done : BOOLEAN;
Mptr, Scrn, Pntr : ^CHAR;
{-------------------------------------------------------------}
PROCEDURE Adjust(Pseg, Pofs : INTEGER);
VAR
SegAdr, OfsAdr : INTEGER;
BEGIN
SegAdr:= MEMW[Pseg:Pofs+2];
OfsAdr:= MEMW[Pseg:Pofs];
IF (OfsAdr < 0) THEN
BEGIN
OfsAdr:= 15;
SegAdr:= SegAdr - 1;
END;
SegAdr:= (SegAdr + (OfsAdr SHR 4));
OfsAdr:= (OfsAdr AND 15);
MEMW[Pseg:Pofs]:= OfsAdr;
MEMW[Pseg:Pofs+2]:= SegAdr;
END;
{-------------------------------------------------------------}
PROCEDURE ShowHex(a:INTEGER);
CONST
HEX = '0123456789ABCDEF';
VAR
inter,i : BYTE;
BEGIN
FOR i := 1 TO 4 DO
BEGIN
inter := a SHR 12;
a := a SHL 4;
WRITE (COPY(hex,inter+1,1));
END;
END;
{-------------------------------------------------------------}
PROCEDURE ReadCommand;
CONST
PageSz = 120;
LineSz = 5;
CharSz = 1;
VAR
key : CHAR;
SegMptr, OfsMptr : INTEGER;
BEGIN
SegMptr:= MEMW[SEG(Mptr):OFS(Mptr)+2];
OfsMptr:= MEMW[SEG(Mptr):OFS(Mptr)];
READ(KBD, key);
IF KEYPRESSED THEN
BEGIN
READ(KBD, key);
CASE key OF
'Q' : SegMptr:= SegMptr + PageSz; { Page Dn }
'I' : SegMptr:= SegMptr - PageSz; { Page Up }
'P' : SegMptr:= SegMptr + LineSz; { Down Arrow }
'H' : SegMptr:= SegMptr - LineSz; { Up Arrow }
'M' : OfsMptr:= OfsMptr + CharSz; { Right Arrow }
'K' : OfsMptr:= OfsMptr - CharSz; { Left Arrow }
'G' : BEGIN SegMptr:= 0; OfsMptr:= 0; END; { Home }
'O' : BEGIN SegMptr:= EndOfMem; OfsMptr:= 0; END; { End }
END;
END; { IF KeyPressed }
MEMW[SEG(Mptr):OFS(Mptr)+2]:= SegMptr;
MEMW[SEG(Mptr):OFS(Mptr)] := OfsMptr;
Adjust(SEG(Mptr),OFS(Mptr));
IF (key = Esc) THEN Done:= TRUE;
END; { PROCEDURE ReadCommand }
{-------------------------------------------------------------}
BEGIN
Done:= FALSE;
MEMW[SEG(Mptr):OFS(Mptr)+2]:= 0; MEMW[SEG(Mptr):OFS(Mptr)]:= 0;
REPEAT
Pntr:= Mptr;
GOTOXY(27,1);
WRITE('Memory Address = ');
ShowHex(MEMW[SEG(Mptr):OFS(Mptr)+2]);
WRITE(':');
ShowHex(MEMW[SEG(Mptr):OFS(Mptr)]);
CLREOL;
MEMW[SEG(Scrn):OFS(Scrn)+2]:= ColorGraphScreen;
MEMW[SEG(Scrn):OFS(Scrn)]:= 0;
FOR i:= 0 TO 1920 DO
BEGIN
Scrn^:= Pntr^;
MEMW[SEG(Pntr):OFS(Pntr)]:= MEMW[SEG(Pntr):OFS(Pntr)] + 1;
MEMW[SEG(Scrn):OFS(Scrn)]:= MEMW[SEG(Scrn):OFS(Scrn)] + 2;
END;
ReadCommand;
UNTIL Done;
CLRSCR;
END.