From: ratex@image.dk (Sam Samalsson)
Subject: Re: Vax-11 Macro
Date: 1996/04/19 [thread overview]
Message-ID: <N.041996.215636.70@194.19.141.1.image.dk> (raw)
In-Reply-To: 317588FA.446B@rfx.com
> John Olavesen wrote:
> >
> > Is it possible to dynamically allocate memory in using VAX-11 Macro
> > assembly language? If so, how would you go about doing it?
>
> Yes. Use lib$get_vm unless you are writting privileged code.
Maybe this can be used as something to start from,
I use this method myself in a few programs
Sam
;----------------------------------------------------------------------------
.title get_free_vm
;
; Allocating memory using LIB$GET_VM.
; Releasing it again using LIB$FREE_VM.
;
; Author Sam Samalsson
; Dato 24. september 1988
;____________________________________________________________________________
.psect data long,noexe
;Argument list for the lib$create_vm_zone call
;---------------------------------------------
zone_arg:
.long 4 ;number of arguments following
.address zone_id ;the new zone gets an id
.address algorithm ;allocation algorithm
.address alg_argument ;argument for algoritth
.address flags ;fill or not
zone_id:
.long 0 ;address of the zone_id
algorithm:
.long 1 ;first fit
alg_argument:
.long 0 ;first fit dont need argument
flags:
.long 1 ;allocated vm to be filled with 0's
;1's could be chosen
;Argument list for the lib$get_vm call
;-------------------------------------
tab_arg:
.long 3 ;number of arguments
.address tab_len ;longword containing the number of bytes
.address tab_start ;longword containing the start add of
table
.address zone_id ;zonen that we allocate from
tab_len:
.long 0 ;table length in bytes
;we will allocate 20.000 bytes
tab_start:
.long 1
;Argument list for the lib$delete_vm_zone call
;---------------------------------------------
del_zone:
.long 1 ;number of argumentes
.address zone_id ;id of the zonen to be released
;------------------------------------------------------------------------------
.psect code exe,wrt,long,shr,pic
.entry get_free_vm,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
;Here we create the VM-zone from where we will allocate our VM
;-------------------------------------------------------------
create_vm_zone:
callg zone_arg,g^lib$create_vm_zone
blbc r0,error ;if we did not get out
;zone, then branch to error
;Here we allocate our VM
;-----------------------
allocate_vm:
movl #20000,tab_len ;the number of bytes we want
callg tab_arg,g^lib$get_vm
blbc r0,error ;if we did not get our
;memory, then branch to error
;Tabels will be released to VMS, funk_kode 1
;----------------------------------------
release_tab:
callg del_zone,g^lib$delete_vm_zone
blbc r0,error ;if we did not get released the
;zone, then branch to error
brb success
;Here we can build in an exeption handler
;----------------------------------------
error:
brb finido
;Here can be build in a succes handler
;-------------------------------------
success:
finido:
movl #1,r0
ret
.end get_free_vm
prev parent reply other threads:[~1996-04-19 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-16 4:00 Vax-11 Macro John Olavesen
1996-04-16 4:00 ` David Bratton
1996-04-17 4:00 ` John Aldridge
1996-04-17 4:00 ` David F. Wall
1996-04-17 4:00 ` Rodney Iwashina
1996-04-19 4:00 ` Sam Samalsson [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox