NEW
  AUTO 3,1
				.LIST OFF
*--------------------------------------
* ZPADDR=STR ID, New pSTR Value on stack
*--------------------------------------
CODE.STRSET		jsr CODE.PULLWS			save pSTR

				ldx hStrings
				jsr CODE.PUSHBI			>PUSHB hSTRV

				>LDYA ZPADDR
				jsr CODE.PUSHIYA		>PUSHW id

				jsr CODE.PUSHWS			>PUSHW str

				ldx #SYS.StrVSet
				jsr CODE.SYSCALL		>SYSCALL StrVSet

				rts
*--------------------------------------
* EXP.ADDR = STR ID
* output : str to ZPStrBuf
*--------------------------------------
CODE.STRGET		ldx hStrings
				jsr CODE.PUSHBI			>PUSHB hSTRV

				>LDYA EXP.ADDR 
				jsr CODE.PUSHIYA		>PUSHW id

				>LDYA ZPStrBuf
				jsr CODE.PUSHIYA		>PUSHW str

				ldx #SYS.StrVGet
				jsr CODE.SYSCALL		>SYSCALL StrVGet

				>LDYA ZPStrBuf
				jsr CODE.PUSHYA

				rts
*--------------------------------------
* ZPADDR=pInt, Int16 on Stack
*--------------------------------------
CODE.INTSET		>LDYA ZPADDR
				jsr CODE.LDYAI

				ldx #0

.1				lda CCODE.PULLWYA,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.PULLWYA.LEN
				bne .1

				rts
*--------------------------------------
* EXP.ADDR=pInt
* output : Int16 on Stack
*--------------------------------------
CODE.INTGET		>LDYA EXP.ADDR
				jsr CODE.LDYAI

				ldx #0

.1				lda CCODE.PUSHWYA,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.PULLWYA.LEN
				bne .1

				rts
*--------------------------------------
CODE.PULLWS		ldx #0

.1				lda CCODE.PULLWS,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.PULLWS.LEN
				bne .1
				
				rts
*--------------------------------------
CODE.PUSHWS		ldx #0

.1				lda CCODE.PUSHWS,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.PUSHWS.LEN
				bne .1
				
				rts
*--------------------------------------
CODE.PUSHBI		lda #$A9				LDA #imm
				jsr CODE.EmitByte
				txa
				jsr CODE.EmitByte
				
				jmp CODE.PUSHA
*--------------------------------------
CODE.PUSHIYA	pha
				lda #$A9				LDA #imm
				jsr CODE.EmitByte
				pla
				jsr CODE.EmitByte
				jsr CODE.PUSHA
				
				lda #$A9				LDA #imm
				jsr CODE.EmitByte
				tya
				jsr CODE.EmitByte
				jmp CODE.PUSHA
*--------------------------------------
CODE.PUSHINT16	ldy #1

.1				lda #$A9				LDA #imm
				jsr CODE.EmitByte
				
				lda (pStack),y
				jsr CODE.EmitByte
				
				jsr CODE.PUSHA
				dey
				bpl .1
				
				rts
*--------------------------------------
CODE.LDYAI		pha
				lda #$A0				LDY #imm
				jsr CODE.EmitByte
				tya
				jsr CODE.EmitByte

				lda #$A9				LDA #imm
				jsr CODE.EmitByte
				pla
				jmp CODE.EmitByte
*--------------------------------------
CODE.PUSHYA		jsr CODE.PUSHA
				lda #$98				tya
				jsr CODE.EmitByte
*--------------------------------------
CODE.PUSHA		ldx #0

.1				lda CCODE.PUSHA,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.PUSHA.LEN
				bne .1

				rts
*--------------------------------------
CODE.FPRINTSTR	ldx #0

.1				lda CCODE.FPRINTSTR,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.FPRINTSTR.LEN
				bne .1

				rts
*--------------------------------------
CODE.FPRINTINT	ldx #0

.1				lda CCODE.FPRINTINT,x
				jsr CODE.EmitByte
				inx
				cpx #CCODE.FPRINTINT.LEN
				bne .1

				rts
*--------------------------------------
CODE.FPUCALL	lda #$A2				LDX #imm
				jsr CODE.EmitByte
				txa
				jsr CODE.EmitByte
				lda #$20				JSR
				jsr CODE.EmitByte
				lda #A2osX.FPUCALL
				jsr CODE.EmitByte
				lda /A2osX.FPUCALL
				bra CODE.EmitByte
*--------------------------------------
CODE.FPRINTCRLF	ldx #C.CR
				jsr CODE.PutChar
				ldx #C.LF 
*--------------------------------------
CODE.PutChar	lda #$A9				LDA #imm
				jsr CODE.EmitByte
				txa
				jsr CODE.EmitByte
				ldx #SYS.PutChar
*--------------------------------------
CODE.SYSCALL	lda #$A2				LDX #imm
				jsr CODE.EmitByte
				txa
				jsr CODE.EmitByte
				lda #$20				JSR
				jsr CODE.EmitByte
				lda #A2osX.SYSCALL
				jsr CODE.EmitByte
				lda /A2osX.SYSCALL
*--------------------------------------
CODE.EmitByte	sta (ZPCodeBufPtr)
				inc ZPCodeBufPtr
				bne .8

				inc ZPCodeBufPtr+1

.8				rts
*--------------------------------------
MAN
SAVE usr/src/bin/acos.s.code
LOAD usr/src/bin/acos.s
ASM
