.TITLE QSHIFT Quadword Shift ;; ; SUBROUTINE QSHIFT( quadword, amount ) ; ; ; The given quadword is arithmetically shifted by the given amount. ; Examples of quadwords are: ; ; REAL*8 QUAD1 ; INTEGER*4 QUAD2(2) ; INTEGER*2 QUAD3(4) ; BYTE QUAD4(8) ; ; If the quadword is composed of an array, the low-order bits are in ; in the first element. ; ; If the amount is positive, the shift is left, with zeros brought ; into the least significant bits; If the amount is negative, the ; shift is right with copies of the original high-order bit put in ; the most significant bits. ; ; .INDEX ARITHMETIC CONVERSIONS>> ; ; Alan L. Zirkle Naval Surface Weapons Center ; Code K53 ; 29 Oct 1983 Dahlgren, Virginia 22448 ; .PSECT $CODE, LONG,PIC,SHR,EXE,RD,NOWRT .ENTRY QSHIFT, ^M<> ASHQ @8(AP), @4(AP), @4(AP) RET ;; ; INTEGER*4 FUNCTION LBYTE( integer ) ; ; ; Extracts the low-order byte from the INTEGER*4 or INTEGER*2 argu- ; ment INTEGER, and sign extends the value. This allows the value ; to be assigned to a BYTE variable without danger of integer over- ; flow. Examples: ; ; Incorrect: INTEGER*4 I Correct: INTEGER*4 I,LBYTE ; BYTE B BYTE B ; I = 255 I = 255 ; B = I B = LBYTE(I) ; ; .INDEX ARITHMETIC CONVERSIONS>> ; ; Alan L. Zirkle Naval Surface Weapons Center ; Code K53 ; 19 Jan 1986 Dahlgren, Virginia 22448 ; .ENTRY LBYTE,^M<> CVTBL @4(AP),R0 RET .END