Solved

Data displayed as stored in memory

Posted on 1999-01-28
6
159 Views
Last Modified: 2010-04-16
I need to know how to display the data of stack stored in memory. that means, display how the memory keeps the information.
0
Comment
Question by:smondrag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:smondrag
ID: 1217522
Adjusted points to 150
0
 
LVL 1

Expert Comment

by:quanghoc
ID: 1217523
 Do you mean you want to get values from memory or you want to list all program in memory ?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1217524
smnondrag, I don't exactly udnerstand what your question is.. WOuld you pleas elaborate a bit more what it is that you need? Thank you!

-Viktor
--Ivanov
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:scrapdog
ID: 1217525
"Stack" as in an "abstract data type", or literally the program stack?
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1217526
you can view variables as stored in memory by doing this

var
 i:integer;
begin
  i:=3;
  Writeln(Mem[Seg(i):Ofs(i)],' ',Mem[Seg(i):ofs(i)+1);
  readln;
end.
Motaz
0
 
LVL 12

Accepted Solution

by:
Hypo earned 150 total points
ID: 1217527
I THINK that this i what you´re looking for...

 The program dumps a memory block to the screen.
( The memoryblock location is determined by the _seg,_ofs
  variables, and the size of it, by the count variable.)

 If you want to look at the stack after you´ve entered a
 procedure... all that you need to do is to insert the
 first five lines in the testit proc at the point where
 you want to look at the stack.

 In my example you can see that byte number five or six, is the
 same as the last parameter ($15).

(If you need to look at the stack at a certain point were the
 program can't be looping in a wait state, (or maybe you don´t
 use textmode), all you need to do is to dump the stack into an
 array, and then point _seg, _ofs to it and call the writemem
 proc when it´s suitable.)

 Hypo


(--- Cut here
Program MemoryDump{writtin in BP 7.0! }
uses crt;

const hexchar : string[16] = '0123456789ABCDEF';

var _ofs,_seg : word;
    count     : word;

{ The _seg and _ofs variables are the "pointer" to the memory
  position that should be viewed!
  Count is the number of bytes that should be displayed.
 
 To view the stack for instance... you could load the _seg
 variable with the SS register (mov _seg,ss), and the _ofs
 with the SP register (mov _ofs,SP).
 (SS and (E)SP always points at the stack)

}

function wordhex(value: word): string;
begin
 wordhex := hexchar[hi(value) shr 4 +1]+
            hexchar[hi(value) and 15+1]+
            hexchar[lo(value) shr 4 +1]+
            hexchar[lo(value) and 15+1];
end;

function bytehex(value: byte): string;
begin
 bytehex := hexchar[value shr 4 +1]+ hexchar[value and 15+1];
end;

procedure writemem;
var vwd : byte;
begin
 writeln;
 vwd := 0;
 if count > 0 then repeat
 if vwd = 0 then write(wordhex(_seg),':',wordhex(_ofs),'  ');
 write(bytehex(mem[_seg:_ofs]));
 if vwd = 7 then write('-') else write(' ');
 mem[segb800:(wherey-1)*160+122+(vwd+vwd)] := mem[_seg:_ofs];
 inc(vwd);
 inc(_ofs);
 dec(count);
 if vwd = 16 then begin
 writeln;
 vwd := 0;
 end;
 until count = 0;
end;

procedure testit(a, b: byte);
begin
 asm  { always setup the _ofs and _seg variables correctly! }
   mov _ofs,sp; { _ofs := regs.sp; }
   mov _seg,ss; { _seg := regs.ss; }
 end;
 writemem; { dumps the stack to the screen }
 { procedure code below }
end;

begin
 count := 15; { setting up the memory dump size }

 testit($F3,$15);
 writeln;
end.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net code to pascal 1 401
Search the database TADOQuery and TVirtualStringTree 3 632
Get pixel color of a jpg in a TImage 1 2,790
Delphi: how to implement a User Shortcut mapper? 1 156
Determining the an SCCM package name from the Package ID
Configuring Remote Assistance for use with SCCM
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question