.TITLE LIB_GETS High Level Language memory access routines .IDENT /V01.03/ ;++LIBGETS.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Library ; ; Abstract: ; This is a package of functions callable from any High Level Language ; (i.e., FORTRAN) to access 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 GET_NOTNDX label ; V01.02 12-Oct-82 FJN Fix bad, bad bug run into by Lin. ; V01.03 15-Apr-83 FJN Standardize header help comments ; .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 get_loc = 4 ;Offset to location argument get_ndx = 8 ;Offset to index argument num_loc = get_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 GET routines ;+0LIB_GET_XXXX ; ; Functional Description: ; Get a signed value from a specified memory location or from 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: ; value = LIB_GET_XXXX( location [,index] ) ; ; Input Parameters: ; location - address of a longword which contains the address of the ; desired item's memory location or the address of the base ; of an array containing the item. ; 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: ; value - value of the item at the specified memory/array location. ; For BYTE, WORD, and LONG this is returned as a signed longword ; value in register R0. For QUAD data types this is returned ; in registers R0 and R1. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- ;+ LIB_GET_BYTE ; Return a byte value from a memory location or an indexed array. ; ; value.wl.v = LIB_GET_BYTE( location.ra.r [,index.rl.r] ) ; ; location 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 the byte itself. Passed by ; reference. ; ; value the byte data value is returned as a sign-extended longword. ; Passed by value. ; ;- .ENTRY LIB_GET_BYTE,^M CLRL R0 ;Case 0 is get signed byte BRB GET_COMMON ;+ LIB_GET_WORD ; Return a word value from a memory location or an indexed array. ; ; value.wl.v = LIB_GET_WORD( location.ra.r [,index.rl.r] ) ; ; location 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 the word itself. Passed by ; reference. ; ; value the word data value is returned as a sign-extended longword. ; Passed by value. ; ;- .ENTRY LIB_GET_WORD,^M MOVB #1,R0 ;Case 1 is get signed word BRB GET_COMMON ;+ LIB_GET_LONG ; Return a longword value from a memory location or an indexed array. ; ; value.wl.v = LIB_GET_LONG( location.ra.r [,index.rl.r] ) ; ; location 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 the longword ; itself. Passed by reference. ; ; value the returned longword data value. Passed by value. ; ;- .ENTRY LIB_GET_LONG,^M MOVB #2,R0 ;Case 2 is get signed/unsigned longword BRB GET_COMMON ;+ LIB_GET_QUAD ; Return a quadword value from a memory location or an indexed array. ; ; value.wq.v = LIB_GET_QUAD( location.ra.r [,index.rl.r] ) ; ; location 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 the quadword ; itself. Passed by reference. ; ; value the returned quadword data value. Passed by value. ; ;- .ENTRY LIB_GET_QUAD,^M MOVB #3,R0 ;Case 3 is get quadword BRB GET_COMMON .PAGE .SUBTITLE Entry points for GETZE routines ;+0LIB_GETZE_XXXX ; ; Functional Description: ; Get an unsigned value from a specified memory location or from an array ; whose base memory location and item index are given. The data types ; of the item (XXXX) are BYTE or WORD. ; ; Calling Sequence: ; value = LIB_GETZE_XXXX( location [,index] ) ; ; Input Parameters: ; location - address of a longword which contains the address of the ; desired item's memory location or the address of the base ; of an array containing the item. ; 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: ; value - value of the item at the specified memory/array location. ; The value is returned zero-extended (unsigned) as a longword ; in Register R0. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- ;+ LIB_GETZE_BYTE ; Return a byte value from a memory location or an indexed array. ; ; value.wlu.v = LIB_GETZE_BYTE( location.ra.r [,index.rl.r] ) ; ; location 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 the byte itself. Passed by ; reference. ; ; value the byte data value is returned as a zero-extended or ; unsigned longword in register R0. Passed by value. ; ;- .ENTRY LIB_GETZE_BYTE,^M MOVB #4,R0 ;Case 4 is get unsigned byte BRB GET_COMMON ;+ LIB_GETZE_WORD ; Return a word value from a memory location or an indexed array. ; ; value.wlu.v = LIB_GETZE_WORD( location.ra.r [,index.rl.r] ) ; ; location 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 the word itself. Passed by ; reference. ; ; value the word data value is returned as a zero-extended or ; unsigned longword in register R0. Passed by value. ; ;- .ENTRY LIB_GETZE_WORD,^M MOVB #5,R0 ;Case 5 is get unsigned word .PAGE .SUBTITLE Common code for all GET routines ; ; This common code determines whether straight or indexed addressing modes ; are to be used to access the data. This decision is based on the presence ; of the index argument (must also be non-defaulted). ; GET_COMMON: MOVL @get_loc(AP),R2 ;Get address of data item CMPB nargs(AP),#num_loc ;Is there an index argument? BLEQ GET_NOTNDX ;If not, use non-indexed addressing TSTL get_ndx(AP) ;Is the index argument defaulted? BEQL GET_NOTNDX ;If so, use non-indexed addressing MOVL @get_ndx(AP),R1 ;Get index value BEQL GET_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 ; GETNDX_BYTE: CVTBL (R2)[R1],R0 ;Get sign-extended byte RET ; GETNDX_WORD: CVTWL (R2)[R1],R0 ;Get sign-extended word RET ; GETNDX_LONG: MOVL (R2)[R1],R0 ;Get longword RET ; GETNDX_QUAD: MOVQ (R2)[R1],R0 ;Get quadword into two registers RET ; GZENDX_BYTE: MOVZBL (R2)[R1],R0 ;Get zero-extended byte RET ; GZENDX_WORD: MOVZWL (R2)[R1],R0 ;Get zero-extended word RET .PAGE .SUBTITLE CASE for non-indexed addressing ; ; CASE for non-indexed addressing for the various data types ; GET_NOTNDX: CASE R0,,- type=B ; GET_BYTE: CVTBL (R2),R0 ;Get sign-extended byte RET ; GET_WORD: CVTWL (R2),R0 ;Get sign-extended word RET ; GET_LONG: MOVL (R2),R0 ;Get longword RET ; GET_QUAD: MOVQ (R2),R0 ;Get quadword into two registers RET ; GZE_BYTE: MOVZBL (R2),R0 ;Get zero-extended byte RET ; GZE_WORD: MOVZWL (R2),R0 ;Get zero-extended word RET .END