OpenVMS Source Code Demos
PEEK_ANY_INT_VAX.MAR
;--------------------------------------------------------------------------------
; Title : Peek_any_int_vax.mar
; Author : Neil S. Rieck (Waterloo, Ontario, Canada)
; Created: 1999.11.13
;
; Notes:
; 1. This VAX assembly language function peeks into a memory location
; 2. It is tested for use with VAX-BASIC (see peek_demo2.bas)
; 3. parameters are passed here via register ap (argument pointer) a.k.a. r12
; 4. results are returned via r0 (and sometimes r1)
; 5. only 1, 2 or 4 bytes are supported (any other value returns 1 byte)
; 6. support could be easily added for 48 bits (RFA?) and 64 bits (quads)
; 7. since the VAX is a CISC machine, I used a CASE instruction (to show off)
;--------------------------------------------------------------------------------
.entry peek_any_int_vax,^M<> ; function name is PEEK_ANY_INT_VAX (null entry mask)
clrq r0 ; clear both r0 + r1 (cuz q = 64 bit)
movl @4(ap),r2 ; passed parameter #1 is address of data
movl @8(ap),r3 ; passed parameter #2 is desired number of bytes
;
casel r3, #1, #3 ; legal range is 1-4 (table has words 0-3)
CASETBL:
.WORD B1-CASETBL ; if r3 = 1 (then get 1 byte)
.WORD B2-CASETBL ; if r3 = 2 (then get 2 bytes)
.WORD B1-CASETBL ; if r3 = 3 (then get 1 bytes) cuz UNSUPPORTED
.WORD B4-CASETBL ; if r3 = 4 (then get 2 bytes)
brw B1-CASETBL ; ERROR if r3>4 or r3<1
B1: movb (r2),r0 ; do an indirect byte move into r0
brw EXIT
B2: movw (r2),r0 ; do an indirect word move into r0
brw EXIT
B4: movl (r2),r0 ; do an indirect long move into r0
EXIT: ret ; return to calling program
.end
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.