[comp.sys.nsc.32k] Summer Project time

dlr@daver.bungi.com (Dave Rand) (05/28/91)

Just to keep everyone from total boredom during the summer, here is
the complete kit for the MIPS-O-METER! Now you can _really_ see how
many mips you are getting on your programs! It autoscales (from KIPS
to MIPS)! It slices! It dices! 

Source for the 8051 is included, as well as the binary image for
the rom. A parts list, and wirelist, is included. Have fun!

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  mips mips.asm mips.obj.uue
# Wrapped by dlr@daver on Mon May 27 17:37:50 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'mips' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mips'\"
else
echo shar: Extracting \"'mips'\" \(4010 characters\)
sed "s/^X//" >'mips' <<'END_OF_FILE'
XBelow is the wire list and bom file for the mips-o-meter.
X
XThe LCD panel is one of the generic 14 pin interface units with a Hitachi
Xcontroller built on. Just about every LCD manufacturer has such beasts.
XWe used an 8 character unit - with EL backlight (blue). Looks very impressive
Xin low light. Full price for just the panel and controller is around $15
Xor so, cheaper at surplus places.
X
XThe /PFSD signal is the /PFS divided by 4096. I soldered a 74HCT4040 in the
Xspare position near the FPU and ran a wire from /PFS (on the solder side of
Xthe CPU socket) to the clock input of the divider. Remember to wire the
Xactive high reset of the 4040 to ground. Then take the /4096 output to a
Xserial connector (long blue wire...). I used CONN10, pin 10 (currently an
Xunused pin) as the comms to the mips-o-meter. I removed the rs232 transceiver
Xand plugged in a straight header - connecting pins 2-15, 3-14, 4-13, 5-12,
X6-11, 7-10.  This runs TTL serial to the mips-o-meter which is fine for the
Xshort length from the pc532 to a blank drive slot where it is mounted. Also,
Xyou will have to solder +5 to the back of CONN10 pin 2 (currently an unused
Xpin).
X
X
X----------------------------------------------------------------------------
XBILL OF MATERIALS   PC532 MIPS-OMETER   V 1A Mon Oct 08 20:02:51 1990   1
X----------------------------------------------------------------------------
X
X  ITEM     QUAN.              DESCRIPTION                	   REF. DES.
X
X    1       1  87C51 - 8 BIT MICROCOMPUTER                             U1
X
X    2       1  CAPACITOR,0.1,                                          C5
X
X    3       2  CAPACITOR,10UF                                          C3,C4
X
X    4       2  CAPACITOR,30PF,                                         C1,C2
X
X    5       1  CRYSTAL, 12MHZ                                          XTAL1
X
X    6       1  HDR10 - 10 WAY PCB HEADER                               CONN1
X
X    7       1  LCD14 - 14 PIN STRAIGHT HEADER FOR LCD PANEL            LCD1
X
X    8       1  RESISTOR,1K,                                            R3
X
X    9       1  RESISTOR,4K7,                                           R2
X
X   10       1  RESISTOR,8K2,                                           R1
X
X
X---------------------------------------------------------------------------
X  WIRE LIST                    Mon Oct 08 19:57:55 1990          PAGE  1
X  532 MIPS METER  		REV 1A 901008
X---------------------------------------------------------------------------
X
X
X1        +5             C3-1           C4-1           C5-1           
X                        CONN1-2        LCD1-2         R2-1           
X                        U1-31          U1-40          
X
X2        /CTS           CONN1-6        U1-24          
X
X3        /EN            LCD1-6         U1-21          
X
X4        /PFSD          CONN1-10       U1-12          
X
X5        /WR            LCD1-5         U1-22          
X
X6        01012024       C3-2           R1-1           U1-9           
X
X7        01019011       C1-1           U1-19          XTAL1-1        
X
X8        01023015       C2-1           U1-18          XTAL1-2        
X
X9        01058014       LCD1-3         R2-2           R3-1           
X
X10       GND            C1-2           C2-2           C4-2           
X                        C5-2           CONN1-9        LCD1-1         
X                        R1-2           R3-2           U1-20          
X
X11       LCD0           LCD1-7         U1-1           
X
X12       LCD1           LCD1-8         U1-2           
X
X13       LCD2           LCD1-9         U1-3           
X
X14       LCD3           LCD1-10        U1-4           
X
X15       LCD4           LCD1-11        U1-5           
X
X16       LCD5           LCD1-12        U1-6           
X
X17       LCD6           LCD1-13        U1-7           
X
X18       LCD7           LCD1-14        U1-8           
X
X19       RS             LCD1-4         U1-23          
X
X20       RXD            CONN1-5        U1-10          
X
X21       TXD            CONN1-3        U1-11          
X
END_OF_FILE
if test 4010 -ne `wc -c <'mips'`; then
    echo shar: \"'mips'\" unpacked with wrong size!
fi
# end of 'mips'
fi
if test -f 'mips.asm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mips.asm'\"
else
echo shar: Extracting \"'mips.asm'\" \(7187 characters\)
sed "s/^X//" >'mips.asm' <<'END_OF_FILE'
X;
X; MIPS-o-meter source code
X; Initial version October 5, 1991
X;
X; Version 1.01  Mon May 27 17:14:58 1991
X;
X; George Scolaro / Dave Rand
X; 941 Chehalis Drive
X; Sunnyvale CA  94087
X;
X; george@wombat.bungi.com, dlr@daver.bungi.com
X;
X; This code allows you to monitor the real-time MIPS rating of the NS32532.
X; Externally, we use a divide by 4096 from the /PFS (Program Flow Status)
X; pin of the NS32532 to get a regular count of the instructions. Once per
X; second, the current count is converted to a KIPS or MIPS rating, and 
X; displayed on the attached LCD panel. It is possible to add additional
X; features to this code, so that the serial line can be used to display
X; messages on the LCD panel, or pass the current MIPS rating back to
X; the PC532 once per second.
X; 
X
X		.equ	countl,0x40	; count low
X		.equ	counth,0x41	; count high
X		.equ	curl,0x42	; current (working) count
X		.equ	curh,0x43	; current (working) count
X		.equ	res,0x44	; output result
X		.equ	res1,0x45	; output result
X		.equ	res2,0x49	; output result
X		.equ	b,0xf0		; point to B register
X		.equ	TIME1,-(1000)	; 1000 usec per tick
X		.equ	ti1l,0x19	; low part of time 1
X		.equ	ti1h,0xfc	; high part of time 1
X;		.equ	P2.0,P2.0	; LCD E pin
X;		.equ	P2.1,P2.1	; LCD RW pin
X;		.equ	P2.2,P2.2	; LCD RS pin
X
X		.org	0
Xstart:		ajmp	main		; jump to mainline
X		.org	3
X		ajmp	int0svc		; service interrupt 0
X		.org	0x0b		; timer interrupt
X		ajmp	tc0int		; service timer 0 inte
X
X		.org	0x23		; serial handler
X		reti			; just return
X
Xint0svc:	push 	PSW
X		inc	r6		;increment countlow
X		cjne	r6,#0,int0x	; exit if no overflow
X		inc	r7		; increment high part
Xint0x:		pop	PSW
X		reti			; and return
X
Xtc0int:		push	PSW
X		setb	P2.4
X		mov	TH0,#ti1h	; high part
X		mov 	TL0,#ti1l	; three times to 768
X		djnz	countl,tc0x	; exit if not done
X		djnz	counth,tc0x	; exit if not done
X		mov	countl,#0xe8	; next count 1000
X		mov	counth,#3
X		mov	curl,r6		; get current count
X		mov	curh,r7		; get current count
X		mov	r6,#0		; zero count
X		mov	r7,#0		; zero count
X		mov	r5,#1		; tell the world we want update
Xtc0x:		clr	P2.4
X		pop 	PSW
X		reti
X
Xmain:		mov	counth,#3	; start with 1000 ticks to go
X		mov	countl,#0xe8	; to get to one second
X		mov	r6,#0		; zero MIPS count
X		mov	r7,#0
X		mov	res,#0x82	; home cursor command
X		mov	res2,#'M'	; set up MIP string
X		mov	res2+1,#'I'
X		mov	res2+2,#'P'
X		mov	res2+3,#'S'
X		mov	TMOD,#0x01	; timer 0 set mode 1
X		clr	TF0		; ensure overflow clear
X		mov	TH0,#ti1h	; set up to zero count
X		mov 	TL0,#ti1l	; initially
X		setb	TR0		; start it running
X		setb	IT0		; set INT0 to be edge triggered
X		mov	IE,#0x83	; enable interrupts
X		acall	lcd_setup	; setup lcd panel
X		
Xmainr:		mov	r5,#0		; start with no update
Xmainl:		cjne	r5,#1,mainl	; wait til update time
X		mov	a,curh		; get upper byte
X		cjne	a,#0,domips	; if upper byte is non-zero
Xdokips:		mov	res2,#'K'	; else display KIPS
X		mov	r0,#10		; multiply by 10
X		acall	mulcurxr0	; using subroutine
X		mov	b,#0xff		; the result starts at -1
Xkip1:		inc	b		; increment result
X		mov	a,r3		; get current value
X		clr	c		; clear carry bit
X		subb	a,#24		; subtract divisor
X		mov	r3,a		; store result
X		mov	a,r4		; get msb
X		subb	a,#0		; prop. carry
X		mov	r4,a		; save result
X		jnc	kip1		; if no carry, loop
X		mov	a,b
X		mov	r3,a		; save result
X		mov	r4,#' '		; zero fill flag
X		mov	r0,#res1	; point to result 
X		mov	b,#100		; divide by 100
X		div	ab		; get result
X		cjne	a,#0,kip2	; jump if result non-zero
X		mov	a,r4		; put in ZF flag
X		sjmp	kip2a		; skip flag set
Xkip2:		add	a,#'0'		; make it ascii
X		mov	r4,#'0'		; zero fill flag is OK
Xkip2a:		mov	@r0,a		; store the result
X		inc	r0
X		mov	a,b		; get remainder
X		mov	b,#10		; divide by 10
X		div	ab		; get result
X		cjne	a,#0,kip3	; jump if result non-zero
X		mov	a,r4		; put in ZF flag
X		sjmp	kip3a		; skip flag set
Xkip3:		add	a,#'0'		; make it ascii
X		mov	r4,#'0'		; zero fill flag is OK
Xkip3a:		mov	@r0,a		; store the result
X		inc	r0		; next
X		mov	a,b		; get remainder
X		cjne	a,#0,kip4	; jump if result non-zero
X		mov	a,r4		; put in ZF flag
X		sjmp	kip4a		; skip flag set
Xkip4:		add	a,#'0'		; make it ascii
Xkip4a:		mov	@r0,a		; store it
X		inc	r0		; last is always zero
X		mov	@r0,#'0'	; store it
X		sjmp	dodisp		; and display it
X
Xdomips:		mov	res2,#'M'	; display MIPS
X		mov	r0,#10		; multiply by 10
X		acall	mulcurxr0	; using subroutine
X		mov	b,#0xff		; the result starts at -1
Xmainl1:		inc	b		; increment result
X		mov	a,r3		; get current value
X		clr	c		; clear carry bit
X		subb	a,#244		; subtract divisor
X		mov	r3,a		; store result
X		mov	a,r4		; get msb
X		subb	a,#0		; prop. carry
X		mov	r4,a		; save result
X		jnc	mainl1		; if no carry, loop
X		mov	a,b
X		mov	r3,a		; save result
X		mov	r0,#res1	; point to result
X		mov	b,#100		; divide by 100
X		div	ab		; get result
X		cjne	a,#0,ml1	; jump if result non-zero
X		mov	a,#' '-'0'	; make it a space
Xml1:		add	a,#'0'		; make it ascii
X		mov	@r0,a		; store the result
X		inc	r0
X		mov	a,b		; get remainder
X		mov	b,#10		; divide by 10
X		div	ab		; get result
X		add	a,#'0'		; make it ascii
X		mov	@r0,a		; store the result
X		inc	r0		; next
X		mov	@r0,#'.'	; store a decimal point
X		inc	r0
X		mov	a,b		; get remainder
X		add	a,#'0'		; make it ascii
X		mov	@r0,a		; store the result
Xdodisp:		mov	r0,#res		; point to string
X		mov	r1,#9		; count of data
X		acall	prlcd		; display it
X		ajmp	mainr		; back for more
X
Xprlcd:		mov	a,@r0		; get current value
X		acall	lcd_out		; output it
X		inc	r0
X		djnz	r1,prlcd	; loop until done
X		ret
X
Xlcd_setup:	mov	P2,#0xf8	; clear RS, enable, r/w
X		mov	P1,#0x34	; set up for 8 bit I/O
X		setb	P2.0		; set the enable
X		clr	P2.0		; clear it
X		mov	a,countl	; wait for 5 ms
X		add	a,#0xfb		; by looking at count
Xdel1:		cjne	a,countl,del1	; wait for 8 milliseconds
X		setb	P2.0		; set the enable
X		clr	P2.0		; clear it
X		mov	a,countl	; wait for 5 ms
X		add	a,#0xfb		; by looking at count
Xdel2:		cjne	a,countl,del2	; wait for 5 milliseconds
X		setb	P2.0		; set the enable
X		clr	P2.0		; clear it
X		mov	a,countl	; wait for 5 ms
X		add	a,#0xfb		; by looking at count
Xdel3:		cjne	a,countl,del3	; wait for 5 milliseconds
X		mov	a,#0x8c		; Display on, cursor off
X		acall	lcd_out		; output it
X		mov	a,#82		; home cursor
X		acall	lcd_out		; output it
X		mov	a,#81		; clear display
X		acall	lcd_out		; output it
X		ret
X
Xlcd_out:	push	ACC		; save accumulator
X		mov	P1,#0xff	; permit reading port
X		clr	P2.2		; clear R/S (command mode)
X		setb	P2.1		; set to read
Xlcd_l1:		setb	P2.0		; read the port
X		mov	a,P1		; from P1
X		clr	P2.0		; drop E
X		jb	ACC.7,lcd_l1	; loop until ready
X		pop	ACC		; restore
X		clr	P2.1		; change to write
X		mov	c,ACC.7		; get command/data status
X		cpl	C		; complement it
X		mov	P2.2,C		; set R/S based on bit
X		clr	ACC.7		; ensure ACC clear
X		mov	P1,a		; store the value to write
X		setb	P2.0		; set the enable
X		clr	P2.0		; clear it
X		ret			; and return
X
X
X;
X;	Multiply curl/curh by r0
X;	return result in r3/r4
X;	destroys A, B, r3/r4 and flags
Xmulcurxr0:
X		mov	a,curl		; get current low value
X		mov	b,r0		; mult by 10 for 1 sig fig
X		mul	ab		; got it
X		mov	r3,a		; save lsb
X		mov	r4,b		; save msb
X		mov	a,curh		; get current high value
X		mov	b,r0		; mult by 10 for 1 sig fig
X		mul	ab		; got it
X		add	a,r4		; sum with low result
X		mov	r4,a
X		; r4r3 contains the 16 bit value
X		ret
X
X		.end
END_OF_FILE
if test 7187 -ne `wc -c <'mips.asm'`; then
    echo shar: \"'mips.asm'\" unpacked with wrong size!
fi
# end of 'mips.asm'
fi
if test -f 'mips.obj.uue' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mips.obj.uue'\"
else
echo shar: Extracting \"'mips.obj.uue'\" \(591 characters\)
sed "s/^X//" >'mips.obj.uue' <<'END_OF_FILE'
X
Xbegin 644 mips.obj
XM`5,)`21R9PDP#0H!+F%R=#H)"6%J;7`);6%I;@D).R!J=6TRP-`.O@`!#]#0Z
XM,L#0TJ1UC/QUBAG50!/501!U0.AU00..0H]#?@!_`'T!PJ30T#)U00-U0.A^:
XM`'\`=42"=4E-=4I)=4M0=4Q3=8D!PHUUC/QUBAG2C-*(=:B#,21]`+T!_>5#A
XMM`!0=4E+>`HQ?'7P_P7PZ\.4&/OLE`#\4//E\/M\('A%=?!DA+0``^R`!"0P:
XM?##V".7P=?`*A+0``^R`!"0P?##V".7PM``#[(`")##V"'8P@#MU24UX"C%\^
XM=?#_!?#KPY3T^^R4`/Q0\^7P^WA%=?!DA+0``G3P)##V".7P=?`*A"0P]@AV?
XM+@CE\"0P]GA$>0DQ'0&`YC%8"-GZ(G6@^'60--*@PJ#E0"3[M4#]TJ#"H.5`7
XM)/NU0/W2H,*@Y4`D^[5`_72,,5AT4C%8=%$Q6"+`X'60_\*BTJ'2H.60PJ`@'
XDY_?0X,*AHN>SDJ+"Y_60TJ#"H"+E0HCPI/NL\.5#B/"D+/PBM
X``
Xend
Xsize 396
END_OF_FILE
if test 591 -ne `wc -c <'mips.obj.uue'`; then
    echo shar: \"'mips.obj.uue'\" unpacked with wrong size!
fi
# end of 'mips.obj.uue'
fi
echo shar: End of shell archive.
exit 0

-- 
Dave Rand
{pyramid|mips|bct|vsi1}!daver!dlr	Internet: dlr@daver.bungi.com

s861298@minyos.xx.rmit.oz.au (Marc A. Boschma) (05/29/91)

dlr@daver.bungi.com (Dave Rand) writes:

>Just to keep everyone from total boredom during the summer, here is
>the complete kit for the MIPS-O-METER! Now you can _really_ see how
>many mips you are getting on your programs! It autoscales (from KIPS
>to MIPS)! It slices! It dices! 

Summer? Hmm well it'll give me something to do on the cold winter nights
that seem to be approaching with great speed.

marcb