1 line
25 KiB
NASM
1 line
25 KiB
NASM
|
keep obj/cc
mcopy cc.macros
****************************************************************
*
* CC - C Specific Run Time Libraries
*
* October 1988
* Mike Westerfield
*
* Copyright 1988
* Byte Works, Inc.
*
****************************************************************
*
CC start dummy routine
end
****************************************************************
*
* ~CopyBF - Copy a bit field
* ~SaveBF - Save a bit field
*
* Inputs:
* addr - address to copy to
* bitDisp - displacement past the address
* bitNum - number of bits
* val - value to copy
*
****************************************************************
*
~CopyBF start
ret equ 2 return address
val equ 5 value to copy
bitNum equ 9 number of bits
bitDisp equ 11 displacement past the address
addr equ 13 address to copy to
lda #0 set the call type
bra lb1
~SaveBF entry
lda #1
lb1 phb
phk
plb
sta isSave
tsc set up the stack frame
phd
tcd
move4 val,lval save the value (for copybf only)
stz mask+2 set up the and mask
ldx bitNum
lda #0
lb2 sec
rol A
rol mask+2
dex
bne lb2
sta mask
and val and out extra bits in the mask
sta val
lda mask+2
and val+2
sta val+2
ldx bitDisp shift the mask and value
beq lb4
lda mask
lb3 asl A
rol mask+2
asl val
rol val+2
dex
bne lb3
sta mask
lb4 ldy #2 place the bits in memory
lda mask
eor #$FFFF
and [addr]
ora val
sta [addr]
lda mask+2
eor #$FFFF
and [addr],Y
ora val+2
sta [addr],Y
lda isSave branch based on call type
beq lb5
lda ret+1 return from save
sta addr+2
lda ret
sta addr+1
pld
plb
tsc
clc
adc #12
tcs
rtl
lb5 move4 lval,addr place the value back on the stack
lda ret+1 return from copy
sta bitDisp
lda ret
sta bitDisp-1
pld
plb
tsc
clc
adc #8
tcs
rtl
;
; local data
;
mask ds 4 bit mask
isSave ds 2 is the call a save? (or copy?)
lval ds 4 temp storage for val
end
****************************************************************
*
* ~C_ShutDown - do shut down peculiar to the C language
*
* Inputs:
* A - shell return code
*
****************************************************************
*
~C_ShutDown start
pha save the return code
jsr ~Exit do exit processing
pla quit
jml ~Quit
end
****************************************************************
*
* ~C_ShutDown2 - do shut down peculiar to the C language
*
* Inputs:
* A - shell return code
*
****************************************************************
*
~C_ShutDown2 start
pha save the return code
jsr ~Exit do exit processing
pla quit
jml ~RTL
end
****************************************************************
*
* ~C_StartUp - do startup peculiar to the C language
*
*****
|