[comp.sys.amiga] Interesting guru using Blink..

jonasf@kuling.UUCP (Jonas Flygare) (09/30/88)

One of my friends told me the other day he couldn't link a program he
wrote, because Blink would guru on the object file. I didn't believe him
so he gave me a copy, and sure enough, my blink (2.7, the one that came 
with Lattice C, vers 4.0) also gave up on the file.
All I could make of it was that Blink guru's somewhere in pass two on
the file. I enclose a shar script with the source, and a uuencoded copy
of the object file. Source is assembly language, assembler used is
asm (Lattice 4.0 version).
I suspect there are some errors in the source, and if you like to pointe 
them out in email, I'll forward them. (He claims it is his first attempt to
do serious programming on his Amy.. And he *refuses* to use C.. :-)
But apart from that, I am ratehr surprised at the guru, I would expect 
Blink to come up with an error message, and then abort linking..
Whoever out there makes Blink tick, and run, is this a bug??



/* If you don't like the guru, don't link the object file below... */
-------------------------------------CUT HERE ---------------------------
: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting xassign.asm'
sed 's/^X//' > xassign.asm << '+ END-OF-FILE xassign.asm'
X**************************************************************************
X* XASSIGN.ASM - this program will read a file (default s:logical-names)
X*  and add the logical names found there (1/line) to the assign list.
X*  Comments may be included in the file using #
X*
X*   Version	By	Date	    Comments
X*   ======================================================================
X*   0.10	hakant	880919	    First version, Blink barfs..
X*
X**************************************************************************
X
X	ttl	    "xassign"
X
X	section     "main",code
X
XCOMMENT_CHAR	    equ     '#'             use this char for comments
X
X	include     "libraries/dos_lib.i"
X	include     "exec/funcdef.i"
X	include     "exec/exec_lib.i"
X	include     "libraries/arpbase.i"
X	include     "macros.i"
X
X***************************************************************************
X* Normal startup code follows..we may only launch from the CLI at the
X* moment...
X
X	OpenARP 		    open up the arp library
X	movem.l a0/d0,-(sp)
X***************************************************************************
X* Now open dos_lib..
X	move.l	#0,d0		    open any available version
X	move.l	#dos_name,a0	    pointer to name
X	sys	OpenLibrary,AbsExecBase     open the library
X	tst.l	d0		    opened?
X	beq	pr_doslib_error     dos library error
X	move.l	d0,dos_lib	    remember the library pointer
X
X	move.l	#helpstr,a1	    extra helpstring if user wants it
X	move.l	#argarray,a2	    the argument array
X	move.l	#tplate,a3	    template for the function
X	sys	GADS		    parse the input string
X	cmp.l	#1,d0		    is there one argument?
X	bne	pr_int_error	    no, (this should not be possible)
X
X***************************************************************************
X* Ok, the first argument in argarray now points to the file with
X* the assignments, open it.
X	move.l	argarray,d1	    point to the filename
X	move.l	MODE_OLDFILE,d2     we only want to read it..
X	sys	ArpOpen 	    open the file and track it
X	tst.l	d0		    was the file opened?
X	beq	pr_file_error	    no
X	move.l	d0,file 	    store the filepointer (for read)
X
X***************************************************************************
X* File successfully opened, now parse each line in it.
Xparse_lines
X	bsr	readline	    read a line (skips comments etc)
X	move.l	#buffer,a1	    now fix the line for assign
X1$:	move.b	(a1),d0
X	cmp.b	#SPACE,d0
X	bne	2$		    not end of word yet
X	move.b	#0,(a1)+            set string end
X	bra	3$		    done
X2$:	add	#1,a1
X	bra	1$
X
X3$:	move.l	#buffer,a0
X	move.l	a0,-(sp)
X	sys	Assign		    make the assign!
X	move.l	(sp)+,a0
X	cmp.l	#ASSIGN_OK,d0
X	beq	parse_lines	    done with this one..
X
X***************************************************************************
X* Some kind of error with the assign..
X* At the moment the following error is known:
X* ASSIGN_NODEV - Physical not valid
X* ASSIGN_FATAL - Something really icky!
X* ASSIGN_CANCEL - Tried to cancel something that won't cancel
X*
X* Howewer, we use a simple error report, we just print some general error
X* and the assign pair..
X	move.l	a0,-(sp)            remember the string we tried to assign
X	move.l	#assign_error,a1
X	sys	Puts		    print the string in a0
X	move.l	(sp)+,a1
Xpr_error
X	sys	Puts
X	move.l	#RETURN_ERROR,d0    only return an error, no cause..
X	bra	exit
X
Xpr_int_error			    *internal error
X	move.l	#int_error,a1
X	sys	Puts
X	move.l	#RETURN_FAIL,d0     severe failure
X	bra	exit
X
Xpr_file_error			    *file open error
X	move.l	#file_error,a1
X	bra	pr_error
X
Xpr_read_error
X	move.l	#read_error,a1
X	bra	pr_error
X
Xpr_doslib_error
X	move.l	#doslib_error,a1
X	sys	Puts
X	move.l	#RETURN_FAIL,d0
X	sys	ArpExit
X
Xctrl_c	sys	Puts		    print ***break
X	bra	done		    end
X
X***************************************************************************
X* readline - read a line from file to buffer, skipping empty lines
X*  and comment lines. If file empty, return with OK.
Xreadline
X	move.l	#ctrl_c,a1	    function to call if ctrl_c
X	sys	CheckAbort	    check if ctrl_c
X	move.l	#buffer,a0	    buffer pointer
X1$:	move.l	a0,-(sp)
X	jsr	getchar 	    get a character to d0.b
X	cmp.b	#LF,d0		    end of line?
X	beq	2$		    yes, done
X	move.b	d0,(a0)+
X	bra	1$
X2$:	move.b	#0,(a0)             put a endpointer
X	move.b	buffer,d0	    look at the first char in line
X	tst.b	d0		    end of line?
X	beq	readline	    yes, nothing read, try next line
X	cmp.b	#COMMENT_CHAR,d0    is it a comment line?
X	beq	readline	    yes, try next line
X	rts
X
X***************************************************************************
X* getchar - read a character from file, if end of file return OK and exit.
Xgetchar move.l	file,d1
X	move.l	#buffer,d2
X	move.l	#1,d3		    read only one char
X	sys	Read,dos_lib	    read a char (using dos_lib)
X	tst.l	d0		    end of file reached
X	beq	done
X	cmp.l	#-1,d0		    some kind of error?
X	beq	pr_read_error	    yes
X	move.b	buffer,d0	    return answer in d0.b
X	rts
Xdone	move.l	#RETURN_OK,d0
X
X* Exit here if dos library was opened
Xexit	move.l	dos_lib,a1
X	sys	CloseLibrary,AbsExecBase
X	sys	ArpExit
X
X	section "More",data
X
Xdos_lib dc.l	0		    pointer to dos library
X
Xfile	dc.l	0		    filepointer (BCPL .. no comments)
X
Xargarray
X	dc.l	0		    only one argument possible
Xhelpstr dc.b	'Takes file with assignments as argument.',0
Xtplate	dc.b	'File/A',0
X
Xdos_name
X	dosname 		    dos library name
X
X***************************************************************************
X* int_error - this string will be printed if some strange error that
X*  shouldn't be possible, ie there is some kind of bug somewhere...
Xint_error
X	dc.b	'Internal error! Probably due to some bug...sorry..',0
X
Xassign_error
X	dc.b	'Couldn''t assign this one',0
X
Xcmdline_error
X	dc.b	'Error in command line.',0
X
Xfile_error
X	dc.b	'File error',0
X
Xread_error
X	dc.b	'Error while reading file',0
X
Xdoslib_error
X	dc.b	'Error in dos library',0
X
Xbuffer	ds.b	256		    readbuffer
X
X	end
X
X
+ END-OF-FILE xassign.asm
chmod 'u=rw,g=rw,o=r' 'xassign.asm'
echo '	-rw-rw-r--  1 jonasf       5807 Sep 29 19:52 xassign.asm        (as sent)'
echo -n '	'
/bin/ls -l xassign.asm
echo 'Extracting macros.i'
sed 's/^X//' > macros.i << '+ END-OF-FILE macros.i'
X*************************************************************************
X* Macros.i -- Useful macro definition collection
X*************************************************************************
X
XSYS	MACRO	*
X	IFGT	NARG-2
X	    FAIL    !!! Too many arguments !!!
X	ENDC
X	IFEQ	NARG-2
X	    move.l  a6,-(sp)
X	    move.l  \2,a6
X	    jsr     _LVO\1(a6)
X	    move.l  (sp)+,a6
X	else
X	    JSR     _LVO\1(a6)
X	endc
X	ENDM
X
XXLIB	MACRO	*
X	XREF	_LVO\1
X	ENDM
X
Xblink	macro
X	bchg.b	#1,$bfe001
X	endm
X
X*************************************************************************
X* push - push register(s) on stack
X* pop - removes register(s) from stack
X*************************************************************************
Xpush	macro	*
X	ifeq	NARG
X	fail
X	endc
X	ifgt	NARG
X	move.l	\1,-(sp)
X	endc
X	ifgt	NARG-1
X	move.l	\2,-(sp)
X	endc
X	ifgt	NARG-2
X	move.l	\3,-(sp)
X	endc
X	ifgt	NARG-3
X	move.l	\4,-(sp)
X	endc
X	ifgt	NARG-4
X	move.l	\5,-(sp)
X	endc
X	ifgt	NARG-5
X	move.l	\6,-(sp)
X	endc
X	endm
X
Xpop	macro	*
X	ifeq	NARG
X	fail
X	endc
X	ifgt	NARG
X	move.l	(sp)+,\1
X	endc
X	ifgt	NARG-1
X	move.l	(sp)+,\2
X	endc
X	ifgt	NARG-2
X	move.l	(sp)+,\3
X	endc
X	ifgt	NARG-3
X	move.l	(sp)+,\4
X	endc
X	ifgt	NARG-4
X	move.l	(sp)+,\5
X	endc
X	ifgt	NARG-5
X	move.l	(sp)+,\6
X	endc
X	endm
X
XAbsExecBase equ 4	    can't find it anywhere..
X
X***************************************************************************
X* Define some useful ascii constants
XSPACE	EQU	' '
XLF	EQU	$0a
XCR	EQU	$0d
X
X
X***************************************************************************
X* OpenARP - open ARP library.
X*
X* Use this macro to open arp.library and avoid recoverable alerts.
X* Saves D0/A0 on stack.
X* After executing, A6 = ARPBASE and stack points at D0/A0
X*
XOpenARP MACRO
X	movem.l d0/a0,-(sp)
X	move.l	AbsExecBase,A6
X	lea.l	ARPNAME,a1		; Get ArpBase
X	move.l	#ArpVersion,d0
X	sys	OpenLibrary
X	tst.l	d0
X	bne	okgo			opened ok!
X
X	lea	dname,A1
X	sys	OpenLibrary
X	tst.l	D0
X	beq	_foo
X	move.l	D0,A6
X	sys	Output			;standard output file handle
X	move.l	d0,d1
X	beq	_foo			; No output. Phoey.
X	move.l	#alibmsg,d2		;tell user he needs to find library
X	move.l	#aliblng,d3
X	sys	Write
X_foo:	add.l	#8,sp
X	rts
X
Xdname	dc.b	'dos.library',0
Xalibmsg dc.b	'you need '
XARPNAME:	ArpName
X	dc.b	' V33+',$a
Xaliblng equ	*-alibmsg
X	ds.w	0
Xokgo:	move.l	D0,A6
X	ENDM
X
X
X
+ END-OF-FILE macros.i
chmod 'u=rw,g=rw,o=r' 'macros.i'
echo '	-rw-rw-r--  1 jonasf       2251 Sep 29 19:54 macros.i        (as sent)'
echo -n '	'
/bin/ls -l macros.i
echo 'Extracting gegga.uu'
sed 's/^X//' > gegga.uu << '+ END-OF-FILE gegga.uu'
X
X(207297) 88-09-27  19.10 /34 rader/ H}kan (3@) Th|rngren (Fick ingen Pan Galactic Gargle Blaster)
XMottagare: Amiga Erfarenhetsutbyte.
XKommentar till: 207280 av Jonas (Emir) Flygare (Dvl / FKCE)
XMarkerad av: Jonas (Emir) Flygare (Dvl / FKCE)
X[rende:  BLink
X------------------------------------------------------------
XOk h{r har du geggan som Blink barfar p}...
X
Xbegin 644 xassign.o
XM```#YP````)X87-S:6=N`````^@````!;6%I;@```^D```!Z2.>`@"QY````T
XM!$/Y````87`B3J[]V$J`9@``VT/Y````3$ZN_=A*@&<``!XL0$ZN_\0B`&<`K
XM`!(D/````%@F/````%Q.KO_04$].=61O<RYL:6)R87)Y`'EO=2!N965D(&%RJ
XM<"YL:6)R87)Y`"!6,S,K"BQ`2.>`@'``('P````\+PXL>0````1.KOW8+%]*3
XM@&<``+0CP``````B?`````PD?`````@F?````#5.KO\$#(`````!9@``;B(YB
XM````""0Y```#[4ZN_G1*@&<``&@CP`````1A``"&(GP```#D$!$,```@9@``?
XM"A+\``!@```(TOP``6#H('P```#D+PA.KOZP(%\,@`````!GR"\((GP```!["
XM3J[_$")?3J[_$'`*8```JB)\````2$ZN_Q!P%&```)HB?````*M@WB)\````O
XMMF#6(GP```#/3J[_$'`43J[^ADZN_Q!@``!P(GP```'93J[^\B!\````Y"\(>
XM3KD```(;#```"F<```80P&#L$+P``!`Y````Y$H`9\X,```C9\A.=2(Y````W
XM!"0\````Y'8!+PXL>0````!.KO_6+%]*@&<``!0,@/____]G`/]\$#D```#D9
XM3G5P`")Y`````"\.+'D````$3J[^8BQ?3J[^A@````/L````!0````````%S#
XM```!80```#H````>````#````!4````!```!T0```<<```&K```!H0```9L`@
XM``&)```!:P```4D```%!```!.0```2D```$3````^P```-T```#3````O0``B
XM`*D```"C````G0```)<```!]`````````_(```/H`````4UO<F4```/J````>
XM>0```````````````%1A:V5S(&9I;&4@=VET:"!A<W-I9VYM96YT<R!A<R!A.
XM<F=U;65N="X`1FEL92]!`&1O<RYL:6)R87)Y`$EN=&5R;F%L(&5R<F]R(2!0A
XM<F]B86)L>2!D=64@=&\@<V]M92!B=6<N+BYS;W)R>2XN`$-O=6QD;B=T(&%S7
XM<VEG;B!T:&ES(&]N90!%<G)O<B!I;B!C;VUM86YD(&QI;F4N`$9I;&4@97)R*
XM;W(`17)R;W(@=VAI;&4@<F5A9&EN9R!F:6QE`$5R<F]R(&EN(&1O<R!L:6)R.
XM87)Y````````````````````````````````````````````````````````,
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XG``````````````````````````````````````````````````/RU
X``
Xend
Xsize 1164
X
X
+ END-OF-FILE gegga.uu
chmod 'u=rw,g=rw,o=r' 'gegga.uu'
echo '	-rw-rw-r--  1 jonasf       2070 Sep 29 19:54 gegga.uu        (as sent)'
echo -n '	'
/bin/ls -l gegga.uu
exit 0
-- 
Jonas Flygare (aka Flax)         +------------------------------------------+
email: jonasf@kuling.UUCP        | "Never try to hack while a playful ferret |
real:  Vaktargatan 32 F:621      |  is watching your toes.                  |
       S-754 22 Uppsala Sweden   +-------- I TRIED....... OUCH! ------------+ 

jonasf%kuling.uucp@UDEL.EDU (10/04/88)

Received: from CUNYVM by CUNYVM.BITNET (Mailer X2.00) with BSMTP id 3960; Sat,
 01 Oct 88 23:12:08 EDT
Received: from UDEL.EDU by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with TCP; Sat, 01
 Oct 88 23:12:02 EDT
Received: from Louie.UDEL.EDU by Louie.udel.EDU id ab00572; 1 Oct 88 19:14 EDT
Received: by Louie.UDEL.EDU id ak00423; 1 Oct 88 19:07 EDT
Received: from USENET by Louie.UDEL.EDU id aa06454; 1 Oct 88 18:37 EDT
From: Jonas Flygare <jonasf@kuling.uucp>
Subject: Interesting guru using Blink..
Message-ID: <834@kuling.UUCP>
Date: 29 Sep 88 19:26:16 GMT
Followup-To: comp.sys.amiga
Organization: Dep. of Computer Systems, Upsala University, Sweden
To:       amiga-relay@UDEL.EDU
Sender:   amiga-relay-request@UDEL.EDU

One of my friends told me the other day he couldn't link a program he
wrote, because Blink would guru on the object file. I didn't believe him
so he gave me a copy, and sure enough, my blink (2.7, the one that came
with Lattice C, vers 4.0) also gave up on the file.
All I could make of it was that Blink guru's somewhere in pass two on
the file. I enclose a shar script with the source, and a uuencoded copy
of the object file. Source is assembly language, assembler used is
asm (Lattice 4.0 version).
I suspect there are some errors in the source, and if you like to pointe
them out in email, I'll forward them. (He claims it is his first attempt to
do serious programming on his Amy.. And he *refuses* to use C.. :-)
But apart from that, I am ratehr surprised at the guru, I would expect
Blink to come up with an error message, and then abort linking..
Whoever out there makes Blink tick, and run, is this a bug??



/* If you don't like the guru, don't link the object file below... */
-------------------------------------CUT HERE ---------------------------
: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting xassign.asm'
sed 's/^X//' > xassign.asm << '+ END-OF-FILE xassign.asm'
X**************************************************************************
X* XASSIGN.ASM - this program will read a file (default s:logical-names)
X*  and add the logical names found there (1/line) to the assign list.
X*  Comments may be included in the file using #
X*
X*   Version    By    Date        Comments
X*   ======================================================================
X*   0.10    hakant    880919        First version, Blink barfs..
X*
X**************************************************************************
X
X    ttl        "xassign"
X
X    section     "main",code
X
XCOMMENT_CHAR        equ     '#'             use this char for comments
X
X    include     "libraries/dos_lib.i"
X    include     "exec/funcdef.i"
X    include     "exec/exec_lib.i"
X    include     "libraries/arpbase.i"
X    include     "macros.i"
X
X***************************************************************************
X* Normal startup code follows..we may only launch from the CLI at the
X* moment...

d88_pata@tekn01.chalmers.se (PATRIK PETTERSSON) (10/06/88)

In article <834@kuling.UUCP>, jonasf@kuling.UUCP (Jonas Flygare) writes:
> One of my friends told me the other day he couldn't link a program he
> wrote, because Blink would guru on the object file. I didn't believe him
> so he gave me a copy, and sure enough, my blink (2.7, the one that came 
> with Lattice C, vers 4.0) also gave up on the file.
> All I could make of it was that Blink guru's somewhere in pass two on
> the file. I enclose a shar script with the source, and a uuencoded copy
> of the object file. Source is assembly language, assembler used is
> asm (Lattice 4.0 version).
> I suspect there are some errors in the source, and if you like to pointe 
> them out in email, I'll forward them. (He claims it is his first attempt to
> do serious programming on his Amy.. And he *refuses* to use C.. :-)
> But apart from that, I am ratehr surprised at the guru, I would expect 
> Blink to come up with an error message, and then abort linking..
> Whoever out there makes Blink tick, and run, is this a bug??
> 

This is exactly the same problem I had, some time ago. I were linking several
small assembler-generated objectfiles with Blink, when suddenly it Gurued!
After many, many frustrating hours of testing and reassembling, I finally
saw a pattern. It appeared to have something to do with the length of the
different hunks in the objectfile. I don't recall the exact reason, but I do
remember that it had something to do with alignment. 
Of, course Blink should *never* guru, but this time it is due to bad programming
practice. The key-issue is how your friend declares strings.
He uses the fast-and-ugly method:  dc.b 'Text',0
The proper way to declare strings in assembler on the Amiga is as follows:

	.
	.
	.
		INCLUDE "exec/strings.i"
	.
	.
	.

	.
	.
	Label:	STRING 'The text'
	.
	.

This trick saved my day. Hopefully it will save your friend's too!

	Patrik Pettersson
	Chalmers University Of Technology
	Sweden