.title argx .library 'god$lib:' ;----- ; routine ARGM ; jsb pt. ARGM_R2 ; Builds longword masks to indicate what args were provided. ; and which are non-zero, which were arg greater than ^x200. ; bit0=ap, bit1=p1, etc. ; Routine as function returns non-zero mask. ; author: ; Grec -- 11/23/83 ; arguments: ; p1 = addr of longword to recieve mask (optional) ; p2 = addr of longword to recieve mask (optional) ; jsb arguments: ; r0 = (scratch) --> bitmask: ; r1 = (scratch) --> bitmask: ; r2 = (scratch) --> 0 ; registers: ; r0 = mask: present and nonzero ; r1 = mask: present and > ^x200 ; r2 = arg counter ;+++++ ;----- ; routine ARGN ; jsb pt. ARGN_R0 ; To return the (calling routine's) Nth argument. ; If N=0 or N is not provided, it returns the number of arguments. ; author: ; GOD -- 11/23/83 ; arguments: ; p1 = number of arg to return (defaults to zero) ; jsb arguments: ; r0 = argument number --> argument ; registers: ; r0 = misc. scratch register ;+++++ $sfdef $esect _kcb$code ;----------------------------------------------------------------------------- .subtitle argm .entry argm, ^m pushl ap ; get bitmasks movl sf$l_save_ap(fp), ap bsb argm_r2 popl ap cmpl (ap), #1 ; arg to recieve r0? blss 20$ tstl 4(ap) beqlu 10$ movl r0, @4(ap) 10$: cmpl (ap), #2 ; arg to recieve r1? blss 20$ tstl 8(ap) beqlu 20$ movl r1, @8(ap) 20$: ret ;---------------------- argm_r2:: clrq r0 ; init masks, counter movl (ap), r2 cmpl r2, #31 ; look at only first 31 args blequ 10$ movl #31, r2 10$: tstl (ap)[r2] beqlu 20$ insv #1, r2, #1, r0 ; if non0, set bit in r0 cmpl (ap)[r2], #^x200 blssu 20$ insv #1, r2, #1, r1 ; if >200, set bit in r1 20$: sobgeq r2, 10$ ; loop? rsb ;----------------------------------------------------------------------------- .subtitle argn .entry argn, ^m<> clrl r0 tstl (ap) ; did we get a parameter? beql 10$ movl 4(ap), r0 ; get the parameter cmpl r0, #^x200 ; test it blssu 10$ ; if not a valid address, use it movl (r0), r0 ; else, dereference it 10$: pushl ap movl sf$l_save_ap(fp), ap ; get old ap bsb argn_r0 popl ap ret ;---------------------- argn_r0: cmpl (ap), r0 ; are there really that many args? bgeq 10$ clrl r0 rsb 10$: movl (ap)[r0], r0 ; get the arg rsb ;----------------------------------------------------------------------------- .end