; CSE 30.  Bennet Yee <cs30f@ieng9.ucsd.edu>.  Oct 19, 1999.

; Extended macro assembly example.

; asm file -- macro definitions removed, and macro usages expanded

		.data
zero:		.word	0			; "constant" zero
						; woe if this is ever changed
tmp:		.word	0			; a global tmp for goto

		.data
mul16A:		.word	0
mul16B:		.word	0

		.data
s16tmp:		.word	0

		.data
ptr1:		.word 0
ptr2:		.word 0
clear_inc:	.word -triple(1,1,0)		; NOTE NEW NOTATION

		.data
negcount:	.word 0
negone:		.word -1			; 0xffffffffffff

		.text 0x0000
;;; main:		clearmem base,length
main:
		.data
L2val_000:	.word L2_000
		.text
		subz length,zero,Ldone_000
		subz negcount,negcount,next
		subz negcount,length,next
;;;		shift16 ptr1,base
;;;		shift4 s16tmp,base
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,base,next
		subz mul16A,base,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz s16tmp,s16tmp,next
		subz s16tmp,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz s16tmp,mul16A,next		; 16 src == src << 4

;;;		shift4 ptr1,s16tmp
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,s16tmp,next
		subz mul16A,s16tmp,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz ptr1,ptr1,next
		subz ptr1,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz ptr1,mul16A,next		; 16 src == src << 4

;;;		shift4 s16tmp,ptr1
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,ptr1,next
		subz mul16A,ptr1,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz s16tmp,s16tmp,next
		subz s16tmp,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz s16tmp,mul16A,next		; 16 src == src << 4

;;;		shift4 ptr1,s16tmp
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,s16tmp,next
		subz mul16A,s16tmp,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz ptr1,ptr1,next
		subz ptr1,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz ptr1,mul16A,next		; 16 src == src << 4

;;;		shift16 ptr2,ptr1
;;;		shift4 s16tmp,ptr1
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,ptr1,next
		subz mul16A,ptr1,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz s16tmp,s16tmp,next
		subz s16tmp,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz s16tmp,mul16A,next		; 16 src == src << 4

;;;		shift4 ptr2,s16tmp
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,s16tmp,next
		subz mul16A,s16tmp,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz ptr2,ptr2,next
		subz ptr2,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz ptr2,mul16A,next		; 16 src == src << 4

;;;		shift4 s16tmp,ptr2
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,ptr2,next
		subz mul16A,ptr2,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz s16tmp,s16tmp,next
		subz s16tmp,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz s16tmp,mul16A,next		; 16 src == src << 4

;;;		shift4 ptr2,s16tmp
		.text
		subz mul16A,mul16A,next		; 0
		subz mul16B,mul16B,next		; 0
		subz mul16A,s16tmp,next
		subz mul16A,s16tmp,next		; -2 src
		subz mul16B,mul16A,next
		subz mul16B,mul16A,next		; 4 src
		subz mul16A,mul16B,next		; -6 src
		subz ptr2,ptr2,next
		subz ptr2,mul16A,next		; 6 src
		subz mul16A,mul16B,next		; -10 src
		subz ptr2,mul16A,next		; 16 src == src << 4

;;;		add L1_000,ptr1,ptr2
		.data
Ltmp_001:	.word	0
		.text
		subz Ltmp_001,Ltmp_001,next
		subz Ltmp_001,ptr1,next
		subz Ltmp_001,ptr2,next
		subz L1_000,L1_000,next
		subz L1_000,Ltmp_001,next
;;;		add L1_000,L1_000,L2val_000
		.data
Ltmp_002:	.word	0
		.text
		subz Ltmp_002,Ltmp_002,next
		subz Ltmp_002,L1_000,next
		subz Ltmp_002,L2val_000,next
		subz L1_000,L1_000,next
		subz L1_000,Ltmp_002,next
L1_000:		.word 0
L2_000:		subz negcount,negone,Ldone_000
		subz L1_000,clear_inc,next
		subz tmp,tmp,L1_000
Ldone_000:
done:		subz tmp,tmp,done

		.data
base:		.word 0x1000
length:		.word 0x0010

		.data 0x1000
		.word 0xdeadbeefdead	;0
		.word 0xdeadbeefdead	;1
		.word 0xdeadbeefdead	;2
		.word 0xdeadbeefdead	;3
		.word 0xdeadbeefdead	;4
		.word 0xdeadbeefdead	;5
		.word 0xdeadbeefdead	;6
		.word 0xdeadbeefdead	;7
		.word 0xdeadbeefdead	;8
		.word 0xdeadbeefdead	;9
		.word 0xdeadbeefdead	;a
		.word 0xdeadbeefdead	;b
		.word 0xdeadbeefdead	;c
		.word 0xdeadbeefdead	;d
		.word 0xdeadbeefdead	;e
		.word 0xdeadbeefdead	;f
		.word 0xdeadbeefdead	;0
		.word 0xdeadbeefdead	;1
		.word 0xdeadbeefdead	;2
		.word 0xdeadbeefdead	;3
		.word 0xdeadbeefdead	;4
		.word 0xdeadbeefdead	;5
		.word 0xdeadbeefdead	;6
		.word 0xdeadbeefdead	;7
		.word 0xdeadbeefdead	;8
		.word 0xdeadbeefdead	;9
		.word 0xdeadbeefdead	;a
		.word 0xdeadbeefdead	;b
		.word 0xdeadbeefdead	;c
		.word 0xdeadbeefdead	;d
		.word 0xdeadbeefdead	;e
		.word 0xdeadbeefdead	;f
