Solved

Data displayed as stored in memory

Posted on 1999-01-28
6
154 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Interbase BDE 4 455
Delphi Ascii code 2 988
Object was open using ADO and Delphi 2007 33 210
add combobox item based on numbers 9 141
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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