?
Solved

Data displayed as stored in memory

Posted on 1999-01-28
6
Medium Priority
?
161 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
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 300 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

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.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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