; Micro assembly language routines
; last edited October 20, 1978  12:50 PM
; Copyright Xerox Corporation 1979

	.titl micasm

	.ent DoubleAdd1	; (vec2)
	.ent unpak	; (dest, source, count)


; Entries
	.srel
unpak:	.unpak
	.zrel
DoubleAdd1:	.dadd1


; Constants
	.zrel
c377:	377
c177400:	177400


; Locations in caller's frame
	link=1
	temp=2
	arg3=3


	.nrel


; Add 1 to a double-length number
; DoubleAdd(vec2, table[ 0; 1])
; Done in assembly language for statistics in symbol lookup

.dadd1:
	inc 0 0
	sta 0 temp,2
	isz @temp,2
	  jmp 1,3
	dsz temp,2
	jmp .-3



; Unpack an unformatted (non-Bcpl) string starting
;	at source into dest for count characters.
; for i = 0 to count-1 do dest!i = source>>BYTE↑i
; Done in assembly language for macro expansion

.unpak:
	sta 3 link,2
	sta 1 temp,2
	mov 0 3
	lda 0 arg3,2
	movzr 0 0 snr	; put odd/even flag into carry
	  jmp unpakdone
	sta 0 arg3,2
unpakloop:
	lda 0 @temp,2
	isz temp,2
	lda 1 c377
	andc 0 1	; preserve carry
	subs 1 0
	sta 0 0,3
	inc 3 3
	sta 1 0,3
	inc 3 3
	dsz arg3,2
	  jmp unpakloop
unpakdone:
	mov# 0 0 snc
	  jmp exit	; even
	lda 0 @temp,2
	lda 1 c177400
	ands 1 0
	sta 0 0,3
exit:
	lda 3 link,2
	jmp 1,3


	.end