.TITLE LIB_PUTS High Level Language memory store routines .IDENT /V01.02/ ;++LIBPUTS.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Library ; ; Abstract: ; This is a package of procedures callable from any High Level Language ; (i.e., FORTRAN) to store items in data structures in memory in an ; indirect fashion where the address of the item or data structure is ; stored in variable (value of the variable is itself an address). ; ; Environment: ; Stored in FERMILIB.OLB and linked into users' programs. No access ; checks are made: assumes incorrect addressing is caught by access ; violations. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 19-Sep-82 ; ; V01.00 19-Sep-82 FJN Created to form a single compact module for ; many uses. ; V01.01 09-Oct-82 FJN Fix problem: define PUT_NOTNDX label ; V01.02 12-Oct-82 FJN Fix problem similar to LIB_GET problem, not ; enough indirection ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; .LIBRARY "SYS$LIBRARY:LIB.MLB" ;To allow use of CASE macro ; ; Library Macros: ; ; NONE ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; nargs = 0 ;Offset to number of arguments in list put_val = 4 ;Offset to value argument put_loc = 8 ;Offset to location argument put_ndx = 12 ;Offset to index argument num_loc = put_loc/4 ;Argument number of location argument ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE Entry points for PUT routines ;+0LIB_PUT_XXXX ; ; Functional Description: ; Store a value into a specified memory location or into an array ; whose base memory location and item index are given. The data types ; of the item (XXXX) are BYTE, WORD, LONG, and QUAD. ; ; Calling Sequence: ; CALL LIB_PUT_XXXX( value, location [,index] ) ; ; Input Parameters: ; value - address of a location containing the data value to be stored ; at the specified memory/array location. The value is ; accessed according to the data type (BYTE, WORD, LONG or QUAD). ; location - address of a longword which contains the address of the ; item's memory location or the address of the base or an ; array in which the data value is to be stored. ; index - address of a longword which contains the index of the item in ; the array whose base address is given by location. If this ; optional argument is used, then indexed addressing is used. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; NONE ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- ;+ LIB_PUT_BYTE ; Store a byte value into a memory location or an indexed array. ; ; CALL LIB_PUT_BYTE( value.rb.r, location.ra.r [,index.rl.r] ) ; ; value value to be stored at the specified location in memory ; or an indirectly-referenced array. Passed by reference. ; ; location is the longword which contains the address of the byte ; in memory or of the start of the array of bytes. ; Passed by reference. ; ; index is an optional argument which indicates that an array of ; bytes is to be accessed by indexed addressing. The index ; argument is a longword which contains the index of the byte ; in the array. If the index argument is not used, then ; location gives the address of where to store the byte. ; Passed by reference. ;- .ENTRY LIB_PUT_BYTE,^M CLRL R0 ;Case 0 is get signed byte BRB PUT_COMMON ;+ LIB_PUT_WORD ; Store a word value into a memory location or an indexed array. ; ; CALL LIB_PUT_WORD( value.rw.r, location.ra.r [,index.rl.r] ) ; ; value value to be stored at the specified location in memory ; or an indirectly-referenced array. Passed by reference. ; ; location is the longword which contains the address of the word ; in memory or of the start of the array of words. ; Passed by reference. ; ; index is an optional argument which indicates that an array of ; words is to be accessed by indexed addressing. The index ; argument is a longword which contains the index of the word ; in the array. If the index argument is not used, then ; location gives the address of where to store the word. ; Passed by reference. ;- .ENTRY LIB_PUT_WORD,^M MOVB #1,R0 ;Case 1 is PUT signed word BRB PUT_COMMON ;+ LIB_PUT_LONG ; Store a longword value into a memory location or an indexed array. ; ; CALL LIB_PUT_LONG( value.rl.r, location.ra.r [,index.rl.r] ) ; ; value value to be stored at the specified location in memory ; or an indirectly-referenced array. Passed by reference. ; ; location is the longword which contains the address of the longword ; in memory or of the start of the array of longwords. ; Passed by reference. ; ; index is an optional argument which indicates that an array of ; longwords is to be accessed by indexed addressing. The ; index argument is a longword which contains the index of ; the longword in the array. If the index argument is not ; used, then location gives the address of where to store ; the longword. Passed by reference. ;- .ENTRY LIB_PUT_LONG,^M MOVB #2,R0 ;Case 2 is get signed/unsigned longword BRB PUT_COMMON ;+ LIB_PUT_QUAD ; Store a quadword value into a memory location or an indexed array. ; ; CALL LIB_PUT_QUAD( value.rq.r, location.ra.r [,index.rl.r] ) ; ; value value to be stored at the specified location in memory ; or an indirectly-referenced array. Passed by reference. ; ; location is the longword which contains the address of the quadword ; in memory or of the start of the array of quadwords. ; Passed by reference. ; ; index is an optional argument which indicates that an array of ; quadwords is to be accessed by indexed addressing. The ; index argument is a longword which contains the index of ; the quadword in the array. If the index argument is not ; used, then location gives the address of where to store ; the quadword. Passed by reference. ;- .ENTRY LIB_PUT_QUAD,^M MOVB #3,R0 ;Case 3 is get quadword BRB PUT_COMMON .PAGE .SUBTITLE Common code for all PUT routines ; ; This common code determines whether straight or indexed addressing modes ; are to be used to store the data. This decision is based on the presence ; of the index argument (must also be non-defaulted). ; PUT_COMMON: MOVL @put_loc(AP),R2 ;Get address of where to store data CMPB nargs(AP),#num_loc ;Is there an index argument? BLEQ PUT_NOTNDX ;If not, use non-indexed addressing TSTL put_ndx(AP) ;Is the index argument defaulted? BEQL PUT_NOTNDX ;If so, use non-indexed addressing MOVL @put_ndx(AP),R1 ;Get index value BEQL PUT_NOTNDX ;If zero, use non-indexed addressing ; (for speed?) ; ; Fall throught to CASE for indexed addressing for the various data types ; .PAGE .SUBTITLE CASE for indexed addressing ; ; CASE for indexed addressing for the various data types ; CASE R0,,type=B ; PUTNDX_BYTE: MOVB @put_val(AP),(R2)[R1] ;Store byte RET ; PUTNDX_WORD: MOVW @put_val(AP),(R2)[R1] ;Store word RET ; PUTNDX_LONG: MOVL @put_val(AP),(R2)[R1] ;Store longword RET ; PUTNDX_QUAD: MOVQ @put_val(AP),(R2)[R1] ;Store quadword RET .PAGE .SUBTITLE CASE for non-indexed addressing ; ; CASE for non-indexed addressing for the various data types ; PUT_NOTNDX: CASE R0,,type=B ; PUT_BYTE: MOVB @put_val(AP),(R2) ;Store byte RET ; PUT_WORD: MOVW @put_val(AP),(R2) ;Store word RET ; PUT_LONG: MOVL @put_val(AP),(R2) ;Store longword RET ; PUT_QUAD: MOVQ @put_val(AP),(R2) ;Store quadword RET .END