From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,5de3b8bd954d5ed6 X-Google-Attributes: gid1164f8,public From: ratex@image.dk (Sam Samalsson) Subject: Re: Vax-11 Macro Date: 1996/04/19 Message-ID: #1/1 X-Deja-AN: 150380543 references: <00001be4+00001892@msn.com> <317588FA.446B@rfx.com> organization: Ratex newsgroups: comp.sys.dec > 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 ;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