[mod.computers.vax] VERB, bug & fix

js@UW-JUNE.ARPA (Joe Meadows) (06/26/86)

	Well, today someone asked me a simple question, how to
make a foreign command into a real command. The answer follows:
	DEFINE VERB SD	! Set default type of program
		IMAGE UTILITY:SD, CLIFLAGS(FOREIGN)
Well, that works fine, but VERB wouldn't parse it correctly due to an
invalid assumption on my part. I had thought that the Cliflags option
only pertained to CLIROUTINEs. Not IMAGEs.. Oh well, a mistake on my
part. The following replacement for COMMAND.MAR fixes this problem.
	Also, some people apparently haven't got fortran compilers,
so, I was wondering if anyone happened to rewrite VERB.FOR into some other
language, like Macro? (everyones got that one...).
	Another also: I wrote a program to modify file attributes,
(Via ATR subfunction in a QIO call). Anybody want it? It's set up as a
command and can twiddle just about any bit in the header that you want.
If theres enough interest I'll post it. It's uses are many, for one, you
can use it to the equivalent of SET FILE/DIRECTORY (one of those left out
functions), or, perhaps (as I often use it) to fix a backup save set after
sending it through Kermit. (I never remember to set the block size beforehand)
ANyhow, if you do, ask for FILE, it's BASIC and MACRO (It's really not too
horrible, the BASIC is minimal, and, shoot, where I work it is the
only language available to me (THAT is horrible).

*****cut somewhere around here... In, this is a great spot -> . <- *****
	.title print command block

; VERB Version 1.0 June 1st, 1985
; Written  by Joe Meadows Jr.,  with thanks  to the
; Fred Hutchinson Cancer Research Center for kindly
; allowing  me to  use  their  computing  resources.
;
; If  you  have any  questions, comments, ideas, or
; whatever, feel free to contact me via US Mail :
;	Joe Meadows Jr.
;	4841 268th Ave. N.E.
;	Redmond Wa. 98052
; or via phone : (206) 827-7296

	.library 'clexlib'

	.entry	clex_print_command,^m<r2,r3,r4,r5,r6,r7>
	; 4(ap) = address of command block

	movl	4(ap),r6

5$:	bitw	#cmd_m_parms,cmd_w_flags(r6)
	beql	10$
	tstl	cmd_l_parms(r6)
	beql	10$
	addl3	clex_table,cmd_l_parms(r6),-(sp)
	calls	#1,clex_evaluate_entity

10$:	bitw	#cmd_m_quals,cmd_w_flags(r6)
	beql	20$
	tstl	cmd_l_quals(r6)
	beql	20$
	addl3	clex_table,cmd_l_quals(r6),-(sp)
	calls	#1,clex_evaluate_entity

20$:	movzwl	cmd_w_name(r6),r7
	addl	r6,r7
	case	cmd_b_subtype(r6),type=b,limit=#1,<-
		_verb,-
		_syntax>

	movl	#0,r0	; invalid
	ret

_verb:	add_string	<'define verb '>	
	movzbl	(r7),r2	; save size of entire thing
	movzbl	1(r7),r3	; save size of verb name
_verb1:	incl	r7	; point to first ascic
	add_ascic_trunc	r7,r3
	decl	r2	; subtract off extra byte for count byte

	movzbl	(r7),r4	; assume verb bigger than synonym
	cmpb	(r7),r3	; is synonym bigger than verb?
	bleq	_verb2
	movzbl	r3,r4	; if so it got truncated by CDU
	add_string	<'   !! warning, synonym truncated'>
_verb2:	calls	#0,g^put_output
	subb	r4,r2	; subtract off printed portion.
	beql	_verb3

	addl	r4,r7
	tstb	1(r7)
	beql	_verb1	; if zero length string , skip to next.
	add_string	<'   synonym '>
	brb	_verb1
_verb3:	brb	_continue

_syntax:
	add_string	<'define syntax '>
	add_ascic	r7

_continue:
	calls	#0,put_output

	movzwl	cmd_w_image(r6),r7
	addl	r6,r7
	clrl	_clex_handler_flag

	case	cmd_b_handler(r6),type=b,limit=#0,<-
		_print_prefix,-	; no handler
		_handler_cli,-
		_handler_user,-
		_handler_image,-
		_handler_same>
	movl	#0,r0	; invalid handler
	ret

_handler_cli:
	add_string	<'   cliroutine '>
	add_ascic	r7
	brw	_print_cliflags

_handler_user:
	add_string	<'   routine '>
	add_ascic	r7
	brw	_print_cliflags

_handler_image:
	add_string	<'   image '>
	add_ascic	r7
	brw	_print_cliflags

_handler_same:
	movl	#1,_clex_handler_flag
	brw	_print_cliflags

_print_cliflags:
	bitw	#^x1F,cmd_w_flags(r6)	; any cliflags?
	bneq	_cliflags_cli1
	calls	#0,g^put_output
	brw	_print_prefix

_cliflags_cli1:
	clrq	r4
	add_string	<' , cliflags ('>
	moval	table_cli_flags,r3
_cliflags_cli2:
	bbc	r4,cmd_w_flags(r6),_cliflags_cli4
	tstl	r5
	beql	_cliflags_cli3
	add_string	<','>
_cliflags_cli3:
	incl	r5
	add_ascic	(r3)[r4]
_cliflags_cli4:
	aobleq	#4,r4,_cliflags_cli2
	add_string	<')'>
	calls	#0,g^put_output

_print_prefix:
	movzwl	cmd_w_prefix(r6),r7
	beql	_print_parms
	addl	r6,r7
	add_string	<'   prefix '>
	add_ascic	r7
	calls	#0,g^put_output

_print_parms:
	bitw	#cmd_m_parms,cmd_w_flags(r6)
	beql	_print_quals
	tstl	cmd_l_parms(r6)
	bneq	_print_parms_1
	add_string	<'   noparameters'>
	calls	#0,g^put_output
	brb	_print_quals
_print_parms_1:
	addl3	clex_table,cmd_l_parms(r6),-(sp)
	calls	#1,clex_print_entity
_print_quals:	
	bitw	#cmd_m_quals,cmd_w_flags(r6)
	beql	_print_disallows
	tstl	cmd_l_quals(r6)
	bneq	_print_quals_1
	add_string	<'   noqualifiers'>
	calls	#0,g^put_output
	brb	_print_disallows
_print_quals_1:
	addl3	clex_table,cmd_l_quals(r6),-(sp)
	calls	#1,clex_print_entity
_print_disallows:	
	bitw	#cmd_m_disallows,cmd_w_flags(r6)
	beql	_print_outputs
	tstl	cmd_l_disallow(r6)
	beql	_print_outputs
	add_string	<'   disallow '>

	pushl	r6
	addl3	clex_table,cmd_l_disallow(r6),-(sp)
	calls	#2,clex_print_disallows
	calls	#0,g^put_output
	brb	_print_outputs

_print_outputs:
	clrl	r5
	movzwl	cmd_w_outputs(r6),r3	; BRO outputs list
	beql	_end_of_command
	addl	r6,r3			; point to ascic of outputs
	movzbl	(r3),r4	; number of outputs
	beql	_end_of_command	; see if there is indeed any outputs
	incl	r3
	add_string	<'   outputs('>
	brb	_print_continue
_print_out_loop:
	add_string	<','>
_print_continue:
	movb	(r3)[r5],r2
	blss	_print_out_parm
	addl3	clex_table,cmd_l_quals(r6),r7	; r7 is address of first entity
	brb	_get_entity_loop
_print_out_parm:
	mnegb	r2,r2
	addl3	clex_table,cmd_l_parms(r6),r7
_get_entity_loop:
	decb	r2
	beql	_print_this_output
	addl3	clex_table,ent_l_next(r7),r7
	brb	_get_entity_loop
_print_this_output:
	movzwl	ent_w_label(r7),r2
	addl	r7,r2
	add_ascic	r2
	aoblss	r4,r5,_print_out_loop
	add_string	<')'>	
	calls	#0,g^put_output

_end_of_command:
	ret

	.psect	string_table	rd,nowrt,noexe
table_cli_flags:
	string	<'abbreviate'>
	string	<'nostatus'>
	string	<'foreign'>
	string	<'immediate'>
	string	<'mcrparse'>

	.end