[comp.os.os9] Shared Data Modules

cjy@hcx.uucp (J. C. Yockey) (09/20/88)

     Could someone provide me with an example of how to create a shared data
module using either the OS-68K or OS-9 relocating macro assembler?  I have
examples using the interactive assembler under OS-9, but no such assembler
was provided with my 2.1 developer's version of OS-68K.  Thanks in advance
for any help.

			Calvin Yockey
			University of Arkansas
			cjy@hcx.uucp

knudsen@ihlpl.ATT.COM (Knudsen) (09/21/88)

In article <707@cseg.uucp>, cjy@hcx.uucp (J. C. Yockey) writes:
> 
>      Could someone provide me with an example of how to create a shared data
> module using either the OS-68K or OS-9 relocating macro assembler?  I have
> examples using the interactive assembler under OS-9, but no such assembler
> was provided with my 2.1 developer's version of OS-68K.  Thanks in advance
> for any help.

Boy have you opened a can of worms!  I have plans for data modules
too, but the "fancy" assembler that needs linking doesn't provide
for many things.

There are really two questions:  How to set the module header
to Data, and What goes into the module?

Header:
I know that a -b switch to the linker will create a Subroutine
module header, which of course contains code (and maybe read-only
strings).  I never saw anything about making a Data header.
The RMA and Linker are very C-oriented.

If necessary, you can use DEBUG or some such to zap the header byte
to Data, save, and verify.
Alternately, assuming your programs know the name of the data module,
just let it be called Program and use the "wild card" type-field
value in your F$Link calls.  This should work; I've linked to
subroutine modules that were headered as Program.

The other question, about the module contents:
Must the entire module's size be initialized data,
or can you just RMB [some of] the space?
If I want a 5K data module that's going to be written into
by programs that don't care about its initial contents,
do I still have to LOAD 5K of dummy zeroes off the disk?

If the answer to the above is unkind, you can always DEBUG
to zap the size field too.  In the old interactive assembler
you explicitly set the SIZE, so good old RMB would be fine.
I'd guess the answer is good, since C sources have no trouble with
RMB areas.

I'd appreciate seeing one of your examples, or a pointer to it
in one of the usual OS9 reference books.  Thanks, mike k.

pasche@ethz.UUCP (Stephan Pasche) (09/23/88)

It is quite easy to create data modules using OS-9's r68/l68.
Here is an example :


Edition equ 1          current edition number

 use /r0/defs/oskdefs.d

Typ_Lang set (Data<<8)
Attr_Rev set (ReEnt<<8)

 psect data_module,Typ_Lang,Attr_Rev,Edition,0,Entry

Entry: dc.b "This is a data module"
 dc.b "          "
 dc.l $01234567,$89abcdef

 ends


You can assemble this file like a normal assemble file :

r68 data.a -o=data.r
l68 data.r -O=data

I hope this will help you

Stephan

==============================================================================
OS/2 & PS/2 : half an operating system for half a computer

Stephan Paschedag           pachedag@strati.ethz.ch  or  pasche@ifi.ethz.ch
Federal Institute Of Technologie Zurich
______________________________________________________________________________

pasche@ethz.UUCP (Stephan Pasche) (09/23/88)

If you don't want to load big data modules, why don't you create them in
runtime ? Here is another example how to create datamodules :

Edition equ 1          current edition number

 use /r0/defs/oskdefs.d

Typ_Lang set (Prgrm<<8)+Objct
Attr_Rev set (ReEnt<<8)
 psect create_datmod,Typ_Lang,Attr_Rev,Edition,0,Entry

StackSiz equ 1000

 vsect
DatMod: ds.l 1         ^data module
DatEnt: ds.l 1         ^entry of datamodule
Stack: ds.b StackSiz   reserved for stack
 ends

Entry: move.l #5000,d0 size of data entries
 move.w #(ReEnt<<8),d1 set attr/revs
 move.w #$0333,d2      set access permission
 lea.l Name(pc),a0     ^name of data module
 os9 F$DatMod          create module
 bcs Error             ..failed
 move.l a2,DatMod(a6)  save ^module
 move.l a1,DatEnt(a6)  save ^entry
 clr.w d1              no error !
Error: os9 F$Exit

Name: dc.b "DataModule",0
 ends

Assembling : r68 create_datmod.a -o=create_datamod.r
             l68 create_datmod.r -l=/dd/lib/sys.l -O=create_datmod

==============================================================================
OS/2 & PS/2 : half an operating system for half a computer

Stephan Paschedag           pachedag@strati.ethz.ch  or  pasche@ifi.ethz.ch
Federal Institute Of Technologie Zurich
______________________________________________________________________________

knudsen@ihlpl.ATT.COM (Knudsen) (09/27/88)

Thanks for the information.  Creating data modules at runtime
sounds like a really radical idea, very helpful.

I'll have to go look at my manuals to see whether OS9/6809
supports these tricks.  OSK is so much more advanced in some ways.

BTW, do you really need to reserve Stack space in a data module?
Won't your program keeping using its own stack space?