ORCA-Pascal/objout.asm

1 line
9.8 KiB
NASM
Raw Normal View History

mcopy objout.macros **************************************************************** * * Code Generator Output Routines * * This module provides fast object module output for the code * generator. Currently, the maximum size for a single object * segment is 64K. * * By Mike Westerfield * * Copyright July 1987 * Byte Works, Inc. * **************************************************************** * ObjData privdata place with ~globals ; ; Constants ; ! NOTE: tokenBuffSize also defined in cgi.pas tokenBuffSize equ 4095 size of the token buffer end **************************************************************** * * COut - write a code byte to the object file * * Inputs: * b - byte to write (on stack) * **************************************************************** * COut start phb OutByte(b); pla ply plx phy pha plb jsr OutByte inc blkcnt blkcnt := blkcnt+1; inc4 pc pc := pc+1; rtl end **************************************************************** * * CnOut - write a byte to the constant buffer * * Inputs: * i - byte to write * **************************************************************** * CnOut start maxCBuffLen equ 191 max index into the constant buffer lda cBuffLen if cBuffLen = maxCBuffLen then cmp #maxCBuffLen bne lb1 jsl Purge Purge; lb1 phb cBuff[cBuffLen] := i; plx ply pla phy phx plb ldx cBuffLen short M sta cBuff,X long M inc cBuffLen cBuffLen := cBuffLen+1; rtl end **************************************************************** * * CnOut2 - write a word to the constant buffer * * Inputs: * i - word to write * **************************************************************** * CnOut2 start maxCBuffLen equ 191 max index into the constant buffer lda cBuffLen if cBuffLen+1 >= maxCBuffLen then inc A cmp #maxCBuffLen blt lb1 jsl Purge Purge; lb1 phb cBuff[cBuffLen] := i; plx ply pla phy phx plb ldx cBuffLen sta cBuff,X inx cBuffLen := cBuffLen+2; inx stx cBuffLen rtl end **************************************************************** * * GrowHandle - Grow the area occupied by a handle * * Inputs: * size - new size for the buffer * haddr - address of the handle * * Notes: * This subroutine must only be used if the handle is * grown. It will fail if you try to shrink the handle. * **************************************************************** * GrowHandle start shandle equ 1 source handle dhandle equ 5 destination handle sptr equ 9 source pointer dptr equ 13 destination pointer sub (4:size,4:haddr),16 ldy #2 recover the source handle lda [haddr] sta shandle lda [haddr],Y sta shandle+2 ph4 shandle unlock the handle _HUnlock pha allocate a new area pha ph4 size ph2 >~User_ID ph2 #$8000 ph4 #0 _NewHandle bcc lb0 ph2 #3 ph4 #0 jsl TermError lb0 pl4 dhandle ph4 shandle lock the source handle _HLock ldy #2 deref