Solved

Data displayed as stored in memory

Posted on 1999-01-28
6
160 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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