Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Management 1

Status
Not open for further replies.

DocDooM

Programmer
Mar 2, 1999
2
0
0
DE
Hi!!!<br>
<br>
I´m searching for some help on Mem in Asm...<br>
Could someone of you please post some code on how to<br>
save something in Mem (like an string in basic)<br>
<br>
Thanx<br>
Doc DooM
 
I'm not sure I understand what you mean. In ASM strings are just chunks of memory. You can declare a block of memory with a DS command (Declare Storage)or a DC (Declare Constant). I am assuming you are using x86 ASM. Different platforms use different commands.<br>

 
First declare how much memory you want to set <br>
aside for a given field. Either a DC or a DS will<br>
do this. The difference is a DS merely reserves <br>
the memory but doesn't change the contents of the<br>
memory, while a DC reserves the memory and stores <br>
a constant in it. <br>
FIELD-1 DS CL80 Reserves 80 bytes<br>
FIELD-2 DC CL80'ABCE' Reserves 80 bytes, and<br>
puts ABCD in the leftmost<br>
4 bytes, and fills the<br>
remaining 76 with blanks. <br>
The compiler automatically<br>
fills unused positions to the right with blanks,.<br>
for C (character) fields.<br>
Notice the DS has nothing in apostrophes after it.<br>
The DC has to have something in apostrohes, because<br>
that's the nature of the definition.<br>
To move something to the fields:<br>
MVC FIELD-1,=CL8'THORFOUR'<br>
MVC FIELD-2,FIELD-1<br>
Assembler moves the b-field (=CL8'THORFOUR) to the<br>
a-field (FIELD-1). The b-field is another way to<br>
set up a constant, except it won't have a label.<br>
Assembler will then move FIELD-1(which now contains<br>
THORFOUR followed by 76 bytes containing anything,<br>
to FIELD-2, wiping out the ABCD that was there.<br>
Hope this helps. <br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top