[comp.sys.atari.st.tech] Sozobon C fixes for JAS and dlib1.2

nisimura@srava.sra.co.jp (Tohru Nisimura) (11/02/90)

In article <284@aldetec.oz.au>, Clive Salvidge writes;

> I have started using GEMINI and am finding it VERY good BUT (and this is
> a big BUT)
> ....
> ....
> SO, is there somewhere in netland, a set of sozobon bins that all work with
> GEMINI, or a set of sources and instructions....

I have never played with GEMINI yet, thus I'm not sure this helps you.

Here is fixes to
	o Sozobon Assembler, jas 1.1 .
	o some routines in dlib1.2 .

Sozobon assembler sometimes produces incorrect codes for bit instructions;
bchg, bclr, bset, btst.

For example, in the case of "btst #4, d0", Sozobon asm would produce
        +----------------------------+
        |     BTST   d0              |
        +----------------------------+
        |             0              |
        +----------------------------+
        |      0      | bit number=4 |
        +----------------------------+
instead of
        +----------------------------+
        |     BTST   d0              |
        +----------------------------+
        |      0      | bit number=4 |
        +----------------------------+

The bit number word that shifted would be interpreted as a corrupted
branch inst. (WAO !!)

The bug exists in "opcodes.h"
the definition of btst is not correct.

{"btst$s",      O_IMM,  O_DN,   S_L,    "x0o40%1e",     F_L },
                                                        ^^^
                                                        F_B

the last field says "its immediate value should be coded in LONG."

Originally bit-instruction does have no size field.
Its operation size is implied by its second operand; data register
or memory data.

I changed "opcodes.h" table so as bit instructions must not have
size specifiers  and their default sizes are F_B.


Also, some dlib1.2 routines have bugs.  Worst one is in bzero.s. 
bzero would make bombs in many cases.  Fixes to them are simple.

Try to apply following patches, and recompile your jas and dlib1.2.


Tohru Nishimura
Software Research Associates, Tokyo, Japan
Internet: nisimura@sra.co.jp

---------- >8 -------------------------- 8< --------

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	jas.dif
#	dlib.dif
# This archive created: Fri Nov  2 11:52:45 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'jas.dif'
then
	echo shar: "will not over-write existing file 'jas.dif'"
else
cat << \SHAR_EOF > 'jas.dif'
*** opcodes.h	Sat Jun  9 18:45:56 1990
--- /tmp/opcodes.h	Tue Sep 18 11:58:17 1990
***************
*** 40,63 ****
  {"as$d$s",	O_DN,	O_DN,	S_BWL,	"xe%r$d$so4%1r",F_W },
  {"as$d$s",	O_IMM,	O_DN,	S_BWL,	"xe%q$d$so0%1r",F_W },
  {"as$d$s",	O_DMEM,	O_NONE,	S_W,	"xeo0$d11%e",	F_W },
! {"bchg$s",	O_DN,	O_DN,	S_L,	"x0%ro5%1e",	F_L },
! {"bchg$s",	O_DN,	O_DMEM,	S_B,	"x0%ro5%1e",	F_B },
! {"bchg$s",	O_IMM,	O_DN,	S_L,	"x0o41%1e",	F_L },
! {"bchg$s",	O_IMM,	O_DMEM,	S_B,	"x0o41%1e",	F_B },
! {"bclr$s",	O_DN,	O_DN,	S_L,	"x0%ro6%1e",	F_L },
! {"bclr$s",	O_DN,	O_DMEM,	S_B,	"x0%ro6%1e",	F_B },
! {"bclr$s",	O_IMM,	O_DN,	S_L,	"x0o42%1e",	F_L },
! {"bclr$s",	O_IMM,	O_DMEM,	S_B,	"x0o42%1e",	F_B },
  {"bra$s",	O_LAB,	O_NONE,	S_BW,	"x60%d",	F_PC|F_TXT },
! {"bset$s",	O_DN,	O_DN,	S_L,	"x0%ro7%1e",	F_L },
! {"bset$s",	O_DN,	O_DMEM,	S_B,	"x0%ro7%1e",	F_B },
! {"bset$s",	O_IMM,	O_DN,	S_L,	"x0o43%1e",	F_L },
! {"bset$s",	O_IMM,	O_DMEM,	S_B,	"x0o43%1e",	F_B },
  {"bsr$s",	O_LAB,	O_NONE,	S_BW,	"x61%d",	F_PC|F_TXT },
! {"btst$s",	O_DN,	O_DN,	S_L,	"x0%ro4%1e",	F_L },
! {"btst$s",	O_DN,	O_MEM,	S_B,	"x0%ro4%1e",	F_B },
! {"btst$s",	O_IMM,	O_DN,	S_L,	"x0o40%1e",	F_L },
! {"btst$s",	O_IMM,	O_MEM,	S_B,	"x0o40%1e",	F_B },
  {"chk$s",	O_NAN,	O_DN,	S_W,	"x4%1ro6%e",	F_W },
  {"clr$s",	O_AN,	O_NONE,	S_W,	"x9%ro3%e",	F_W },
  {"clr$s",	O_AN,	O_NONE,	S_L,	"x9%ro7%e",	F_W },
--- 40,63 ----
  {"as$d$s",	O_DN,	O_DN,	S_BWL,	"xe%r$d$so4%1r",F_W },
  {"as$d$s",	O_IMM,	O_DN,	S_BWL,	"xe%q$d$so0%1r",F_W },
  {"as$d$s",	O_DMEM,	O_NONE,	S_W,	"xeo0$d11%e",	F_W },
! {"bchg$s",	O_DN,	O_DN,	0,	"x0%ro5%1e",	F_B },
! {"bchg$s",	O_DN,	O_DMEM,	0,	"x0%ro5%1e",	F_B },
! {"bchg$s",	O_IMM,	O_DN,	0,	"x0o41%1e",	F_B },
! {"bchg$s",	O_IMM,	O_DMEM,	0,	"x0o41%1e",	F_B },
! {"bclr$s",	O_DN,	O_DN,	0,	"x0%ro6%1e",	F_B },
! {"bclr$s",	O_DN,	O_DMEM,	0,	"x0%ro6%1e",	F_B },
! {"bclr$s",	O_IMM,	O_DN,	0,	"x0o42%1e",	F_B },
! {"bclr$s",	O_IMM,	O_DMEM,	0,	"x0o42%1e",	F_B },
  {"bra$s",	O_LAB,	O_NONE,	S_BW,	"x60%d",	F_PC|F_TXT },
! {"bset$s",	O_DN,	O_DN,	0,	"x0%ro7%1e",	F_B },
! {"bset$s",	O_DN,	O_DMEM,	0,	"x0%ro7%1e",	F_B },
! {"bset$s",	O_IMM,	O_DN,	0,	"x0o43%1e",	F_B },
! {"bset$s",	O_IMM,	O_DMEM,	0,	"x0o43%1e",	F_B },
  {"bsr$s",	O_LAB,	O_NONE,	S_BW,	"x61%d",	F_PC|F_TXT },
! {"btst$s",	O_DN,	O_DN,	0,	"x0%ro4%1e",	F_B },
! {"btst$s",	O_DN,	O_MEM,	0,	"x0%ro4%1e",	F_B },
! {"btst$s",	O_IMM,	O_DN,	0,	"x0o40%1e",	F_B },
! {"btst$s",	O_IMM,	O_MEM,	0,	"x0o40%1e",	F_B },
  {"chk$s",	O_NAN,	O_DN,	S_W,	"x4%1ro6%e",	F_W },
  {"clr$s",	O_AN,	O_NONE,	S_W,	"x9%ro3%e",	F_W },
  {"clr$s",	O_AN,	O_NONE,	S_L,	"x9%ro7%e",	F_W },
SHAR_EOF
fi
if test -f 'dlib.dif'
then
	echo shar: "will not over-write existing file 'dlib.dif'"
else
cat << \SHAR_EOF > 'dlib.dif'
*** alloca.s	Sat Jun  9 18:52:51 1990
--- /tmp/alloca.s	Fri Nov  2 11:49:26 1990
***************
*** 27,32 ****
--- 27,34 ----
  	move.l	(sp),a1			* save return address
  	clr.l	d1			* get requested block size
  	move.w	4(sp),d1
+ 	addq.l	#1,d1
+ 	bclr	#0,d1			* round up to even value
  	move.l	sp,a0			* calculate new sp
  	sub.l	d1,a0
  	cmp.l	__break,a0		* if (new sp < __break)
*** bzero.s	Sat Jun  9 18:52:54 1990
--- /tmp/bzero.s	Fri Nov  2 10:47:39 1990
***************
*** 7,14 ****
  _bzero:
  	move.l	4(a7),a0	; destination
  	clr.l	d1
! 	move.l	8(a7),d1	; number of bytes
! 	move.l	a1,d0
  	btst	#0,d0		; odd alignment?
  	beq	bzero0
  	clr.b	(a0)+		; zero first byte
--- 7,14 ----
  _bzero:
  	move.l	4(a7),a0	; destination
  	clr.l	d1
! 	move.w	8(a7),d1	; number of bytes
! 	move.l	a0,d0
  	btst	#0,d0		; odd alignment?
  	beq	bzero0
  	clr.b	(a0)+		; zero first byte
*** memcpy.s	Sat Jun  9 18:53:08 1990
--- /tmp/memcpy.s	Fri Nov  2 10:48:10 1990
***************
*** 9,15 ****
  	move.l	4(a7),a1	; destination
  	move.l	8(a7),a0	; source
  	clr.l	d1
! 	move.l	12(a7),d1	; number of bytes
  	move.l	a1,d0
  	btst	#0,d0		; odd alignment?
  	beq	memcpy0
--- 9,15 ----
  	move.l	4(a7),a1	; destination
  	move.l	8(a7),a0	; source
  	clr.l	d1
! 	move.w	12(a7),d1	; number of bytes
  	move.l	a1,d0
  	btst	#0,d0		; odd alignment?
  	beq	memcpy0
SHAR_EOF
fi
exit 0
#	End of shell archive