- Put a BASIC-language stub at the beginning.
- Removed the Autostart flag.
Those changes make it easy to give command-line arguments to a program.
* Made the Atmos configure file accept a special symbol definition on ld65's command line. We can use "__RAMEND__" to increase the amount of RAM that's available to programs.
SYMBOLS {
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
+ __TAPEHDR__: type = import;
+ __BASHDR__: type = import;
+ __PROGFLAG__: type = weak, value = $00; # $00=BASIC, $80=machine code
+ __AUTORUN__: type = weak, value = $00; # $C7=run, $00=only load
+ __STACKSIZE__: type = weak, value = $0800; # 2K stack
+ __RAMEND__: type = weak, value = $9800; # graphics RAM not grabbed
+# __RAMEND__: type = weak, value = $B400; # graphics RAM grabbed
}
MEMORY {
ZP: file = "", define = yes, start = $00E2, size = $001A;
- TAPEHDR: file = %O, type = ro, start = $0000, size = $0011;
- RAM: file = %O, define = yes, start = $0500, size = $9300 - __STACKSIZE__;
+ TAPEHDR: file = %O, type = ro, start = $0000, size = $001F;
+ BASHEAD: file = %O, define = yes, start = $0501, size = $000D;
+ RAM: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __RAM_START__ - __STACKSIZE__;
}
SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
TAPEHDR: load = TAPEHDR, type = ro;
+ BASHDR: load = BASHEAD, type = ro, define = yes, optional = yes;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
- INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
+ INIT: load = RAM, type = ro, define = yes, optional = yes;
DATA: load = RAM, type = rw;
- ZPSAVE: load = RAM, type = bss, define = yes;
+ ZPSAVE: load = RAM, type = rw, define = yes;
BSS: load = RAM, type = bss, define = yes;
- ZEROPAGE: load = ZP, type = zp;
}
FEATURES {
CONDES: type = constructor,
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
-<date>2014-03-27
+<date>2014-09-23
<abstract>
An overview over the Atmos runtime system as it is implemented for the cc65 C
information.
+
<sect>Binary format<p>
The standard binary output format generated by the linker for the Atmos target
-is a machine language program with a 17 byte tape header including a cc65 tag.
-The standard load and autostart address is $500.
+is a machine language program with a one-line BASIC stub that jumps to the
+machine-language part through <tt/CALL/. It has a 24-byte tape header.
+It means that a file can be loaded as a BASIC program, and started with RUN.
+The standard load address is $501.
+
<sect>Memory layout<p>
-In the standard setup, cc65 generated programs use the memory from
-$500 to $9800, so nearly 37K of memory (including the stack) is
+In the standard setup, cc65-generated programs use the memory from
+$0501 to $9800; so, nearly 37K of memory (including the stack) is
available. ROM calls are possible without further precautions.
+If your program needs more memory, and it won't use TGI graphics, then you can
+use the ld65 command-line option, <tt/-D __RAMEND__=$B400/, when building the
+program, to "grab" the graphics screen RAM. Then, nearly 44K of memory is
+available.
+
Special locations:
<descrip>
<tag/Stack/
- The C runtime stack is located at $97FF and growing downwards.
+ The C runtime stack is located at $97FF (or $B3FF), and grows
+ downwards.
<tag/Heap/
- The C heap is located at the end of the program and grows towards the C
+ The C heap is located at the end of the program, and grows towards the C
runtime stack.
</descrip><p>
<sect1>Graphics drivers<p>
-The default drivers, <tt/tgi_stddrv (tgi_static_stddrv)/, point to <tt/atmos-240-200-2.tgi (atmos_240_200_2_tgi)/.
+The default drivers, <tt/tgi_stddrv (tgi_static_stddrv)/,
+point to <tt/atmos-240-200-2.tgi (atmos_240_200_2_tgi)/.
<descrip>
<sect1>Disk I/O<p>
-The existing library for the Atmos doesn't implement C file
-I/O. There are hacks for the <tt/read()/ and <tt/write()/ routines in
-place, which will make functions work that read from and write to <tt/stdout/
-(like <tt/printf()/). However, those functions have some shortcomings which
-won't be fixed, because they're going to be replaced anyway.
+The existing library for the Atmos doesn't implement C file I/O. There are
+hacks for the <tt/read()/ and <tt/write()/ routines in place, which will make
+functions work that read from <tt/stdin/ and write to <tt/stdout/ and
+<tt/stderr/ (such as <tt/printf()/). However, those functions have some
+shortcomings which won't be fixed, because they're going to be replaced
+anyway.
-To be more concrete, the limitation means that you cannot use any of the
+To be more concrete, that limitation means that you cannot use any of the
following functions (and a few others):
<itemize>
<sect1>Function keys<p>
-These are defined to be FUNCT + number key.
+They are defined to be FUNCT + a number key.
+
+
+<sect1>Capitals Lock<p>
+
+The "CAPS Lock" mode is turned off while the program is running. The previous
+mode (usually turned on) is restored when the program stops.
<sect1>Passing arguments to the program<p>
supported directly by BASIC, the following syntax was chosen:
<tscreen><verb>
- CALL#500:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+ RUN:REM arg1 " ARG2 IS QUOTED" ARG3 "" ARG5
</verb></tscreen>
<enum>
+<item>You must turn <tt/CAPS/ lock off (tap CTRL-T) when you want to type
+ lower-case arguments.
<item>Arguments are separated by spaces.
<item>Arguments may be quoted.
<item>Leading and trailing spaces around an argument are ignored. Spaces within
--- /dev/null
+;
+; 2010-11-14, Ullrich von Bassewitz
+; 2014-09-06, Greg King
+;
+; This module supplies a small BASIC stub program that uses CALL
+; to jump to the machine-language code that follows it.
+;
+
+ ; The following symbol is used by the linker config. file
+ ; to force this module to be included into the output file.
+ .export __BASHDR__:abs = 1
+
+
+.segment "BASHDR"
+
+ .addr Next
+ .word .version ; Line number
+ .byte $BF,'#' ; CALL token, mark number as hexadecimal
+ .byte <(Start >> 8 ) + '0' + (Start >> 8 > $09) * $07
+ .byte <(Start >> 4 & $0F) + '0' + (Start >> 4 & $0F > $09) * $07
+ .byte <(Start & $0F) + '0' + (Start & $0F > $09) * $07
+ .byte $00 ; End of BASIC line
+Next: .addr $0000 ; BASIC program end marker
+Start:
; Startup code for cc65 (Oric version)
;
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
-; 2014-08-22, Greg King
+; 2014-11-09, Greg King
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import callmain, zerobss
- .import __RAM_START__, __RAM_SIZE__
- .import __ZPSAVE_LOAD__, __STACKSIZE__
+ .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.include "zeropage.inc"
.include "atmos.inc"
-; ------------------------------------------------------------------------
-; Oric tape header
-
-.segment "TAPEHDR"
-
- .byte $16, $16, $16 ; Sync bytes
- .byte $24 ; End of header marker
-
- .byte $00 ; $2B0
- .byte $00 ; $2AF
- .byte $80 ; $2AE Machine code flag
- .byte $C7 ; $2AD Autoload flag
- .dbyt __ZPSAVE_LOAD__ - 1 ; $2AB
- .dbyt __RAM_START__ ; $2A9
- .byte $00 ; $2A8
- .byte ((.VERSION >> 8) & $0F) + '0'
- .byte ((.VERSION >> 4) & $0F) + '0'
- .byte (.VERSION & $0F) + '0'
- .byte $00 ; Zero terminated compiler version
-
; ------------------------------------------------------------------------
; Place the startup code in a special segment.
; Call the module destructors. This is also the exit() entry.
-_exit: jsr donelib ; Run module destructors
+_exit: jsr donelib
; Restore the system stuff.
.segment "ZPSAVE"
-zpsave: .res zpspace
+zpsave:
+
+; This padding is needed by a bug in the ROM.
+; (The CLOAD command starts BASIC's variables table on top of the last byte
+; that was loaded [instead of at the next address].)
+
+ .byte 0
+
+ .res zpspace - 1
; ------------------------------------------------------------------------
--- /dev/null
+;
+; Based on code by Debrune Jérôme <jede@oric.org>
+; 2013-08-15, Greg King
+;
+
+ ; The following symbol is used by the linker config. file
+ ; to force this module to be included into the output file.
+ .export __TAPEHDR__:abs = 1
+
+ .import __BASHDR_LOAD__, __ZPSAVE_LOAD__, __AUTORUN__, __PROGFLAG__
+
+
+; ------------------------------------------------------------------------
+; Oric cassette-tape header
+
+.segment "TAPEHDR"
+
+ .byte $16, $16, $16 ; Sync bytes
+ .byte $24 ; Beginning-of-header marker
+
+ .byte $00 ; $2B0
+ .byte $00 ; $2AF
+ .byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
+ .byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
+ .dbyt __ZPSAVE_LOAD__ ; $2AB Address of end of file
+ .dbyt __BASHDR_LOAD__ ; $2A9 Address of start of file
+ .byte $00 ; $2A8
+
+ ; File name (a maximum of 17 characters), zero-terminated
+ .asciiz .sprintf("%u", .time)