codebreaker/cc65-2.13.2-apple1.patch
2014-11-24 10:15:15 -07:00

3277 lines
99 KiB
Diff

diff -Ncr cc65-2.13.2/include/apple1.h cc65-2.13.2-apple1/include/apple1.h
*** cc65-2.13.2/include/apple1.h Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/include/apple1.h Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,105 ----
+ /*****************************************************************************/
+ /* */
+ /* apple1.h */
+ /* */
+ /* Apple I system specific definitions */
+ /* */
+ /* */
+ /* */
+ /* (C) 2000 Kevin Ruland, <kevin@rodin.wustl.edu> */
+ /* (C) 2003 Ullrich von Bassewitz, <uz@cc65.org> */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ #ifndef _APPLE1_H
+ #define _APPLE1_H
+
+
+
+ /* Check for errors */
+ #if !defined(__APPLE1__) && !defined(__REPLICA1__)
+ # error This module may only be used when compiling for the Apple ][!
+ #endif
+
+
+
+ /*****************************************************************************/
+ /* Data */
+ /*****************************************************************************/
+
+
+
+ /* Color Defines
+ * Since Apple1 does not support color text these defines are only
+ * used to get the library to compile correctly. They should not be used
+ * in user code
+ */
+ #define COLOR_BLACK 0x00
+ #define COLOR_WHITE 0x01
+
+ /* Characters codes */
+ #define CH_ENTER 0x0D
+ #define CH_ESC 0x1B
+ #define CH_CURS_LEFT 0x08
+ #define CH_CURS_RIGHT 0x15
+
+ #define CH_ULCORNER '+'
+ #define CH_URCORNER '+'
+ #define CH_LLCORNER '+'
+ #define CH_LRCORNER '+'
+ #define CH_TTEE '+'
+ #define CH_BTEE '+'
+ #define CH_LTEE '+'
+ #define CH_RTEE '+'
+ #define CH_CROSS '+'
+
+ /* Return codes for get_ostype */
+ #define APPLE_UNKNOWN 0x00
+ #define APPLE_I 0x01 /* Apple I */
+ #define REPLICA_I 0x02 /* Replica I */
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+ #ifdef __APPLE1__
+ #define get_ostype() APPLE_I
+ #endif
+ #ifdef __REPLICA1__
+ #define get_ostype() REPLICA_I
+ #endif
+ /* Get the machine type. Returns one of the APPLE_xxx codes. */
+
+ /* The following #defines will cause the matching functions calls in conio.h
+ * to be overlaid by macros with the same names, saving the function call
+ * overhead.
+ */
+ #define _textcolor(color) COLOR_WHITE
+ #define _bgcolor(color) COLOR_BLACK
+ #define _bordercolor(color) COLOR_BLACK
+
+
+
+ /* End of apple2.h */
+ #endif
diff -Ncr cc65-2.13.2/include/conio.h cc65-2.13.2-apple1/include/conio.h
*** cc65-2.13.2/include/conio.h Tue Aug 21 07:16:53 2007
--- cc65-2.13.2-apple1/include/conio.h Tue Sep 13 18:42:27 2011
***************
*** 63,68 ****
--- 63,72 ----
# include <apple2.h>
#elif defined(__APPLE2ENH__)
# include <apple2enh.h>
+ #elif defined(__APPLE1__)
+ # include <apple1.h>
+ #elif defined(__REPLICA1__)
+ # include <apple1.h>
#elif defined(__ATARI__)
# include <atari.h>
#elif defined(__ATMOS__)
diff -Ncr cc65-2.13.2/libsrc/Makefile cc65-2.13.2-apple1/libsrc/Makefile
*** cc65-2.13.2/libsrc/Makefile Tue Sep 22 15:43:57 2009
--- cc65-2.13.2-apple1/libsrc/Makefile Mon Nov 21 13:27:42 2011
***************
*** 15,20 ****
--- 15,21 ----
# List of all targets
ALLTARGETS = apple2 \
apple2enh \
+ apple1 \
atari \
atmos \
c16 \
***************
*** 39,44 ****
--- 40,57 ----
done
#-----------------------------------------------------------------------------
+ # Apple I
+
+ apple1lib:
+ for i in apple1 common runtime conio; do \
+ $(MAKE) SYS=apple1 -C $$i || exit 1; \
+ $(AR) a apple1.lib $$i/*.o;\
+ done
+ mv apple1/crt0.o apple1.o
+ cp apple1.o replica1.o
+ cp apple1.o apple-1.o
+
+ #-----------------------------------------------------------------------------
# Apple ][
apple2lib:
diff -Ncr cc65-2.13.2/libsrc/apple1/Makefile cc65-2.13.2-apple1/libsrc/apple1/Makefile
*** cc65-2.13.2/libsrc/apple1/Makefile Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/Makefile Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,81 ----
+ #
+ # makefile for CC65 runtime library
+ #
+
+ .SUFFIXES: .o .s .c
+
+ #--------------------------------------------------------------------------
+ # Programs and flags
+
+ SYS = apple1
+
+ AS = ../../src/ca65/ca65
+ CC = ../../src/cc65/cc65
+ LD = ../../src/ld65/ld65
+
+ AFLAGS = -t $(SYS) -I../../asminc
+ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
+
+ #--------------------------------------------------------------------------
+ # Rules
+
+ %.o: %.c
+ @$(CC) $(CFLAGS) $<
+ @$(AS) -o $@ $(AFLAGS) $(*).s
+
+ %.o: %.s
+ @$(AS) -g -o $@ $(AFLAGS) $<
+
+ %.emd: %.o ../runtime/zeropage.o
+ @$(LD) -t module -o $@ $^
+
+ %.joy: %.o ../runtime/zeropage.o
+ @$(LD) -t module -o $@ $^
+
+ %.ser: %.o ../runtime/zeropage.o
+ @$(LD) -t module -o $@ $^
+
+ %.tgi: %.o ../runtime/zeropage.o
+ @$(LD) -t module -o $@ $^
+
+ #--------------------------------------------------------------------------
+ # Object files
+
+ S_OBJS= _scrsize.o \
+ cclear.o \
+ cgetc.o \
+ clrscr.o \
+ cputc.o \
+ crt0.o \
+ ctype.o \
+ gotoxy.o \
+ kbhit.o \
+ randomize.o
+
+ #--------------------------------------------------------------------------
+ # Drivers
+
+ EMDS =
+
+ JOYS =
+
+ SERS =
+
+ TGIS =
+
+ #--------------------------------------------------------------------------
+ # Targets
+
+ .PHONY: all clean zap
+
+ all: $(C_OBJS) $(S_OBJS) $(EMDS) $(JOYS) $(SERS) $(TGIS)
+
+ ../runtime/zeropage.o:
+ $(MAKE) -C $(dir $@) $(notdir $@)
+
+ clean:
+ @$(RM) $(C_OBJS:.o=.s) $(C_OBJS) $(S_OBJS) $(EMDS:.emd=.o) $(JOYS:.joy=.o) $(SERS:.ser=.o) $(TGIS:.tgi=.o)
+
+ zap: clean
+ @$(RM) $(EMDS) $(JOYS) $(SERS) $(TGIS)
+
diff -Ncr cc65-2.13.2/libsrc/apple1/_scrsize.s cc65-2.13.2-apple1/libsrc/apple1/_scrsize.s
*** cc65-2.13.2/libsrc/apple1/_scrsize.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/_scrsize.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,14 ----
+ ;
+ ; Ullrich von Bassewitz, 26.10.2000
+ ;
+ ; Screen size variables
+ ;
+
+ .export screensize
+
+ .include "apple1.inc"
+
+ screensize:
+ ldx #40
+ ldy #24
+ rts
diff -Ncr cc65-2.13.2/libsrc/apple1/apple1.inc cc65-2.13.2-apple1/libsrc/apple1/apple1.inc
*** cc65-2.13.2/libsrc/apple1/apple1.inc Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/apple1.inc Mon Nov 21 10:41:26 2011
***************
*** 0 ****
--- 1,24 ----
+ ;-----------------------------------------------------------------------------
+ ; Zero page locations
+
+ IRQ := $00 ; IRQ handler jumps to $0000
+ NMI := $0F ; NMI handler jumps to $000F
+
+ ;-----------------------------------------------------------------------------
+ ; Hardware
+
+ ; Keyboard input
+ KBD := $D010 ; Read keyboard
+ KBDRDY := $D011 ; Clear keyboard strobe
+
+ ;Video output
+ VID := $D012 ; Write to video hardware
+
+ ; RAM locations
+ RAMTOP := $EFFF
+
+ ;-----------------------------------------------------------------------------
+ ; ROM routines
+
+ RESET := $FF1A ; RESET entrypoint into monitor
+ ECHO := $FFEF ; Echo character in A to video hardware
diff -Ncr cc65-2.13.2/libsrc/apple1/cclear.s cc65-2.13.2-apple1/libsrc/apple1/cclear.s
*** cc65-2.13.2/libsrc/apple1/cclear.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/cclear.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,19 ----
+ ;
+ ; Ullrich von Bassewitz, 08.08.1998
+ ;
+ ; void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);
+ ; void __fastcall__ cclear (unsigned char length);
+ ;
+
+ .export _cclearxy, _cclear
+ .import popa, _gotoxy, chlinedirect
+
+ _cclearxy:
+ pha ; Save the length
+ jsr popa ; Get y
+ jsr _gotoxy ; Call this one, will pop params
+ pla ; Restore the length and run into _cclear
+
+ _cclear:
+ ldx #' ' | $80 ; Blank, screen code
+ jmp chlinedirect
diff -Ncr cc65-2.13.2/libsrc/apple1/cgetc.s cc65-2.13.2-apple1/libsrc/apple1/cgetc.s
*** cc65-2.13.2/libsrc/apple1/cgetc.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/cgetc.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,17 ----
+ ;
+ ; Kevin Ruland
+ ;
+ ; char cgetc (void);
+ ;
+
+ .export _cgetc
+
+ .include "apple1.inc"
+
+ _cgetc:
+ lda KBDRDY
+ bpl _cgetc ; if < 128, no key pressed
+ lda KBD
+ and #$7F ; Clear high bit
+ done: ldx #$00
+ rts
diff -Ncr cc65-2.13.2/libsrc/apple1/clrscr.s cc65-2.13.2-apple1/libsrc/apple1/clrscr.s
*** cc65-2.13.2/libsrc/apple1/clrscr.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/clrscr.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,10 ----
+ ;
+ ; Kevin Ruland
+ ;
+ ; void clrscr (void);
+ ;
+
+ .export _clrscr
+ .import HOME
+
+ _clrscr := HOME
diff -Ncr cc65-2.13.2/libsrc/apple1/cputc.s cc65-2.13.2-apple1/libsrc/apple1/cputc.s
*** cc65-2.13.2/libsrc/apple1/cputc.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/cputc.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,24 ----
+ ;
+ ; Ullrich von Bassewitz, 06.08.1998
+ ;
+ ; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
+ ; void __fastcall__ cputc (char c);
+ ;
+
+ .export _cputcxy, _cputc
+ .import popa, _gotoxy
+
+ .include "apple1.inc"
+
+ .code
+
+ ; Plot a character - also used as internal function
+
+ _cputcxy:
+ pha ; Save C
+ jsr popa ; Get Y
+ jsr _gotoxy
+ pla ; Restore C
+
+ _cputc:
+ jmp ECHO
diff -Ncr cc65-2.13.2/libsrc/apple1/crt0.s cc65-2.13.2-apple1/libsrc/apple1/crt0.s
*** cc65-2.13.2/libsrc/apple1/crt0.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/crt0.s Mon Nov 21 13:27:22 2011
***************
*** 0 ****
--- 1,75 ----
+ ;
+ ; Startup code for cc65 (Apple1 version)
+ ;
+ ; This must be the *first* file on the linker command line
+ ;
+
+ .export _exit
+ .export __STARTUP__ : absolute = 1 ; Mark as startup
+ .import zerobss
+ .import initlib, donelib
+ .import callmain, callirq
+ .import __STARTUP_LOAD__, __BSS_LOAD__ ; Linker generated
+ .import __INTERRUPTOR_COUNT__ ; Linker generated
+
+ .include "zeropage.inc"
+ .include "apple1.inc"
+
+ ; ------------------------------------------------------------------------
+
+ .segment "EXEHDR"
+
+ .addr __STARTUP_LOAD__ ; Start address
+ .word __BSS_LOAD__ - __STARTUP_LOAD__ ; Size
+
+ ; ------------------------------------------------------------------------
+
+ .segment "STARTUP"
+
+ ldx #$FF
+ txs ; Init stack pointer
+
+ ; Delegate all further processing to keep STARTUP small
+ jsr init
+
+ ; Avoid re-entrance of donelib. This is also the _exit entry
+ _exit:
+ ; Call module destructors
+ jsr donelib
+
+ ; Jump back to monitor ROM
+ exit: jmp RESET
+
+
+ ; ------------------------------------------------------------------------
+
+ .segment "INIT"
+
+ ; Save the zero page locations we need
+ init:
+
+ ; Clear the BSS data
+ jsr zerobss
+
+ ; Setup the stack
+ ; The Replica 1 has 32K of RAM from $0000 to $7FFF
+ ; The Apple 1 has 4K of RAM from $0000 to $0FFF
+ ; and 4K from $E000 to $EFFF
+
+ lda #<(RAMTOP+1)
+ sta sp
+ lda #>(RAMTOP+1)
+ sta sp+1 ; Set argument stack ptr
+
+ ; Check for interruptors
+ ;lda #<__INTERRUPTOR_COUNT__
+ ;beq :+
+
+ ; Enable interrupts
+ cli
+
+ ; Call module constructors
+ : jsr initlib
+
+ ; Push arguments and call main()
+ jmp callmain
diff -Ncr cc65-2.13.2/libsrc/apple1/ctype.s cc65-2.13.2-apple1/libsrc/apple1/ctype.s
*** cc65-2.13.2/libsrc/apple1/ctype.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/ctype.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,161 ----
+ ;
+ ; Stefan Haubenthal with minor changes from Ullrich von Bassewitz, 2003-05-02
+ ;
+ ; Character specification table.
+ ;
+
+ .include "ctype.inc"
+
+ ; The tables are readonly, put them into the rodata segment
+
+ .rodata
+
+ ; The following 256 byte wide table specifies attributes for the isxxx type
+ ; of functions. Doing it by a table means some overhead in space, but it
+ ; has major advantages:
+ ;
+ ; * It is fast. If it were'nt for the slow parameter passing of cc65, one
+ ; could even define macros for the isxxx functions (this is usually
+ ; done on other platforms).
+ ;
+ ; * It is highly portable. The only unportable part is the table itself,
+ ; all real code goes into the common library.
+ ;
+ ; * We save some code in the isxxx functions.
+
+
+ __ctype:
+ .repeat 2
+ .byte CT_CTRL ; 0/00 ___ctrl_@___
+ .byte CT_CTRL ; 1/01 ___ctrl_A___
+ .byte CT_CTRL ; 2/02 ___ctrl_B___
+ .byte CT_CTRL ; 3/03 ___ctrl_C___
+ .byte CT_CTRL ; 4/04 ___ctrl_D___
+ .byte CT_CTRL ; 5/05 ___ctrl_E___
+ .byte CT_CTRL ; 6/06 ___ctrl_F___
+ .byte CT_CTRL ; 7/07 ___ctrl_G___
+ .byte CT_CTRL ; 8/08 ___ctrl_H___
+ .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB
+ ; 9/09 ___ctrl_I___
+ .byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___
+ .byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___
+ .byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___
+ .byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___
+ .byte CT_CTRL ; 14/0e ___ctrl_N___
+ .byte CT_CTRL ; 15/0f ___ctrl_O___
+ .byte CT_CTRL ; 16/10 ___ctrl_P___
+ .byte CT_CTRL ; 17/11 ___ctrl_Q___
+ .byte CT_CTRL ; 18/12 ___ctrl_R___
+ .byte CT_CTRL ; 19/13 ___ctrl_S___
+ .byte CT_CTRL ; 20/14 ___ctrl_T___
+ .byte CT_CTRL ; 21/15 ___ctrl_U___
+ .byte CT_CTRL ; 22/16 ___ctrl_V___
+ .byte CT_CTRL ; 23/17 ___ctrl_W___
+ .byte CT_CTRL ; 24/18 ___ctrl_X___
+ .byte CT_CTRL ; 25/19 ___ctrl_Y___
+ .byte CT_CTRL ; 26/1a ___ctrl_Z___
+ .byte CT_CTRL ; 27/1b ___ctrl_[___
+ .byte CT_CTRL ; 28/1c ___ctrl_\___
+ .byte CT_CTRL ; 29/1d ___ctrl_]___
+ .byte CT_CTRL ; 30/1e ___ctrl_^___
+ .byte CT_CTRL ; 31/1f ___ctrl_____
+ .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___
+ .byte CT_NONE ; 33/21 _____!_____
+ .byte CT_NONE ; 34/22 _____"_____
+ .byte CT_NONE ; 35/23 _____#_____
+ .byte CT_NONE ; 36/24 _____$_____
+ .byte CT_NONE ; 37/25 _____%_____
+ .byte CT_NONE ; 38/26 _____&_____
+ .byte CT_NONE ; 39/27 _____'_____
+ .byte CT_NONE ; 40/28 _____(_____
+ .byte CT_NONE ; 41/29 _____)_____
+ .byte CT_NONE ; 42/2a _____*_____
+ .byte CT_NONE ; 43/2b _____+_____
+ .byte CT_NONE ; 44/2c _____,_____
+ .byte CT_NONE ; 45/2d _____-_____
+ .byte CT_NONE ; 46/2e _____._____
+ .byte CT_NONE ; 47/2f _____/_____
+ .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____
+ .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____
+ .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____
+ .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____
+ .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____
+ .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____
+ .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____
+ .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____
+ .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____
+ .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____
+ .byte CT_NONE ; 58/3a _____:_____
+ .byte CT_NONE ; 59/3b _____;_____
+ .byte CT_NONE ; 60/3c _____<_____
+ .byte CT_NONE ; 61/3d _____=_____
+ .byte CT_NONE ; 62/3e _____>_____
+ .byte CT_NONE ; 63/3f _____?_____
+
+ .byte CT_NONE ; 64/40 _____@_____
+ .byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____
+ .byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____
+ .byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____
+ .byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____
+ .byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____
+ .byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____
+ .byte CT_UPPER ; 71/47 _____G_____
+ .byte CT_UPPER ; 72/48 _____H_____
+ .byte CT_UPPER ; 73/49 _____I_____
+ .byte CT_UPPER ; 74/4a _____J_____
+ .byte CT_UPPER ; 75/4b _____K_____
+ .byte CT_UPPER ; 76/4c _____L_____
+ .byte CT_UPPER ; 77/4d _____M_____
+ .byte CT_UPPER ; 78/4e _____N_____
+ .byte CT_UPPER ; 79/4f _____O_____
+ .byte CT_UPPER ; 80/50 _____P_____
+ .byte CT_UPPER ; 81/51 _____Q_____
+ .byte CT_UPPER ; 82/52 _____R_____
+ .byte CT_UPPER ; 83/53 _____S_____
+ .byte CT_UPPER ; 84/54 _____T_____
+ .byte CT_UPPER ; 85/55 _____U_____
+ .byte CT_UPPER ; 86/56 _____V_____
+ .byte CT_UPPER ; 87/57 _____W_____
+ .byte CT_UPPER ; 88/58 _____X_____
+ .byte CT_UPPER ; 89/59 _____Y_____
+ .byte CT_UPPER ; 90/5a _____Z_____
+ .byte CT_NONE ; 91/5b _____[_____
+ .byte CT_NONE ; 92/5c _____\_____
+ .byte CT_NONE ; 93/5d _____]_____
+ .byte CT_NONE ; 94/5e _____^_____
+ .byte CT_NONE ; 95/5f _UNDERLINE_
+ .byte CT_NONE ; 96/60 ___grave___
+ .byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____
+ .byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____
+ .byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____
+ .byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____
+ .byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____
+ .byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____
+ .byte CT_LOWER ; 103/67 _____g_____
+ .byte CT_LOWER ; 104/68 _____h_____
+ .byte CT_LOWER ; 105/69 _____i_____
+ .byte CT_LOWER ; 106/6a _____j_____
+ .byte CT_LOWER ; 107/6b _____k_____
+ .byte CT_LOWER ; 108/6c _____l_____
+ .byte CT_LOWER ; 109/6d _____m_____
+ .byte CT_LOWER ; 110/6e _____n_____
+ .byte CT_LOWER ; 111/6f _____o_____
+ .byte CT_LOWER ; 112/70 _____p_____
+ .byte CT_LOWER ; 113/71 _____q_____
+ .byte CT_LOWER ; 114/72 _____r_____
+ .byte CT_LOWER ; 115/73 _____s_____
+ .byte CT_LOWER ; 116/74 _____t_____
+ .byte CT_LOWER ; 117/75 _____u_____
+ .byte CT_LOWER ; 118/76 _____v_____
+ .byte CT_LOWER ; 119/77 _____w_____
+ .byte CT_LOWER ; 120/78 _____x_____
+ .byte CT_LOWER ; 121/79 _____y_____
+ .byte CT_LOWER ; 122/7a _____z_____
+ .byte CT_NONE ; 123/7b _____{_____
+ .byte CT_NONE ; 124/7c _____|_____
+ .byte CT_NONE ; 125/7d _____}_____
+ .byte CT_NONE ; 126/7e _____~_____
+ .byte CT_OTHER_WS ; 127/7f ____DEL____
+ .endrepeat
+
+
diff -Ncr cc65-2.13.2/libsrc/apple1/gotoxy.s cc65-2.13.2-apple1/libsrc/apple1/gotoxy.s
*** cc65-2.13.2/libsrc/apple1/gotoxy.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/gotoxy.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,22 ----
+ ;
+ ; Ullrich von Bassewitz, 06.08.1998
+ ;
+ ; void __fastcall__ gotoxy (unsigned char x, unsigned char y);
+ ; void __fastcall__ gotox (unsigned char x);
+ ;
+
+ .export _gotoxy, _gotox
+
+ .import popa, VTABZ
+
+ .include "apple1.inc"
+
+ _gotoxy:
+ clc
+ ; sta CV ; Store Y
+ ; jsr VTABZ
+ jsr popa ; Get X
+
+ _gotox:
+ ; sta CH ; Store X
+ rts
diff -Ncr cc65-2.13.2/libsrc/apple1/kbhit.s cc65-2.13.2-apple1/libsrc/apple1/kbhit.s
*** cc65-2.13.2/libsrc/apple1/kbhit.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/kbhit.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,18 ----
+ ;
+ ; Kevin Ruland
+ ; Ullrich von Bassewitz, 2005-03-25
+ ;
+ ; unsigned char kbhit (void);
+ ;
+
+ .export _kbhit
+
+ .include "apple1.inc"
+
+ _kbhit:
+ lda KBDRDY ; Reading KBDRDY checks for keypress
+ rol ; if high bit is set, key was pressed
+ lda #$00
+ tax
+ rol
+ rts
diff -Ncr cc65-2.13.2/libsrc/apple1/randomize.s cc65-2.13.2-apple1/libsrc/apple1/randomize.s
*** cc65-2.13.2/libsrc/apple1/randomize.s Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/libsrc/apple1/randomize.s Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,17 ----
+ ;
+ ; Ullrich von Bassewitz, 07.11.2002
+ ;
+ ; void _randomize (void);
+ ; /* Initialize the random number generator */
+ ;
+
+ .export __randomize
+ .import _srand
+
+ .include "apple1.inc"
+
+ __randomize:
+ ldx #$EA ; Use random value supplied by ROM
+ lda #$55
+ jmp _srand ; Initialize generator
+
diff -Ncr cc65-2.13.2/src/ca65/main.c cc65-2.13.2-apple1/src/ca65/main.c
*** cc65-2.13.2/src/ca65/main.c Mon Sep 28 14:12:43 2009
--- cc65-2.13.2-apple1/src/ca65/main.c Tue Sep 13 18:42:27 2011
***************
*** 243,248 ****
--- 243,256 ----
NewSymbol ("__APPLE2ENH__", 1);
break;
+ case TGT_APPLE1:
+ NewSymbol ("__APPLE1__", 1);
+ break;
+
+ case TGT_REPLICA1:
+ NewSymbol ("__REPLICA1__", 1);
+ break;
+
case TGT_GEOS:
/* Do not handle as a CBM system */
NewSymbol ("__GEOS__", 1);
diff -Ncr cc65-2.13.2/src/ca65/main.c.orig cc65-2.13.2-apple1/src/ca65/main.c.orig
*** cc65-2.13.2/src/ca65/main.c.orig Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/ca65/main.c.orig Mon Sep 28 14:12:43 2009
***************
*** 0 ****
--- 1,993 ----
+ /*****************************************************************************/
+ /* */
+ /* main.c */
+ /* */
+ /* Main program for the ca65 macroassembler */
+ /* */
+ /* */
+ /* */
+ /* (C) 1998-2009, Ullrich von Bassewitz */
+ /* Roemerstrasse 52 */
+ /* D-70794 Filderstadt */
+ /* EMail: uz@cc65.org */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <time.h>
+
+ /* common */
+ #include "addrsize.h"
+ #include "chartype.h"
+ #include "cmdline.h"
+ #include "mmodel.h"
+ #include "print.h"
+ #include "strbuf.h"
+ #include "target.h"
+ #include "tgttrans.h"
+ #include "version.h"
+
+ /* ca65 */
+ #include "abend.h"
+ #include "asserts.h"
+ #include "error.h"
+ #include "expr.h"
+ #include "feature.h"
+ #include "filetab.h"
+ #include "global.h"
+ #include "incpath.h"
+ #include "instr.h"
+ #include "istack.h"
+ #include "lineinfo.h"
+ #include "listing.h"
+ #include "macpack.h"
+ #include "macro.h"
+ #include "nexttok.h"
+ #include "objfile.h"
+ #include "options.h"
+ #include "pseudo.h"
+ #include "scanner.h"
+ #include "segment.h"
+ #include "sizeof.h"
+ #include "spool.h"
+ #include "symtab.h"
+ #include "ulabel.h"
+
+
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+
+ static void Usage (void)
+ /* Print usage information and exit */
+ {
+ printf ("Usage: %s [options] file\n"
+ "Short options:\n"
+ " -D name[=value]\tDefine a symbol\n"
+ " -I dir\t\tSet an include directory search path\n"
+ " -U\t\t\tMark unresolved symbols as import\n"
+ " -V\t\t\tPrint the assembler version\n"
+ " -W n\t\t\tSet warning level n\n"
+ " -g\t\t\tAdd debug info to object file\n"
+ " -h\t\t\tHelp (this text)\n"
+ " -i\t\t\tIgnore case of symbols\n"
+ " -l\t\t\tCreate a listing if assembly was ok\n"
+ " -mm model\t\tSet the memory model\n"
+ " -o name\t\tName the output file\n"
+ " -s\t\t\tEnable smart mode\n"
+ " -t sys\t\tSet the target system\n"
+ " -v\t\t\tIncrease verbosity\n"
+ "\n"
+ "Long options:\n"
+ " --auto-import\t\tMark unresolved symbols as import\n"
+ " --cpu type\t\tSet cpu type\n"
+ " --debug-info\t\tAdd debug info to object file\n"
+ " --feature name\tSet an emulation feature\n"
+ " --forget-inc-paths\tForget include search paths\n"
+ " --help\t\tHelp (this text)\n"
+ " --ignore-case\t\tIgnore case of symbols\n"
+ " --include-dir dir\tSet an include directory search path\n"
+ " --listing\t\tCreate a listing if assembly was ok\n"
+ " --list-bytes n\tMaximum number of bytes per listing line\n"
+ " --macpack-dir dir\tSet a macro package directory\n"
+ " --memory-model model\tSet the memory model\n"
+ " --pagelength n\tSet the page length for the listing\n"
+ " --smart\t\tEnable smart mode\n"
+ " --target sys\t\tSet the target system\n"
+ " --verbose\t\tIncrease verbosity\n"
+ " --version\t\tPrint the assembler version\n",
+ ProgName);
+ }
+
+
+
+ static void SetOptions (void)
+ /* Set the option for the translator */
+ {
+ StrBuf Buf = STATIC_STRBUF_INITIALIZER;
+
+ /* Set the translator */
+ SB_Printf (&Buf, "ca65 V%s", GetVersionAsString ());
+ OptTranslator (&Buf);
+
+ /* Set date and time */
+ OptDateTime ((unsigned long) time(0));
+
+ /* Release memory for the string */
+ SB_Done (&Buf);
+ }
+
+
+
+ static void NewSymbol (const char* SymName, long Val)
+ /* Define a symbol with a fixed numeric value in the current scope */
+ {
+ ExprNode* Expr;
+ SymEntry* Sym;
+
+ /* Convert the name to a string buffer */
+ StrBuf SymBuf = STATIC_STRBUF_INITIALIZER;
+ SB_CopyStr (&SymBuf, SymName);
+
+ /* Search for the symbol, allocate a new one if it doesn't exist */
+ Sym = SymFind (CurrentScope, &SymBuf, SYM_ALLOC_NEW);
+
+ /* Check if have already a symbol with this name */
+ if (SymIsDef (Sym)) {
+ AbEnd ("`%s' is already defined", SymName);
+ }
+
+ /* Generate an expression for the symbol */
+ Expr = GenLiteralExpr (Val);
+
+ /* Mark the symbol as defined */
+ SymDef (Sym, Expr, ADDR_SIZE_DEFAULT, SF_NONE);
+
+ /* Free string buffer memory */
+ SB_Done (&SymBuf);
+ }
+
+
+
+ static void CBMSystem (const char* Sys)
+ /* Define a CBM system */
+ {
+ NewSymbol ("__CBM__", 1);
+ NewSymbol (Sys, 1);
+ }
+
+
+
+ static void SetSys (const char* Sys)
+ /* Define a target system */
+ {
+ switch (Target = FindTarget (Sys)) {
+
+ case TGT_NONE:
+ break;
+
+ case TGT_MODULE:
+ AbEnd ("Cannot use `module' as a target for the assembler");
+ break;
+
+ case TGT_ATARI:
+ NewSymbol ("__ATARI__", 1);
+ break;
+
+ case TGT_C16:
+ CBMSystem ("__C16__");
+ break;
+
+ case TGT_C64:
+ CBMSystem ("__C64__");
+ break;
+
+ case TGT_VIC20:
+ CBMSystem ("__VIC20__");
+ break;
+
+ case TGT_C128:
+ CBMSystem ("__C128__");
+ break;
+
+ case TGT_PLUS4:
+ CBMSystem ("__PLUS4__");
+ break;
+
+ case TGT_CBM510:
+ CBMSystem ("__CBM510__");
+ break;
+
+ case TGT_CBM610:
+ CBMSystem ("__CBM610__");
+ break;
+
+ case TGT_PET:
+ CBMSystem ("__PET__");
+ break;
+
+ case TGT_BBC:
+ NewSymbol ("__BBC__", 1);
+ break;
+
+ case TGT_APPLE2:
+ NewSymbol ("__APPLE2__", 1);
+ break;
+
+ case TGT_APPLE2ENH:
+ NewSymbol ("__APPLE2ENH__", 1);
+ break;
+
+ case TGT_GEOS:
+ /* Do not handle as a CBM system */
+ NewSymbol ("__GEOS__", 1);
+ break;
+
+ case TGT_LUNIX:
+ NewSymbol ("__LUNIX__", 1);
+ break;
+
+ case TGT_ATMOS:
+ NewSymbol ("__ATMOS__", 1);
+ break;
+
+ case TGT_NES:
+ NewSymbol ("__NES__", 1);
+ break;
+
+ case TGT_SUPERVISION:
+ NewSymbol ("__SUPERVISION__", 1);
+ break;
+
+ case TGT_LYNX:
+ NewSymbol ("__LYNX__", 1);
+ break;
+
+ default:
+ AbEnd ("Invalid target name: `%s'", Sys);
+
+ }
+
+ /* Initialize the translation tables for the target system */
+ TgtTranslateInit ();
+ }
+
+
+
+ static void DefineSymbol (const char* Def)
+ /* Define a symbol from the command line */
+ {
+ const char* P;
+ unsigned I;
+ long Val;
+ StrBuf SymName = AUTO_STRBUF_INITIALIZER;
+
+
+ /* The symbol must start with a character or underline */
+ if (!IsIdStart (Def [0])) {
+ InvDef (Def);
+ }
+ P = Def;
+
+ /* Copy the symbol, checking the rest */
+ I = 0;
+ while (IsIdChar (*P)) {
+ SB_AppendChar (&SymName, *P++);
+ }
+ SB_Terminate (&SymName);
+
+ /* Do we have a value given? */
+ if (*P != '=') {
+ if (*P != '\0') {
+ InvDef (Def);
+ }
+ Val = 0;
+ } else {
+ /* We have a value */
+ ++P;
+ if (*P == '$') {
+ ++P;
+ if (sscanf (P, "%lx", &Val) != 1) {
+ InvDef (Def);
+ }
+ } else {
+ if (sscanf (P, "%li", &Val) != 1) {
+ InvDef (Def);
+ }
+ }
+ }
+
+ /* Define the new symbol */
+ NewSymbol (SB_GetConstBuf (&SymName), Val);
+
+ /* Release string memory */
+ SB_Done (&SymName);
+ }
+
+
+
+ static void OptAutoImport (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Mark unresolved symbols as imported */
+ {
+ AutoImport = 1;
+ }
+
+
+
+ static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --cpu option */
+ {
+ cpu_t CPU = FindCPU (Arg);
+ if (CPU == CPU_UNKNOWN) {
+ AbEnd ("Invalid CPU: `%s'", Arg);
+ } else {
+ SetCPU (CPU);
+ }
+ }
+
+
+
+ static void OptDebugInfo (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Add debug info to the object file */
+ {
+ DbgSyms = 1;
+ }
+
+
+
+ static void OptFeature (const char* Opt attribute ((unused)), const char* Arg)
+ /* Set an emulation feature */
+ {
+ /* Make a string buffer from Arg */
+ StrBuf Feature;
+
+ /* Set the feature, check for errors */
+ if (SetFeature (SB_InitFromString (&Feature, Arg)) == FEAT_UNKNOWN) {
+ AbEnd ("Illegal emulation feature: `%s'", Arg);
+ }
+ }
+
+
+
+ static void OptForgetIncPaths (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Forget all currently defined include paths */
+ {
+ ForgetAllIncludePaths ();
+ }
+
+
+
+ static void OptHelp (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Print usage information and exit */
+ {
+ Usage ();
+ exit (EXIT_SUCCESS);
+ }
+
+
+
+ static void OptIgnoreCase (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Ignore case on symbols */
+ {
+ IgnoreCase = 1;
+ }
+
+
+
+ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
+ /* Add an include search path */
+ {
+ AddIncludePath (Arg);
+ }
+
+
+
+ static void OptListBytes (const char* Opt, const char* Arg)
+ /* Set the maximum number of bytes per listing line */
+ {
+ unsigned Num;
+ char Check;
+
+ /* Convert the argument to a number */
+ if (sscanf (Arg, "%u%c", &Num, &Check) != 1) {
+ AbEnd ("Invalid argument for option `%s'", Opt);
+ }
+
+ /* Check the bounds */
+ if (Num != 0 && (Num < MIN_LIST_BYTES || Num > MAX_LIST_BYTES)) {
+ AbEnd ("Argument for option `%s' is out of range", Opt);
+ }
+
+ /* Use the value */
+ SetListBytes (Num);
+ }
+
+
+
+ static void OptListing (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Create a listing file */
+ {
+ Listing = 1;
+ }
+
+
+
+ static void OptMacPackDir (const char* Opt attribute ((unused)), const char* Arg)
+ /* Set a macro package directory */
+ {
+ /* Make a string buffer from Arg */
+ StrBuf Dir;
+
+ /* Use the directory */
+ MacPackSetDir (SB_InitFromString (&Dir, Arg));
+ }
+
+
+
+ static void OptMemoryModel (const char* Opt, const char* Arg)
+ /* Set the memory model */
+ {
+ mmodel_t M;
+
+ /* Check the current memory model */
+ if (MemoryModel != MMODEL_UNKNOWN) {
+ AbEnd ("Cannot use option `%s' twice", Opt);
+ }
+
+ /* Translate the memory model name and check it */
+ M = FindMemoryModel (Arg);
+ if (M == MMODEL_UNKNOWN) {
+ AbEnd ("Unknown memory model: %s", Arg);
+ } else if (M == MMODEL_HUGE) {
+ AbEnd ("Unsupported memory model: %s", Arg);
+ }
+
+ /* Set the memory model */
+ SetMemoryModel (M);
+ }
+
+
+
+ static void OptPageLength (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --pagelength option */
+ {
+ int Len = atoi (Arg);
+ if (Len != -1 && (Len < MIN_PAGE_LEN || Len > MAX_PAGE_LEN)) {
+ AbEnd ("Invalid page length: %d", Len);
+ }
+ PageLength = Len;
+ }
+
+
+
+ static void OptSmart (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Handle the -s/--smart options */
+ {
+ SmartMode = 1;
+ }
+
+
+
+ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
+ /* Set the target system */
+ {
+ SetSys (Arg);
+ }
+
+
+
+ static void OptVerbose (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Increase verbosity */
+ {
+ ++Verbosity;
+ }
+
+
+
+ static void OptVersion (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Print the assembler version */
+ {
+ fprintf (stderr, "ca65 V%s - %s\n", GetVersionAsString (), Copyright);
+ }
+
+
+
+ static void DoPCAssign (void)
+ /* Start absolute code */
+ {
+ long PC = ConstExpression ();
+ if (PC < 0 || PC > 0xFFFFFF) {
+ Error ("Range error");
+ } else {
+ EnterAbsoluteMode (PC);
+ }
+ }
+
+
+
+ static void OneLine (void)
+ /* Assemble one line */
+ {
+ Segment* Seg = 0;
+ unsigned long PC = 0;
+ SymEntry* Sym = 0;
+ int Macro = 0;
+ int Instr = -1;
+
+ /* Initialize the new listing line if we are actually reading from file
+ * and not from internally pushed input.
+ */
+ if (!HavePushedInput ()) {
+ InitListingLine ();
+ }
+
+ if (Tok == TOK_COLON) {
+ /* An unnamed label */
+ ULabDef ();
+ NextTok ();
+ }
+
+ /* If the first token on the line is an identifier, check for a macro or
+ * an instruction.
+ */
+ if (Tok == TOK_IDENT) {
+ if (!UbiquitousIdents) {
+ /* Macros and symbols cannot use instruction names */
+ Instr = FindInstruction (&SVal);
+ if (Instr < 0) {
+ Macro = IsMacro (&SVal);
+ }
+ } else {
+ /* Macros and symbols may use the names of instructions */
+ Macro = IsMacro (&SVal);
+ }
+ }
+
+ /* Handle an identifier */
+ if (Tok == TOK_LOCAL_IDENT || (Tok == TOK_IDENT && Instr < 0 && !Macro)) {
+
+ /* Did we have whitespace before the ident? */
+ int HadWS = WS;
+
+ /* Generate the symbol table entry, then skip the name */
+ if (Tok == TOK_IDENT) {
+ Sym = SymFind (CurrentScope, &SVal, SYM_ALLOC_NEW);
+ } else {
+ Sym = SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW);
+ }
+ NextTok ();
+
+ /* If a colon follows, this is a label definition. If there
+ * is no colon, it's an assignment.
+ */
+ if (Tok == TOK_EQ || Tok == TOK_ASSIGN) {
+
+ /* Determine the symbol flags from the assignment token */
+ unsigned Flags = (Tok == TOK_ASSIGN)? SF_LABEL : SF_NONE;
+
+ /* Skip the '=' */
+ NextTok ();
+
+ /* Define the symbol with the expression following the '=' */
+ SymDef (Sym, Expression(), ADDR_SIZE_DEFAULT, Flags);
+
+ /* Don't allow anything after a symbol definition */
+ ConsumeSep ();
+ return;
+
+ } else if (Tok == TOK_SET) {
+
+ ExprNode* Expr;
+
+ /* .SET defines variables (= redefinable symbols) */
+ NextTok ();
+
+ /* Read the assignment expression, which must be constant */
+ Expr = GenLiteralExpr (ConstExpression ());
+
+ /* Define the symbol with the constant expression following
+ * the '='
+ */
+ SymDef (Sym, Expr, ADDR_SIZE_DEFAULT, SF_VAR);
+
+ /* Don't allow anything after a symbol definition */
+ ConsumeSep ();
+ return;
+
+ } else {
+
+ /* A label. Remember the current segment, so we can later
+ * determine the size of the data stored under the label.
+ */
+ Seg = ActiveSeg;
+ PC = GetPC ();
+
+ /* Define the label */
+ SymDef (Sym, GenCurrentPC (), ADDR_SIZE_DEFAULT, SF_LABEL);
+
+ /* Skip the colon. If NoColonLabels is enabled, allow labels
+ * without a colon if there is no whitespace before the
+ * identifier.
+ */
+ if (Tok != TOK_COLON) {
+ if (HadWS || !NoColonLabels) {
+ Error ("`:' expected");
+ /* Try some smart error recovery */
+ if (Tok == TOK_NAMESPACE) {
+ NextTok ();
+ }
+ }
+ } else {
+ /* Skip the colon */
+ NextTok ();
+ }
+
+ /* If we come here, a new identifier may be waiting, which may
+ * be a macro or instruction.
+ */
+ if (Tok == TOK_IDENT) {
+ if (!UbiquitousIdents) {
+ /* Macros and symbols cannot use instruction names */
+ Instr = FindInstruction (&SVal);
+ if (Instr < 0) {
+ Macro = IsMacro (&SVal);
+ }
+ } else {
+ /* Macros and symbols may use the names of instructions */
+ Macro = IsMacro (&SVal);
+ }
+ }
+ }
+ }
+
+ /* We've handled a possible label, now handle the remainder of the line */
+ if (Tok >= TOK_FIRSTPSEUDO && Tok <= TOK_LASTPSEUDO) {
+ /* A control command */
+ HandlePseudo ();
+ } else if (Macro) {
+ /* A macro expansion */
+ MacExpandStart ();
+ } else if (Instr >= 0 ||
+ (UbiquitousIdents && ((Instr = FindInstruction (&SVal)) >= 0))) {
+ /* A mnemonic - assemble one instruction */
+ HandleInstruction (Instr);
+ } else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
+ NextTok ();
+ if (Tok != TOK_EQ) {
+ Error ("`=' expected");
+ SkipUntilSep ();
+ } else {
+ /* Skip the equal sign */
+ NextTok ();
+ /* Enter absolute mode */
+ DoPCAssign ();
+ }
+ }
+
+ /* If we have defined a label, remember its size. Sym is also set by
+ * a symbol assignment, but in this case Done is false, so we don't
+ * come here.
+ */
+ if (Sym) {
+ unsigned long Size;
+ if (Seg == ActiveSeg) {
+ /* Same segment */
+ Size = GetPC () - PC;
+ } else {
+ /* The line has switched the segment */
+ Size = 0;
+ }
+ DefSizeOfSymbol (Sym, Size);
+ }
+
+ /* Line separator must come here */
+ ConsumeSep ();
+ }
+
+
+
+ static void Assemble (void)
+ /* Start the ball rolling ... */
+ {
+ /* Prime the pump */
+ NextTok ();
+
+ /* Assemble lines until end of file */
+ while (Tok != TOK_EOF) {
+ OneLine ();
+ }
+ }
+
+
+
+ static void CreateObjFile (void)
+ /* Create the object file */
+ {
+ /* Open the object, write the header */
+ ObjOpen ();
+
+ /* Write the object file options */
+ WriteOptions ();
+
+ /* Write the list of input files */
+ WriteFiles ();
+
+ /* Write the segment data to the file */
+ WriteSegments ();
+
+ /* Write the import list */
+ WriteImports ();
+
+ /* Write the export list */
+ WriteExports ();
+
+ /* Write debug symbols if requested */
+ WriteDbgSyms ();
+
+ /* Write line infos if requested */
+ WriteLineInfo ();
+
+ /* Write the string pool */
+ WriteStrPool ();
+
+ /* Write the assertions */
+ WriteAssertions ();
+
+ /* Write an updated header and close the file */
+ ObjClose ();
+ }
+
+
+
+ int main (int argc, char* argv [])
+ /* Assembler main program */
+ {
+ /* Program long options */
+ static const LongOpt OptTab[] = {
+ { "--auto-import", 0, OptAutoImport },
+ { "--cpu", 1, OptCPU },
+ { "--debug-info", 0, OptDebugInfo },
+ { "--feature", 1, OptFeature },
+ { "--forget-inc-paths", 0, OptForgetIncPaths },
+ { "--help", 0, OptHelp },
+ { "--ignore-case", 0, OptIgnoreCase },
+ { "--include-dir", 1, OptIncludeDir },
+ { "--list-bytes", 1, OptListBytes },
+ { "--listing", 0, OptListing },
+ { "--macpack-dir", 1, OptMacPackDir },
+ { "--memory-model", 1, OptMemoryModel },
+ { "--pagelength", 1, OptPageLength },
+ { "--smart", 0, OptSmart },
+ { "--target", 1, OptTarget },
+ { "--verbose", 0, OptVerbose },
+ { "--version", 0, OptVersion },
+ };
+
+ /* Name of the global name space */
+ static const StrBuf GlobalNameSpace = STATIC_STRBUF_INITIALIZER;
+
+ unsigned I;
+
+ /* Initialize the cmdline module */
+ InitCmdLine (&argc, &argv, "ca65");
+
+ /* Initialize the include search paths */
+ InitIncludePaths ();
+
+ /* Enter the base lexical level. We must do that here, since we may
+ * define symbols using -D.
+ */
+ SymEnterLevel (&GlobalNameSpace, ST_GLOBAL, ADDR_SIZE_DEFAULT);
+
+ /* Check the parameters */
+ I = 1;
+ while (I < ArgCount) {
+
+ /* Get the argument */
+ const char* Arg = ArgVec [I];
+
+ /* Check for an option */
+ if (Arg[0] == '-') {
+ switch (Arg[1]) {
+
+ case '-':
+ LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
+ break;
+
+ case 'g':
+ OptDebugInfo (Arg, 0);
+ break;
+
+ case 'h':
+ OptHelp (Arg, 0);
+ break;
+
+ case 'i':
+ OptIgnoreCase (Arg, 0);
+ break;
+
+ case 'l':
+ OptListing (Arg, 0);
+ break;
+
+ case 'm':
+ if (Arg[2] == 'm') {
+ OptMemoryModel (Arg, GetArg (&I, 3));
+ } else {
+ UnknownOption (Arg);
+ }
+ break;
+
+ case 'o':
+ OutFile = GetArg (&I, 2);
+ break;
+
+ case 's':
+ OptSmart (Arg, 0);
+ break;
+
+ case 't':
+ OptTarget (Arg, GetArg (&I, 2));
+ break;
+
+ case 'v':
+ OptVerbose (Arg, 0);
+ break;
+
+ case 'D':
+ DefineSymbol (GetArg (&I, 2));
+ break;
+
+ case 'I':
+ OptIncludeDir (Arg, GetArg (&I, 2));
+ break;
+
+ case 'U':
+ OptAutoImport (Arg, 0);
+ break;
+
+ case 'V':
+ OptVersion (Arg, 0);
+ break;
+
+ case 'W':
+ WarnLevel = atoi (GetArg (&I, 2));
+ break;
+
+ default:
+ UnknownOption (Arg);
+ break;
+
+ }
+ } else {
+ /* Filename. Check if we already had one */
+ if (InFile) {
+ fprintf (stderr, "%s: Don't know what to do with `%s'\n",
+ ProgName, Arg);
+ exit (EXIT_FAILURE);
+ } else {
+ InFile = Arg;
+ }
+ }
+
+ /* Next argument */
+ ++I;
+ }
+
+ /* Do we have an input file? */
+ if (InFile == 0) {
+ fprintf (stderr, "%s: No input files\n", ProgName);
+ exit (EXIT_FAILURE);
+ }
+
+ /* If no CPU given, use the default CPU for the target */
+ if (GetCPU () == CPU_UNKNOWN) {
+ if (Target != TGT_UNKNOWN) {
+ SetCPU (DefaultCPU[Target]);
+ } else {
+ SetCPU (CPU_6502);
+ }
+ }
+
+ /* If no memory model was given, use the default */
+ if (MemoryModel == MMODEL_UNKNOWN) {
+ SetMemoryModel (MMODEL_NEAR);
+ }
+
+ /* Initialize the segments */
+ InitSegments ();
+
+ /* Initialize the scanner, open the input file */
+ InitScanner (InFile);
+
+ /* Define the default options */
+ SetOptions ();
+
+ /* Assemble the input */
+ Assemble ();
+
+ /* If we didn't have any errors, check the segment stack */
+ if (ErrorCount == 0) {
+ SegStackCheck ();
+ }
+
+ /* If we didn't have any errors, check the unnamed labels */
+ if (ErrorCount == 0) {
+ ULabCheck ();
+ }
+
+ /* If we didn't have any errors, check the symbol table */
+ if (ErrorCount == 0) {
+ SymCheck ();
+ }
+
+ /* If we didn't have any errors, check and resolve the segment data */
+ if (ErrorCount == 0) {
+ SegCheck ();
+ }
+
+ /* If we didn't have any errors, check the assertions */
+ if (ErrorCount == 0) {
+ CheckAssertions ();
+ }
+
+ /* If we didn't have an errors, index the line infos */
+ MakeLineInfoIndex ();
+
+ /* Dump the data */
+ if (Verbosity >= 2) {
+ SymDump (stdout);
+ SegDump ();
+ }
+
+ /* If we didn't have any errors, create the object and listing files */
+ if (ErrorCount == 0) {
+ CreateObjFile ();
+ if (Listing) {
+ CreateListing ();
+ }
+ }
+
+ /* Close the input file */
+ DoneScanner ();
+
+ /* Return an apropriate exit code */
+ return (ErrorCount == 0)? EXIT_SUCCESS : EXIT_FAILURE;
+ }
+
+
+
diff -Ncr cc65-2.13.2/src/cc65/main.c cc65-2.13.2-apple1/src/cc65/main.c
*** cc65-2.13.2/src/cc65/main.c Mon Sep 28 14:12:43 2009
--- cc65-2.13.2-apple1/src/cc65/main.c Tue Sep 13 18:42:27 2011
***************
*** 205,210 ****
--- 205,218 ----
DefineNumericMacro ("__APPLE2ENH__", 1);
break;
+ case TGT_APPLE1:
+ DefineNumericMacro ("__APPLE1__", 1);
+ break;
+
+ case TGT_REPLICA1:
+ DefineNumericMacro ("__REPLICA1__", 1);
+ break;
+
case TGT_GEOS:
/* Do not handle as a CBM system */
DefineNumericMacro ("__GEOS__", 1);
diff -Ncr cc65-2.13.2/src/cc65/main.c.orig cc65-2.13.2-apple1/src/cc65/main.c.orig
*** cc65-2.13.2/src/cc65/main.c.orig Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/cc65/main.c.orig Mon Sep 28 14:12:43 2009
***************
*** 0 ****
--- 1,917 ----
+ /*****************************************************************************/
+ /* */
+ /* main.c */
+ /* */
+ /* cc65 main program */
+ /* */
+ /* */
+ /* */
+ /* (C) 2000-2009, Ullrich von Bassewitz */
+ /* Roemerstrasse 52 */
+ /* D-70794 Filderstadt */
+ /* EMail: uz@cc65.org */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include <errno.h>
+
+ /* common */
+ #include "abend.h"
+ #include "chartype.h"
+ #include "cmdline.h"
+ #include "cpu.h"
+ #include "debugflag.h"
+ #include "fname.h"
+ #include "mmodel.h"
+ #include "print.h"
+ #include "segnames.h"
+ #include "target.h"
+ #include "tgttrans.h"
+ #include "version.h"
+ #include "xmalloc.h"
+
+ /* cc65 */
+ #include "asmcode.h"
+ #include "compile.h"
+ #include "codeopt.h"
+ #include "error.h"
+ #include "global.h"
+ #include "incpath.h"
+ #include "input.h"
+ #include "macrotab.h"
+ #include "output.h"
+ #include "scanner.h"
+ #include "segments.h"
+ #include "standard.h"
+ #include "svnversion.h"
+
+
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+
+ static void Usage (void)
+ /* Print usage information to stderr */
+ {
+ printf ("Usage: %s [options] file\n"
+ "Short options:\n"
+ " -Cl\t\t\tMake local variables static\n"
+ " -Dsym[=defn]\t\tDefine a symbol\n"
+ " -E\t\t\tStop after the preprocessing stage\n"
+ " -I dir\t\tSet an include directory search path\n"
+ " -O\t\t\tOptimize code\n"
+ " -Oi\t\t\tOptimize code, inline more code\n"
+ " -Or\t\t\tEnable register variables\n"
+ " -Os\t\t\tInline some known functions\n"
+ " -T\t\t\tInclude source as comment\n"
+ " -V\t\t\tPrint the compiler version number\n"
+ " -W\t\t\tSuppress warnings\n"
+ " -d\t\t\tDebug mode\n"
+ " -g\t\t\tAdd debug info to object file\n"
+ " -h\t\t\tHelp (this text)\n"
+ " -j\t\t\tDefault characters are signed\n"
+ " -mm model\t\tSet the memory model\n"
+ " -o name\t\tName the output file\n"
+ " -r\t\t\tEnable register variables\n"
+ " -t sys\t\tSet the target system\n"
+ " -v\t\t\tIncrease verbosity\n"
+ "\n"
+ "Long options:\n"
+ " --add-source\t\tInclude source as comment\n"
+ " --bss-name seg\tSet the name of the BSS segment\n"
+ " --check-stack\t\tGenerate stack overflow checks\n"
+ " --code-name seg\tSet the name of the CODE segment\n"
+ " --codesize x\t\tAccept larger code by factor x\n"
+ " --cpu type\t\tSet cpu type (6502, 65c02)\n"
+ " --create-dep\t\tCreate a make dependency file\n"
+ " --data-name seg\tSet the name of the DATA segment\n"
+ " --debug\t\tDebug mode\n"
+ " --debug-info\t\tAdd debug info to object file\n"
+ " --debug-opt name\tDebug optimization steps\n"
+ " --disable-opt name\tDisable an optimization step\n"
+ " --enable-opt name\tEnable an optimization step\n"
+ " --forget-inc-paths\tForget include search paths\n"
+ " --help\t\tHelp (this text)\n"
+ " --include-dir dir\tSet an include directory search path\n"
+ " --list-opt-steps\tList all optimizer steps and exit\n"
+ " --memory-model model\tSet the memory model\n"
+ " --register-space b\tSet space available for register variables\n"
+ " --register-vars\tEnable register variables\n"
+ " --rodata-name seg\tSet the name of the RODATA segment\n"
+ " --signed-chars\tDefault characters are signed\n"
+ " --standard std\tLanguage standard (c89, c99, cc65)\n"
+ " --static-locals\tMake local variables static\n"
+ " --target sys\t\tSet the target system\n"
+ " --verbose\t\tIncrease verbosity\n"
+ " --version\t\tPrint the compiler version number\n"
+ " --writable-strings\tMake string literals writable\n",
+ ProgName);
+ }
+
+
+
+ static void cbmsys (const char* sys)
+ /* Define a CBM system */
+ {
+ DefineNumericMacro ("__CBM__", 1);
+ DefineNumericMacro (sys, 1);
+ }
+
+
+
+ static void SetSys (const char* Sys)
+ /* Define a target system */
+ {
+ switch (Target = FindTarget (Sys)) {
+
+ case TGT_NONE:
+ break;
+
+ case TGT_MODULE:
+ AbEnd ("Cannot use `module' as a target for the compiler");
+ break;
+
+ case TGT_ATARI:
+ DefineNumericMacro ("__ATARI__", 1);
+ break;
+
+ case TGT_C16:
+ cbmsys ("__C16__");
+ break;
+
+ case TGT_C64:
+ cbmsys ("__C64__");
+ break;
+
+ case TGT_VIC20:
+ cbmsys ("__VIC20__");
+ break;
+
+ case TGT_C128:
+ cbmsys ("__C128__");
+ break;
+
+ case TGT_PLUS4:
+ cbmsys ("__PLUS4__");
+ break;
+
+ case TGT_CBM510:
+ cbmsys ("__CBM510__");
+ break;
+
+ case TGT_CBM610:
+ cbmsys ("__CBM610__");
+ break;
+
+ case TGT_PET:
+ cbmsys ("__PET__");
+ break;
+
+ case TGT_BBC:
+ DefineNumericMacro ("__BBC__", 1);
+ break;
+
+ case TGT_APPLE2:
+ DefineNumericMacro ("__APPLE2__", 1);
+ break;
+
+ case TGT_APPLE2ENH:
+ DefineNumericMacro ("__APPLE2ENH__", 1);
+ break;
+
+ case TGT_GEOS:
+ /* Do not handle as a CBM system */
+ DefineNumericMacro ("__GEOS__", 1);
+ break;
+
+ case TGT_LUNIX:
+ DefineNumericMacro ("__LUNIX__", 1);
+ break;
+
+ case TGT_ATMOS:
+ DefineNumericMacro ("__ATMOS__", 1);
+ break;
+
+ case TGT_NES:
+ DefineNumericMacro ("__NES__", 1);
+ break;
+
+ case TGT_SUPERVISION:
+ DefineNumericMacro ("__SUPERVISION__", 1);
+ break;
+
+ case TGT_LYNX:
+ DefineNumericMacro ("__LYNX__", 1);
+ break;
+
+ default:
+ AbEnd ("Unknown target system type %d", Target);
+ }
+
+ /* Initialize the translation tables for the target system */
+ TgtTranslateInit ();
+ }
+
+
+
+ static void DoCreateDep (const char* OutputName)
+ /* Create the dependency file */
+ {
+ /* Make the dependency file name from the output file name */
+ char* DepName = MakeFilename (OutputName, ".u");
+
+ /* Open the file */
+ FILE* F = fopen (DepName, "w");
+ if (F == 0) {
+ Fatal ("Cannot open dependency file `%s': %s", DepName, strerror (errno));
+ }
+
+ /* Write the dependencies to the file */
+ WriteDependencies (F, OutputName);
+
+ /* Close the file, check for errors */
+ if (fclose (F) != 0) {
+ remove (DepName);
+ Fatal ("Cannot write to dependeny file (disk full?)");
+ }
+
+ /* Free the name */
+ xfree (DepName);
+ }
+
+
+
+ static void DefineSym (const char* Def)
+ /* Define a symbol on the command line */
+ {
+ const char* P = Def;
+
+ /* The symbol must start with a character or underline */
+ if (Def [0] != '_' && !IsAlpha (Def [0])) {
+ InvDef (Def);
+ }
+
+ /* Check the symbol name */
+ while (IsAlNum (*P) || *P == '_') {
+ ++P;
+ }
+
+ /* Do we have a value given? */
+ if (*P != '=') {
+ if (*P != '\0') {
+ InvDef (Def);
+ }
+ /* No value given. Define the macro with the value 1 */
+ DefineNumericMacro (Def, 1);
+ } else {
+ /* We have a value, P points to the '=' character. Since the argument
+ * is const, create a copy and replace the '=' in the copy by a zero
+ * terminator.
+ */
+ char* Q;
+ unsigned Len = strlen (Def)+1;
+ char* S = (char*) xmalloc (Len);
+ memcpy (S, Def, Len);
+ Q = S + (P - Def);
+ *Q++ = '\0';
+
+ /* Define this as a macro */
+ DefineTextMacro (S, Q);
+
+ /* Release the allocated memory */
+ xfree (S);
+ }
+ }
+
+
+
+ static void CheckSegName (const char* Seg)
+ /* Abort if the given name is not a valid segment name */
+ {
+ /* Print an error and abort if the name is not ok */
+ if (!ValidSegName (Seg)) {
+ AbEnd ("Segment name `%s' is invalid", Seg);
+ }
+ }
+
+
+
+ static void OptAddSource (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Add source lines as comments in generated assembler file */
+ {
+ AddSource = 1;
+ }
+
+
+
+ static void OptBssName (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --bss-name option */
+ {
+ /* Check for a valid name */
+ CheckSegName (Arg);
+
+ /* Set the name */
+ SetSegName (SEG_BSS, Arg);
+ }
+
+
+
+ static void OptCheckStack (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Handle the --check-stack option */
+ {
+ IS_Set (&CheckStack, 1);
+ }
+
+
+
+ static void OptCodeName (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --code-name option */
+ {
+ /* Check for a valid name */
+ CheckSegName (Arg);
+
+ /* Set the name */
+ SetSegName (SEG_CODE, Arg);
+ }
+
+
+
+ static void OptCodeSize (const char* Opt, const char* Arg)
+ /* Handle the --codesize option */
+ {
+ unsigned Factor;
+ char BoundsCheck;
+
+ /* Numeric argument expected */
+ if (sscanf (Arg, "%u%c", &Factor, &BoundsCheck) != 1 ||
+ Factor < 10 || Factor > 1000) {
+ AbEnd ("Argument for %s is invalid", Opt);
+ }
+ IS_Set (&CodeSizeFactor, Factor);
+ }
+
+
+
+ static void OptCreateDep (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Handle the --create-dep option */
+ {
+ CreateDep = 1;
+ }
+
+
+
+ static void OptCPU (const char* Opt, const char* Arg)
+ /* Handle the --cpu option */
+ {
+ /* Find the CPU from the given name */
+ CPU = FindCPU (Arg);
+ if (CPU != CPU_6502 && CPU != CPU_6502X && CPU != CPU_65SC02 &&
+ CPU != CPU_65C02 && CPU != CPU_65816 && CPU != CPU_HUC6280) {
+ AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
+ }
+ }
+
+
+
+ static void OptDataName (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --data-name option */
+ {
+ /* Check for a valid name */
+ CheckSegName (Arg);
+
+ /* Set the name */
+ SetSegName (SEG_DATA, Arg);
+ }
+
+
+
+ static void OptDebug (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Compiler debug mode */
+ {
+ ++Debug;
+ }
+
+
+
+ static void OptDebugInfo (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Add debug info to the object file */
+ {
+ DebugInfo = 1;
+ }
+
+
+
+ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg)
+ /* Debug optimization steps */
+ {
+ char Buf [128];
+ char* Line;
+
+ /* Open the file */
+ FILE* F = fopen (Arg, "r");
+ if (F == 0) {
+ AbEnd ("Cannot open `%s': %s", Arg, strerror (errno));
+ }
+
+ /* Read line by line, ignore empty lines and switch optimization
+ * steps on/off.
+ */
+ while (fgets (Buf, sizeof (Buf), F) != 0) {
+
+ /* Remove trailing control chars. This will also remove the
+ * trailing newline.
+ */
+ unsigned Len = strlen (Buf);
+ while (Len > 0 && IsControl (Buf[Len-1])) {
+ --Len;
+ }
+ Buf[Len] = '\0';
+
+ /* Get a pointer to the buffer and remove leading white space */
+ Line = Buf;
+ while (IsBlank (*Line)) {
+ ++Line;
+ }
+
+ /* Check the first character and enable/disable the step or
+ * ignore the line
+ */
+ switch (*Line) {
+
+ case '\0':
+ case '#':
+ case ';':
+ /* Empty or comment line */
+ continue;
+
+ case '-':
+ DisableOpt (Line+1);
+ break;
+
+ case '+':
+ ++Line;
+ /* FALLTHROUGH */
+
+ default:
+ EnableOpt (Line);
+ break;
+
+ }
+
+ }
+
+ /* Close the file, no error check here since we were just reading and
+ * this is only a debug function.
+ */
+ (void) fclose (F);
+ }
+
+
+
+ static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg)
+ /* Disable an optimization step */
+ {
+ DisableOpt (Arg);
+ }
+
+
+
+ static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg)
+ /* Enable an optimization step */
+ {
+ EnableOpt (Arg);
+ }
+
+
+
+ static void OptForgetIncPaths (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Forget all currently defined include paths */
+ {
+ ForgetAllIncludePaths ();
+ }
+
+
+
+ static void OptHelp (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Print usage information and exit */
+ {
+ Usage ();
+ exit (EXIT_SUCCESS);
+ }
+
+
+
+ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
+ /* Add an include search path */
+ {
+ AddIncludePath (Arg, INC_SYS | INC_USER);
+ }
+
+
+
+ static void OptListOptSteps (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* List all optimizer steps */
+ {
+ /* List the optimizer steps */
+ ListOptSteps (stdout);
+
+ /* Terminate */
+ exit (EXIT_SUCCESS);
+ }
+
+
+
+ static void OptMemoryModel (const char* Opt, const char* Arg)
+ /* Set the memory model */
+ {
+ mmodel_t M;
+
+ /* Check the current memory model */
+ if (MemoryModel != MMODEL_UNKNOWN) {
+ AbEnd ("Cannot use option `%s' twice", Opt);
+ }
+
+ /* Translate the memory model name and check it */
+ M = FindMemoryModel (Arg);
+ if (M == MMODEL_UNKNOWN) {
+ AbEnd ("Unknown memory model: %s", Arg);
+ } else if (M == MMODEL_HUGE) {
+ AbEnd ("Unsupported memory model: %s", Arg);
+ }
+
+ /* Set the memory model */
+ SetMemoryModel (M);
+ }
+
+
+
+ static void OptRegisterSpace (const char* Opt, const char* Arg)
+ /* Handle the --register-space option */
+ {
+ /* Numeric argument expected */
+ if (sscanf (Arg, "%u", &RegisterSpace) != 1 || RegisterSpace > 256) {
+ AbEnd ("Argument for option %s is invalid", Opt);
+ }
+ }
+
+
+
+ static void OptRegisterVars (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Handle the --register-vars option */
+ {
+ IS_Set (&EnableRegVars, 1);
+ }
+
+
+
+ static void OptRodataName (const char* Opt attribute ((unused)), const char* Arg)
+ /* Handle the --rodata-name option */
+ {
+ /* Check for a valid name */
+ CheckSegName (Arg);
+
+ /* Set the name */
+ SetSegName (SEG_RODATA, Arg);
+ }
+
+
+
+ static void OptSignedChars (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Make default characters signed */
+ {
+ IS_Set (&SignedChars, 1);
+ }
+
+
+
+ static void OptStandard (const char* Opt, const char* Arg)
+ /* Handle the --standard option */
+ {
+ /* Find the standard from the given name */
+ standard_t Std = FindStandard (Arg);
+ if (Std == STD_UNKNOWN) {
+ AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
+ } else if (IS_Get (&Standard) != STD_UNKNOWN) {
+ AbEnd ("Option %s given more than once", Opt);
+ } else {
+ IS_Set (&Standard, Std);
+ }
+ }
+
+
+
+ static void OptStaticLocals (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Place local variables in static storage */
+ {
+ IS_Set (&StaticLocals, 1);
+ }
+
+
+
+ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
+ /* Set the target system */
+ {
+ SetSys (Arg);
+ }
+
+
+
+ static void OptVerbose (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Increase verbosity */
+ {
+ ++Verbosity;
+ }
+
+
+
+ static void OptVersion (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Print the compiler version */
+ {
+ fprintf (stderr,
+ "cc65 V%s\nSVN version: %s\n",
+ GetVersionAsString (), SVNVersion);
+ exit (EXIT_SUCCESS);
+ }
+
+
+
+ static void OptWritableStrings (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+ /* Make string literals writable */
+ {
+ IS_Set (&WritableStrings, 1);
+ }
+
+
+
+ int main (int argc, char* argv[])
+ {
+ /* Program long options */
+ static const LongOpt OptTab[] = {
+ { "--add-source", 0, OptAddSource },
+ { "--bss-name", 1, OptBssName },
+ { "--check-stack", 0, OptCheckStack },
+ { "--code-name", 1, OptCodeName },
+ { "--codesize", 1, OptCodeSize },
+ { "--cpu", 1, OptCPU },
+ { "--create-dep", 0, OptCreateDep },
+ { "--data-name", 1, OptDataName },
+ { "--debug", 0, OptDebug },
+ { "--debug-info", 0, OptDebugInfo },
+ { "--debug-opt", 1, OptDebugOpt },
+ { "--disable-opt", 1, OptDisableOpt },
+ { "--enable-opt", 1, OptEnableOpt },
+ { "--forget-inc-paths", 0, OptForgetIncPaths },
+ { "--help", 0, OptHelp },
+ { "--include-dir", 1, OptIncludeDir },
+ { "--list-opt-steps", 0, OptListOptSteps },
+ { "--memory-model", 1, OptMemoryModel },
+ { "--register-space", 1, OptRegisterSpace },
+ { "--register-vars", 0, OptRegisterVars },
+ { "--rodata-name", 1, OptRodataName },
+ { "--signed-chars", 0, OptSignedChars },
+ { "--standard", 1, OptStandard },
+ { "--static-locals", 0, OptStaticLocals },
+ { "--target", 1, OptTarget },
+ { "--verbose", 0, OptVerbose },
+ { "--version", 0, OptVersion },
+ { "--writable-strings", 0, OptWritableStrings },
+ };
+
+ unsigned I;
+
+ /* Initialize the input file name */
+ const char* InputFile = 0;
+
+ /* Initialize the cmdline module */
+ InitCmdLine (&argc, &argv, "cc65");
+
+ /* Initialize the default segment names */
+ InitSegNames ();
+
+ /* Initialize the include search paths */
+ InitIncludePaths ();
+
+ /* Parse the command line */
+ I = 1;
+ while (I < ArgCount) {
+
+ const char* P;
+
+ /* Get the argument */
+ const char* Arg = ArgVec[I];
+
+ /* Check for an option */
+ if (Arg [0] == '-') {
+
+ switch (Arg [1]) {
+
+ case '-':
+ LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
+ break;
+
+ case 'd':
+ OptDebug (Arg, 0);
+ break;
+
+ case 'h':
+ case '?':
+ OptHelp (Arg, 0);
+ break;
+
+ case 'g':
+ OptDebugInfo (Arg, 0);
+ break;
+
+ case 'j':
+ OptSignedChars (Arg, 0);
+ break;
+
+ case 'o':
+ SetOutputName (GetArg (&I, 2));
+ break;
+
+ case 'r':
+ OptRegisterVars (Arg, 0);
+ break;
+
+ case 't':
+ OptTarget (Arg, GetArg (&I, 2));
+ break;
+
+ case 'u':
+ OptCreateDep (Arg, 0);
+ break;
+
+ case 'v':
+ OptVerbose (Arg, 0);
+ break;
+
+ case 'C':
+ P = Arg + 2;
+ while (*P) {
+ switch (*P++) {
+ case 'l':
+ OptStaticLocals (Arg, 0);
+ break;
+ default:
+ UnknownOption (Arg);
+ break;
+ }
+ }
+ break;
+
+ case 'D':
+ DefineSym (GetArg (&I, 2));
+ break;
+
+ case 'E':
+ PreprocessOnly = 1;
+ break;
+
+ case 'I':
+ OptIncludeDir (Arg, GetArg (&I, 2));
+ break;
+
+ case 'O':
+ IS_Set (&Optimize, 1);
+ P = Arg + 2;
+ while (*P) {
+ switch (*P++) {
+ case 'i':
+ IS_Set (&CodeSizeFactor, 200);
+ break;
+ case 'r':
+ IS_Set (&EnableRegVars, 1);
+ break;
+ case 's':
+ IS_Set (&InlineStdFuncs, 1);
+ break;
+ }
+ }
+ break;
+
+ case 'T':
+ OptAddSource (Arg, 0);
+ break;
+
+ case 'V':
+ OptVersion (Arg, 0);
+ break;
+
+ case 'W':
+ IS_Set (&WarnDisable, 1);
+ break;
+
+ default:
+ UnknownOption (Arg);
+ break;
+ }
+ } else {
+ if (InputFile) {
+ fprintf (stderr, "additional file specs ignored\n");
+ } else {
+ InputFile = Arg;
+ }
+ }
+
+ /* Next argument */
+ ++I;
+ }
+
+ /* Did we have a file spec on the command line? */
+ if (InputFile == 0) {
+ AbEnd ("No input files");
+ }
+
+ /* Create the output file name if it was not explicitly given */
+ MakeDefaultOutputName (InputFile);
+
+ /* If no CPU given, use the default CPU for the target */
+ if (CPU == CPU_UNKNOWN) {
+ if (Target != TGT_UNKNOWN) {
+ CPU = DefaultCPU[Target];
+ } else {
+ CPU = CPU_6502;
+ }
+ }
+
+ /* If no memory model was given, use the default */
+ if (MemoryModel == MMODEL_UNKNOWN) {
+ SetMemoryModel (MMODEL_NEAR);
+ }
+
+ /* If no language standard was given, use the default one */
+ if (IS_Get (&Standard) == STD_UNKNOWN) {
+ IS_Set (&Standard, STD_DEFAULT);
+ }
+
+ /* Go! */
+ Compile (InputFile);
+
+ /* Create the output file if we didn't had any errors */
+ if (PreprocessOnly == 0 && (ErrorCount == 0 || Debug)) {
+
+ /* Open the file */
+ OpenOutputFile ();
+
+ /* Write the output to the file */
+ WriteAsmOutput ();
+ Print (stdout, 1, "Wrote output to `%s'\n", OutputFilename);
+
+ /* Close the file, check for errors */
+ CloseOutputFile ();
+
+ /* Create dependencies if requested */
+ if (CreateDep) {
+ DoCreateDep (OutputFilename);
+ Print (stdout, 1, "Creating dependeny file\n");
+ }
+
+ }
+
+ /* Return an apropriate exit code */
+ return (ErrorCount > 0)? EXIT_FAILURE : EXIT_SUCCESS;
+ }
+
+
+
diff -Ncr cc65-2.13.2/src/common/target.c cc65-2.13.2-apple1/src/common/target.c
*** cc65-2.13.2/src/common/target.c Sun Sep 13 05:46:04 2009
--- cc65-2.13.2-apple1/src/common/target.c Tue Sep 13 18:42:27 2011
***************
*** 64,69 ****
--- 64,71 ----
"cbm610",
"pet",
"bbc",
+ "apple1",
+ "replica1",
"apple2",
"apple2enh",
"geos",
***************
*** 90,95 ****
--- 92,99 ----
CPU_6502, /* cbm610 */
CPU_6502, /* pet */
CPU_6502, /* bbc */
+ CPU_6502, /* apple1 */
+ CPU_6502, /* replica1 */
CPU_6502, /* apple2 */
CPU_65C02, /* apple2enh */
CPU_6502, /* geos */
diff -Ncr cc65-2.13.2/src/common/target.c.orig cc65-2.13.2-apple1/src/common/target.c.orig
*** cc65-2.13.2/src/common/target.c.orig Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/common/target.c.orig Sun Sep 13 05:46:04 2009
***************
*** 0 ****
--- 1,141 ----
+ /*****************************************************************************/
+ /* */
+ /* target.c */
+ /* */
+ /* Target specification */
+ /* */
+ /* */
+ /* */
+ /* (C) 2000-2009, Ullrich von Bassewitz */
+ /* Roemerstrasse 52 */
+ /* D-70794 Filderstadt */
+ /* EMail: uz@cc65.org */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ #include <stdlib.h>
+ #include <string.h>
+
+ #include "chartype.h"
+ #include "target.h"
+
+
+
+ /*****************************************************************************/
+ /* Data */
+ /*****************************************************************************/
+
+
+
+ /* Target system */
+ target_t Target = TGT_NONE;
+
+ /* Table with target names */
+ const char* TargetNames [TGT_COUNT] = {
+ "none",
+ "module",
+ "atari",
+ "vic20",
+ "c16",
+ "c64",
+ "c128",
+ "plus4",
+ "cbm510",
+ "cbm610",
+ "pet",
+ "bbc",
+ "apple2",
+ "apple2enh",
+ "geos",
+ "lunix",
+ "atmos",
+ "nes",
+ "supervision",
+ "lynx"
+ };
+
+
+
+ /* Table with default CPUs per target */
+ const cpu_t DefaultCPU[TGT_COUNT] = {
+ CPU_6502, /* none */
+ CPU_6502, /* module */
+ CPU_6502, /* atari */
+ CPU_6502, /* vic20 */
+ CPU_6502, /* c16 */
+ CPU_6502, /* c64 */
+ CPU_6502, /* c128 */
+ CPU_6502, /* plus4 */
+ CPU_6502, /* cbm510 */
+ CPU_6502, /* cbm610 */
+ CPU_6502, /* pet */
+ CPU_6502, /* bbc */
+ CPU_6502, /* apple2 */
+ CPU_65C02, /* apple2enh */
+ CPU_6502, /* geos */
+ CPU_6502, /* lunix */
+ CPU_6502, /* atmos */
+ CPU_6502, /* nes */
+ CPU_65SC02, /* supervision */
+ CPU_65C02, /* lynx */
+ };
+
+
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+
+ target_t FindTarget (const char* Name)
+ /* Find a target by name and return the target id. TGT_UNKNOWN is returned if
+ * the given name is no valid target.
+ */
+ {
+ unsigned I;
+
+ /* Check for a numeric target */
+ if (IsDigit (*Name)) {
+ int Target = atoi (Name);
+ if (Target >= 0 && Target < TGT_COUNT) {
+ return (target_t)Target;
+ }
+ }
+
+ /* Check for a target string */
+ for (I = 0; I < TGT_COUNT; ++I) {
+ if (strcmp (TargetNames [I], Name) == 0) {
+ return (target_t)I;
+ }
+ }
+
+ /* Not found */
+ return TGT_UNKNOWN;
+ }
+
+
+
+
+
+
diff -Ncr cc65-2.13.2/src/common/target.h cc65-2.13.2-apple1/src/common/target.h
*** cc65-2.13.2/src/common/target.h Sun Sep 13 05:46:04 2009
--- cc65-2.13.2-apple1/src/common/target.h Tue Sep 13 18:42:27 2011
***************
*** 64,69 ****
--- 64,71 ----
TGT_CBM610,
TGT_PET,
TGT_BBC,
+ TGT_APPLE1,
+ TGT_REPLICA1,
TGT_APPLE2,
TGT_APPLE2ENH,
TGT_GEOS,
diff -Ncr cc65-2.13.2/src/common/target.h.orig cc65-2.13.2-apple1/src/common/target.h.orig
*** cc65-2.13.2/src/common/target.h.orig Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/common/target.h.orig Sun Sep 13 05:46:04 2009
***************
*** 0 ****
--- 1,108 ----
+ /*****************************************************************************/
+ /* */
+ /* target.h */
+ /* */
+ /* Target specification */
+ /* */
+ /* */
+ /* */
+ /* (C) 2000-2009, Ullrich von Bassewitz */
+ /* Roemerstrasse 52 */
+ /* D-70794 Filderstadt */
+ /* EMail: uz@cc65.org */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ #ifndef TARGET_H
+ #define TARGET_H
+
+
+
+ /* common */
+ #include "cpu.h"
+
+
+
+ /*****************************************************************************/
+ /* Data */
+ /*****************************************************************************/
+
+
+
+ /* Supported target systems */
+ typedef enum {
+ TGT_UNKNOWN = -1, /* Not specified or invalid target */
+ TGT_NONE,
+ TGT_MODULE,
+ TGT_ATARI,
+ TGT_VIC20,
+ TGT_C16,
+ TGT_C64,
+ TGT_C128,
+ TGT_PLUS4,
+ TGT_CBM510,
+ TGT_CBM610,
+ TGT_PET,
+ TGT_BBC,
+ TGT_APPLE2,
+ TGT_APPLE2ENH,
+ TGT_GEOS,
+ TGT_LUNIX,
+ TGT_ATMOS,
+ TGT_NES,
+ TGT_SUPERVISION,
+ TGT_LYNX,
+ TGT_COUNT /* Number of target systems */
+ } target_t;
+
+ /* Target system */
+ extern target_t Target;
+
+ /* Table with target names */
+ extern const char* TargetNames[TGT_COUNT];
+
+ /* Table with default CPUs per target */
+ extern const cpu_t DefaultCPU[TGT_COUNT];
+
+
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+
+ target_t FindTarget (const char* Name);
+ /* Find a target by name and return the target id. TGT_UNKNOWN is returned if
+ * the given name is no valid target.
+ */
+
+
+
+ /* End of target.h */
+
+ #endif
+
+
+
+
diff -Ncr cc65-2.13.2/src/common/tgttrans.c cc65-2.13.2-apple1/src/common/tgttrans.c
*** cc65-2.13.2/src/common/tgttrans.c Sun Sep 13 05:46:04 2009
--- cc65-2.13.2-apple1/src/common/tgttrans.c Tue Sep 13 18:42:27 2011
***************
*** 153,158 ****
--- 153,160 ----
case TGT_CBM610: memcpy (Tab, CTPET, sizeof (Tab)); break;
case TGT_PET: memcpy (Tab, CTPET, sizeof (Tab)); break;
case TGT_BBC: memcpy (Tab, CTNone, sizeof (Tab)); break;
+ case TGT_APPLE1: memcpy (Tab, CTNone, sizeof (Tab)); break;
+ case TGT_REPLICA1: memcpy (Tab, CTNone, sizeof (Tab)); break;
case TGT_APPLE2: memcpy (Tab, CTNone, sizeof (Tab)); break;
case TGT_APPLE2ENH: memcpy (Tab, CTNone, sizeof (Tab)); break;
case TGT_GEOS: memcpy (Tab, CTNone, sizeof (Tab)); break;
diff -Ncr cc65-2.13.2/src/ld65/apple1.inc cc65-2.13.2-apple1/src/ld65/apple1.inc
*** cc65-2.13.2/src/ld65/apple1.inc Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/ld65/apple1.inc Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,39 ----
+ static const char CfgApple1 [] =
+ "MEMORY {\n"
+ "ZP: start = $0020, size = $00C0, define = yes;\n"
+ "HEADER: start = $0000, size = $0004, file = %O;\n"
+ "RAM1: start = $0280, size = $0B80, file = %O;\n"
+ "RAM2: start = $E000, size = $1000, file = %O;\n"
+ "}\n"
+ "SEGMENTS {\n"
+ "EXEHDR: load = HEADER, type = ro;\n"
+ "STARTUP: load = RAM1, type = ro, define = yes;\n"
+ "LOWCODE: load = RAM1, type = ro, optional = yes;\n"
+ "INIT: load = RAM1, type = ro, define = yes, optional = yes;\n"
+ "CODE: load = RAM1, type = ro;\n"
+ "RODATA: load = RAM1, type = ro;\n"
+ "DATA: load = RAM1, type = rw;\n"
+ "BSS: load = RAM2, type = bss, define = yes;\n"
+ "HEAP: load = RAM2, type = bss, optional = yes;\n" /* must sit just below stack */
+ "ZEROPAGE: load = ZP, type = zp;\n"
+ "}\n"
+ "FEATURES {\n"
+ "CONDES: segment = INIT,\n"
+ "type = constructor,\n"
+ "label = __CONSTRUCTOR_TABLE__,\n"
+ "count = __CONSTRUCTOR_COUNT__;\n"
+ "CONDES: segment = RODATA,\n"
+ "type = destructor,\n"
+ "label = __DESTRUCTOR_TABLE__,\n"
+ "count = __DESTRUCTOR_COUNT__;\n"
+ "CONDES: type = interruptor,\n"
+ "segment = RODATA,\n"
+ "label = __INTERRUPTOR_TABLE__,\n"
+ "count = __INTERRUPTOR_COUNT__;\n"
+ "}\n"
+ "SYMBOLS {\n"
+ "__STACKSIZE__ = $800;\n" /* 2K stack */
+ "}\n"
+ "\n"
+ "\n"
+ ;
diff -Ncr cc65-2.13.2/src/ld65/replica1.inc cc65-2.13.2-apple1/src/ld65/replica1.inc
*** cc65-2.13.2/src/ld65/replica1.inc Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/ld65/replica1.inc Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,38 ----
+ static const char CfgReplica1 [] =
+ "MEMORY {\n"
+ "ZP: start = $0020, size = $00C0, define = yes;\n"
+ "HEADER: start = $0000, size = $0004, file = %O;\n"
+ "RAM: start = $0280, size = $7D80, file = %O;\n"
+ "}\n"
+ "SEGMENTS {\n"
+ "EXEHDR: load = HEADER, type = ro;\n"
+ "STARTUP: load = RAM, type = ro, define = yes;\n"
+ "LOWCODE: load = RAM, type = ro, optional = yes;\n"
+ "INIT: load = RAM, type = ro, define = yes, optional = yes;\n"
+ "CODE: load = RAM, type = ro;\n"
+ "RODATA: load = RAM, type = ro;\n"
+ "DATA: load = RAM, type = rw;\n"
+ "BSS: load = RAM, type = bss, define = yes;\n"
+ "HEAP: load = RAM, type = bss, optional = yes;\n" /* must sit just below stack */
+ "ZEROPAGE: load = ZP, type = zp;\n"
+ "}\n"
+ "FEATURES {\n"
+ "CONDES: segment = INIT,\n"
+ "type = constructor,\n"
+ "label = __CONSTRUCTOR_TABLE__,\n"
+ "count = __CONSTRUCTOR_COUNT__;\n"
+ "CONDES: segment = RODATA,\n"
+ "type = destructor,\n"
+ "label = __DESTRUCTOR_TABLE__,\n"
+ "count = __DESTRUCTOR_COUNT__;\n"
+ "CONDES: type = interruptor,\n"
+ "segment = RODATA,\n"
+ "label = __INTERRUPTOR_TABLE__,\n"
+ "count = __INTERRUPTOR_COUNT__;\n"
+ "}\n"
+ "SYMBOLS {\n"
+ "__STACKSIZE__ = $800;\n" /* 2K stack */
+ "}\n"
+ "\n"
+ "\n"
+ ;
diff -Ncr cc65-2.13.2/src/ld65/tgtcfg.c cc65-2.13.2-apple1/src/ld65/tgtcfg.c
*** cc65-2.13.2/src/ld65/tgtcfg.c Fri Sep 18 13:13:59 2009
--- cc65-2.13.2-apple1/src/ld65/tgtcfg.c Tue Sep 13 18:42:27 2011
***************
*** 49,54 ****
--- 49,56 ----
/* Actual target configurations, converted into C strings by a perl script */
+ #include "apple1.inc"
+ #include "replica1.inc"
#include "apple2.inc"
#include "apple2enh.inc"
#include "atari.inc"
***************
*** 92,97 ****
--- 94,101 ----
{ BINFMT_BINARY, CfgCBM610 },
{ BINFMT_BINARY, CfgPET },
{ BINFMT_BINARY, CfgBBC },
+ { BINFMT_BINARY, CfgApple1 },
+ { BINFMT_BINARY, CfgReplica1 },
{ BINFMT_BINARY, CfgApple2 },
{ BINFMT_BINARY, CfgApple2Enh },
{ BINFMT_BINARY, CfgGeos },
diff -Ncr cc65-2.13.2/src/ld65/tgtcfg.c.orig cc65-2.13.2-apple1/src/ld65/tgtcfg.c.orig
*** cc65-2.13.2/src/ld65/tgtcfg.c.orig Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/src/ld65/tgtcfg.c.orig Fri Sep 18 13:13:59 2009
***************
*** 0 ****
--- 1,125 ----
+ /*****************************************************************************/
+ /* */
+ /* tgtcfg.c */
+ /* */
+ /* Target machine configurations the ld65 linker */
+ /* */
+ /* */
+ /* */
+ /* (C) 1998-2009, Ullrich von Bassewitz */
+ /* Roemerstrasse 52 */
+ /* D-70794 Filderstadt */
+ /* EMail: uz@cc65.org */
+ /* */
+ /* */
+ /* This software is provided 'as-is', without any expressed or implied */
+ /* warranty. In no event will the authors be held liable for any damages */
+ /* arising from the use of this software. */
+ /* */
+ /* Permission is granted to anyone to use this software for any purpose, */
+ /* including commercial applications, and to alter it and redistribute it */
+ /* freely, subject to the following restrictions: */
+ /* */
+ /* 1. The origin of this software must not be misrepresented; you must not */
+ /* claim that you wrote the original software. If you use this software */
+ /* in a product, an acknowledgment in the product documentation would be */
+ /* appreciated but is not required. */
+ /* 2. Altered source versions must be plainly marked as such, and must not */
+ /* be misrepresented as being the original software. */
+ /* 3. This notice may not be removed or altered from any source */
+ /* distribution. */
+ /* */
+ /*****************************************************************************/
+
+
+
+ /* common */
+ #include "check.h"
+
+ /* ld65 */
+ #include "binfmt.h"
+ #include "tgtcfg.h"
+
+
+
+ /*****************************************************************************/
+ /* Target configurations */
+ /*****************************************************************************/
+
+
+
+ /* Actual target configurations, converted into C strings by a perl script */
+ #include "apple2.inc"
+ #include "apple2enh.inc"
+ #include "atari.inc"
+ #include "atmos.inc"
+ #include "bbc.inc"
+ #include "c128.inc"
+ #include "c16.inc"
+ #include "c64.inc"
+ #include "cbm510.inc"
+ #include "cbm610.inc"
+ #include "geos.inc"
+ #include "lunix.inc"
+ #include "lynx.inc"
+ #include "module.inc"
+ #include "nes.inc"
+ #include "none.inc"
+ #include "pet.inc"
+ #include "plus4.inc"
+ #include "supervision.inc"
+ #include "vic20.inc"
+
+
+
+ /*****************************************************************************/
+ /* Data */
+ /*****************************************************************************/
+
+
+
+ /* Target configurations for all systems */
+ const TargetDesc Targets[TGT_COUNT] = {
+ { BINFMT_BINARY, CfgNone },
+ { BINFMT_O65, CfgModule },
+ { BINFMT_BINARY, CfgAtari },
+ { BINFMT_BINARY, CfgVic20 },
+ { BINFMT_BINARY, CfgC16 },
+ { BINFMT_BINARY, CfgC64 },
+ { BINFMT_BINARY, CfgC128 },
+ { BINFMT_BINARY, CfgPlus4 },
+ { BINFMT_BINARY, CfgCBM510 },
+ { BINFMT_BINARY, CfgCBM610 },
+ { BINFMT_BINARY, CfgPET },
+ { BINFMT_BINARY, CfgBBC },
+ { BINFMT_BINARY, CfgApple2 },
+ { BINFMT_BINARY, CfgApple2Enh },
+ { BINFMT_BINARY, CfgGeos },
+ { BINFMT_O65, CfgLunix },
+ { BINFMT_BINARY, CfgAtmos },
+ { BINFMT_BINARY, CfgNES },
+ { BINFMT_BINARY, CfgSupervision },
+ { BINFMT_BINARY, CfgLynx },
+ };
+
+
+
+ /*****************************************************************************/
+ /* Code */
+ /*****************************************************************************/
+
+
+
+ void DumpBuiltinConfig (FILE* F, target_t T)
+ /* Dump a builtin linker configuration */
+ {
+ /* Check the given parameter */
+ PRECONDITION (T > TGT_UNKNOWN && T < TGT_COUNT);
+
+ /* Dump the config */
+ fprintf (F, "%s\n", Targets[T].Cfg);
+ }
+
+
+
+
diff -Ncr cc65-2.13.2/util/apple1/bintomon.c cc65-2.13.2-apple1/util/apple1/bintomon.c
*** cc65-2.13.2/util/apple1/bintomon.c Wed Dec 31 17:00:00 1969
--- cc65-2.13.2-apple1/util/apple1/bintomon.c Tue Sep 13 18:42:27 2011
***************
*** 0 ****
--- 1,34 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int main(int argc, char **argv)
+ {
+ FILE *obj;
+ int start_addr, length;
+ unsigned char b;
+
+ if (argc < 2)
+ {
+ fprintf(stderr, "Include file to convert on command line.\n");
+ exit(1);
+ }
+ if (obj = fopen(argv[1], "rb"))
+ {
+ start_addr = length = 0;
+ fread(&b, 1, 1, obj);
+ start_addr = b;
+ fread(&b, 1, 1, obj);
+ start_addr |= b << 8;
+ fread(&length, 1, 2, obj);
+ printf("%04X:", start_addr);
+ while (fread(&b, 1, 1, obj) == 1)
+ {
+ printf(" %02X", b);
+ if (!(++start_addr & 0x07))
+ printf("\r\n:");
+ }
+ printf("\r\n");
+ fclose(obj);
+ }
+ return (0);
+ }