1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 19:29:53 +00:00

Merge branch 'master' into fptest

This commit is contained in:
mrdudz 2023-03-04 13:48:31 +01:00
commit c92a8f863a
127 changed files with 1302 additions and 507 deletions

View File

@ -134,7 +134,22 @@ You can refer to Annex B of the ISO C99 standard ([here](https://www.open-std.or
* Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context. * Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context.
* Hexadecimal letters should be upper-case. * Hexadecimal letters should be upper-case.
* When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes). * When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes).
* If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) * If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) This must be done in one of the following ways:
<pre>
lda #RETURN_VALUE
ldx #0 ; return value is char
</pre>
or, if the value is 0, you can use:
<pre>
lda #RETURN_VALUE
.assert RETURN_VALUE = 0
tax
</pre>
sometimes jumping to return0 could save a byte:
<pre>
.assert RETURN_VALUE = 0
jmp return 0
</pre>
* Functions, that are intended for a platform's system library, should be optimized as much as possible. * Functions, that are intended for a platform's system library, should be optimized as much as possible.
* Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast. * Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast.
* Comments that are put on the right side of instructions must be aligned (start in the same character columns). * Comments that are put on the right side of instructions must be aligned (start in the same character columns).

View File

@ -125,6 +125,7 @@ Long options:
--target sys Set the target system --target sys Set the target system
--verbose Increase verbosity --verbose Increase verbosity
--version Print the assembler version --version Print the assembler version
--warnings-as-errors Treat warnings as errors
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
</verb></tscreen> </verb></tscreen>
@ -183,7 +184,7 @@ Here is a description of all the command line options:
Enable an emulation feature. This is identical as using <tt/.FEATURE/ Enable an emulation feature. This is identical as using <tt/.FEATURE/
in the source with two exceptions: Feature names must be lower case, and in the source with two exceptions: Feature names must be lower case, and
each feature must be specified by using an extra <tt/--feature/ option, each feature must be specified by using a separate <tt/--feature/ option,
comma separated lists are not allowed. comma separated lists are not allowed.
See the discussion of the <tt><ref id=".FEATURE" name=".FEATURE"></tt> See the discussion of the <tt><ref id=".FEATURE" name=".FEATURE"></tt>
@ -359,6 +360,13 @@ Here is a description of all the command line options:
warning level is 1, and it would probably be silly to set it to warning level is 1, and it would probably be silly to set it to
something lower. something lower.
<label id="option--warnings-as-errors">
<tag><tt>--warnings-as-errors</tt></tag>
An error will be generated if any warnings were produced.
</descrip> </descrip>
<p> <p>
@ -431,6 +439,15 @@ The assembler accepts
<tt><ref id=".P4510" name=".P4510"></tt> command was given). <tt><ref id=".P4510" name=".P4510"></tt> command was given).
</itemize> </itemize>
On 6502-derived platforms the <tt/BRK/ instruction has an optional signature
byte. If omitted, the assembler will only produce only 1 byte.
<tscreen><verb>
brk ; 1-byte: $00
brk $34 ; 2-bytes: $00 $34
brk #$34 ; 2-bytes: $00 $34
</verb></tscreen>
<sect1>65816 mode<p> <sect1>65816 mode<p>
@ -448,6 +465,17 @@ mnemonics:
<item><tt>TSA</tt> is an alias for <tt>TSC</tt> <item><tt>TSA</tt> is an alias for <tt>TSC</tt>
</itemize> </itemize>
The <tt/MVN/ and <tt/MVP/ instructions accept two different argument forms.
Either two bank bytes may be given with a <tt/#/ prefix,
or two far addresses whose high byte will be used.
<tscreen><verb>
mvn #^src, #^dst ; bank of src to bank of dst
mvn src, dst ; bank of src to bank of dst
mvp #$12, #$78 ; bank $12 to $78
mvp $123456, $789ABC ; bank $12 to $78
</verb></tscreen>
<sect1>6502X mode<label id="6502X-mode"><p> <sect1>6502X mode<label id="6502X-mode"><p>
@ -2019,7 +2047,7 @@ Here's a list of all control commands and a description, what they do:
<sect1><tt>.A16</tt><label id=".A16"><p> <sect1><tt>.A16</tt><label id=".A16"><p>
Valid only in 65816 mode. Switch the accumulator to 16 bit. Valid only in 65816 mode. Assume the accumulator is 16 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 16 bit operands for immediate accumulator addressing mode. create 16 bit operands for immediate accumulator addressing mode.
@ -2029,7 +2057,7 @@ Here's a list of all control commands and a description, what they do:
<sect1><tt>.A8</tt><label id=".A8"><p> <sect1><tt>.A8</tt><label id=".A8"><p>
Valid only in 65816 mode. Switch the accumulator to 8 bit. Valid only in 65816 mode. Assume the accumulator is 8 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 8 bit operands for immediate accu addressing mode. create 8 bit operands for immediate accu addressing mode.
@ -2112,15 +2140,15 @@ Here's a list of all control commands and a description, what they do:
</verb></tscreen> </verb></tscreen>
the assembler will force a segment alignment to the least common multiple of the assembler will force a segment alignment to the least common multiple of
15, 18 and 251 - which is 22590. To protect the user against errors, the 15, 18 and 251 - which is 22590. To protect the user against errors, when the
assembler will issue a warning when the combined alignment exceeds 256. The combined alignment is larger than the explicitly requested alignments,
command line option <tt><ref id="option--large-alignment" the assembler will issue a warning if it also exceeds 256. The command line
name="--large-alignment"></tt> will disable this warning. option <tt><ref id="option--large-alignment" name="--large-alignment"></tt>
will disable this warning.
Please note that with alignments that are a power of two (which were the Please note that with only alignments that are a power of two, a warning will
only alignments possible in older versions of the assembler), the problem is never occur, because the least common multiple of powers to the same base is
less severe, because the least common multiple of powers to the same base is always simply the larger one.
always the larger one.
@ -2514,7 +2542,19 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.ENDMAC, .ENDMACRO</tt><label id=".ENDMACRO"><p> <sect1><tt>.ENDMAC, .ENDMACRO</tt><label id=".ENDMACRO"><p>
Marks the end of a macro definition. Marks the end of a macro definition. Note, <tt>.ENDMACRO</tt> should be on
its own line to successfully end the macro definition. It is possible to use
<tt><ref id=".DEFINE" name=".DEFINE"></tt> to create a symbol that references
<tt>.ENDMACRO</tt> without ending the macro definition.
Example:
<tscreen><verb>
.macro new_mac
.define startmac .macro
.define endmac .endmacro
.endmacro
</verb></tscreen>
See: <tt><ref id=".DELMACRO" name=".DELMACRO"></tt>, See: <tt><ref id=".DELMACRO" name=".DELMACRO"></tt>,
<tt><ref id=".EXITMACRO" name=".EXITMACRO"></tt>, <tt><ref id=".EXITMACRO" name=".EXITMACRO"></tt>,
@ -2738,15 +2778,19 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
This directive may be used to enable one or more compatibility features This directive may be used to enable one or more compatibility features
of the assembler. While the use of <tt/.FEATURE/ should be avoided when of the assembler. While the use of <tt/.FEATURE/ should be avoided when
possible, it may be useful when porting sources written for other possible, it may be useful when porting sources written for other
assemblers. There is no way to switch a feature off, once you have assemblers. After the feature name an optional '+' or '-' may specify whether
enabled it, so using to enable or disable the feature (enable if omitted). Multiple features may be
enabled, separated by commas. Examples:
<tscreen><verb> <tscreen><verb>
.FEATURE xxx ; enable c_comments
.feature c_comments
.feature c_comments +
; enable force_range, disable underline_in_numbers, enable labels_without_colons
.feature force_range, underline_in_numbers -, labels_without_colons +
.feature force_range +, underline_in_numbers off, labels_without_colons on
</verb></tscreen> </verb></tscreen>
will enable the feature until end of assembly is reached.
The following features are available: The following features are available:
<descrip> <descrip>
@ -2825,6 +2869,23 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
overridden. When using this feature, you may also get into trouble if overridden. When using this feature, you may also get into trouble if
later versions of the assembler define new keywords starting with a dot. later versions of the assembler define new keywords starting with a dot.
<tag><tt>long_jsr_jmp_rts</tt><label id="long_jsr_jmp_rts"></tag>
Affects 65816 mode only.
Allows <tt>jsr</tt> and <tt>jmp</tt> to produce long jumps if the target
address has been previously declared in a <tt>far</tt> segment,
or imported as <tt>far</tt>.
Otherwise <tt>jsl</tt> and <tt>jml</tt> must be used instead.
Also allows <tt><ref id=".SMART" name=".SMART"></tt> to convert <tt>rts</tt>
to a long return <tt>rtl</tt> when the enclosing scope or memory model
indicates returning from a <tt>far</tt> procedure.
This permits compatibility with the old behavior of this assembler, or other
assemblers which similarly allowed <tt>jsr</tt> and <tt>jmp</tt> to be used
this way.
<tag><tt>loose_char_term</tt><label id="loose_char_term"></tag> <tag><tt>loose_char_term</tt><label id="loose_char_term"></tag>
Accept single quotes as well as double quotes as terminators for char Accept single quotes as well as double quotes as terminators for char
@ -3036,7 +3097,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.I16</tt><label id=".I16"><p> <sect1><tt>.I16</tt><label id=".I16"><p>
Valid only in 65816 mode. Switch the index registers to 16 bit. Valid only in 65816 mode. Assume the index registers are 16 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 16 bit operands for immediate operands. create 16 bit operands for immediate operands.
@ -3047,7 +3108,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.I8</tt><label id=".I8"><p> <sect1><tt>.I8</tt><label id=".I8"><p>
Valid only in 65816 mode. Switch the index registers to 8 bit. Valid only in 65816 mode. Assume the index registers are 8 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 8 bit operands for immediate operands. create 8 bit operands for immediate operands.
@ -3994,7 +4055,9 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
the assembler cannot trace the execution flow this may lead to false the assembler cannot trace the execution flow this may lead to false
results in some cases. If in doubt, use the <tt/.Inn/ and <tt/.Ann/ results in some cases. If in doubt, use the <tt/.Inn/ and <tt/.Ann/
instructions to tell the assembler about the current settings. instructions to tell the assembler about the current settings.
<item>In 65816 mode, replace a <tt/RTS/ instruction by <tt/RTL/ if it is <item>In 65816 mode, if the <tt><ref id="long_jsr_jmp_rts"
name="long_jsr_jmp_rts"></tt> feature is enabled,
smart mode will replace a <tt/RTS/ instruction by <tt/RTL/ if it is
used within a procedure declared as <tt/far/, or if the procedure has used within a procedure declared as <tt/far/, or if the procedure has
no explicit address specification, but it is <tt/far/ because of the no explicit address specification, but it is <tt/far/ because of the
memory model used. memory model used.

View File

@ -6,7 +6,8 @@
<abstract> <abstract>
Internal details of cc65 code generation, Internal details of cc65 code generation,
such as calling assembly functions from C. such as the expected linker configuration,
and calling assembly functions from C.
</abstract> </abstract>
<!-- Table of contents --> <!-- Table of contents -->
@ -16,6 +17,76 @@ such as calling assembly functions from C.
<sect>Linker configuration<p>
The C libraries and code generation depend directly on a suitable linker configuration.
There are premade configuration files in the <tt/cfg&sol;/ directory, normally chosen by the
linker's selected target. These can be used as a template for customization.
The C libraries depend on several special segments to be defined in your linker configuration.
Generated code will also use some of them by default.
Some platform libraries have additional special segments.
Memory areas are free to be defined in a way that is appropriate to each platform,
and the segments they contain are used as a layer of semantics and abstraction,
to allow much of the reorganization to be done with the linker config,
rather than requiring platform-specific code source changes.
<sect1><tt/ZEROPAGE/ segment<p>
Used by the C library and generated code for efficient internal and temporary state storage,
also called "pseudo-registers".
<sect1><tt/STARTUP/ segment<p>
Used by each platform instance of the C library in <tt/crt0.s/ to contain the entry point
of the program.
The startup module will export <tt/__STARTUP__ : absolute = 1/ to force the linker to
always include <tt/crt0.s/ from the library.
<sect1><tt/CODE/ segment<p>
The default segment for generated code, and most C library code will be located here.
Use <tt/#pragma code-name/ to redirect generated code to another segment.
<sect1><tt/BSS/ segment<p>
Used for uninitialized variables.
Originally an acronym for "Block Started by Symbol", but the meaning of this is now obscure.
Use <tt/#pragma bss-name/ to redirect uninitialized variables to another segment.
<sect1><tt/DATA/ segment<p>
Used for initialized variables.
On some platforms, this may be initialized as part of the program loading process,
but on others it may have a separate <tt/LOAD/ and <tt/RUN/ address,
allowing <tt/copydata/ to copy the initialization from the loaded location
into their run destination in RAM.
Use <tt/#pragma data-name/ to redirect initialized variables to another segment.
<sect1><tt/RODATA/ segment<p>
Used for read-only (constant) data.
Use <tt/#pragma rodata-name/ to redirect constant data to another segment.
<sect1><tt/FEATURES/ table<p>
This currently defines table locations for the <tt/CONDES/
constructor, destructor, and interruptor features.
Some platform libraries use these.
The constructors will be called with <tt/initlib/ at startup,
and the destructors with <tt/donelib/ at program exit.
Interruptors are called with <tt/callirq/.
<sect>Calling assembly functions from C<p> <sect>Calling assembly functions from C<p>
<sect1>Calling conventions<p> <sect1>Calling conventions<p>

View File

@ -59,7 +59,7 @@
Contains hints on creating the most effective code with cc65. Contains hints on creating the most effective code with cc65.
<tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag> <tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag>
Describes internal details of cc65, such as calling conventions. Describes internal details of cc65: linker configuration, calling conventions, etc.
<tag><htmlurl url="using-make.html" name="using-make.html"></tag> <tag><htmlurl url="using-make.html" name="using-make.html"></tag>
Build programs, using the GNU Make utility. Build programs, using the GNU Make utility.

View File

@ -90,6 +90,7 @@ Long options:
--start-group Start a library group --start-group Start a library group
--target sys Set the target system --target sys Set the target system
--version Print the linker version --version Print the linker version
--warnings-as-errors Treat warnings as errors
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
</verb></tscreen> </verb></tscreen>
@ -330,6 +331,13 @@ Here is a description of all of the command-line options:
directory, in the list of directories specified using <tt/--obj-path/, in directory, in the list of directories specified using <tt/--obj-path/, in
directories given by environment variables, and in a built-in default directory. directories given by environment variables, and in a built-in default directory.
<label id="option--warnings-as-errors">
<tag><tt>--warnings-as-errors</tt></tag>
An error will be generated if any warnings were produced.
</descrip> </descrip>

View File

@ -73,7 +73,8 @@ INSTALL:
and #$f0 and #$f0
cmp #$80 cmp #$80
bne @L1 bne @L1
lda #EM_ERR_OK .assert EM_ERR_OK = 0, error
txa
rts rts
@L1: lda #EM_ERR_NO_DEVICE @L1: lda #EM_ERR_NO_DEVICE
; rts ; rts

View File

@ -71,8 +71,9 @@ INSTALL:
stx gettype+2 stx gettype+2
gettype:jsr $0000 gettype:jsr $0000
sta ostype sta ostype
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; Fall through ; Fall through
; UNINSTALL routine. Is called before the driver is removed from memory. ; UNINSTALL routine. Is called before the driver is removed from memory.

View File

@ -133,8 +133,8 @@ next: inc ptr1+1
bcc :+ bcc :+
; Mouse firmware not found ; Mouse firmware not found
lda #<MOUSE_ERR_NO_DEVICE lda #MOUSE_ERR_NO_DEVICE
ldx #>MOUSE_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
; Check Pascal 1.1 Firmware Protocol ID bytes ; Check Pascal 1.1 Firmware Protocol ID bytes

View File

@ -168,8 +168,9 @@ SER_CLOSE:
sta ACIA_CMD,x sta ACIA_CMD,x
; Done, return an error code ; Done, return an error code
: lda #<SER_ERR_OK : lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
stx Index ; Mark port as closed stx Index ; Mark port as closed
rts rts
@ -256,23 +257,24 @@ SER_OPEN:
; Done ; Done
stx Index ; Mark port as open stx Index ; Mark port as open
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Device (hardware) not found ; Device (hardware) not found
NoDevice:lda #<SER_ERR_NO_DEVICE NoDevice:lda #SER_ERR_NO_DEVICE
ldx #>SER_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
; Invalid parameter ; Invalid parameter
InvParam:lda #<SER_ERR_INIT_FAILED InvParam:lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud:lda #<SER_ERR_BAUD_UNAVAIL InvBaud:lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -292,8 +294,8 @@ SER_GET:
: lda RecvFreeCnt ; (25) : lda RecvFreeCnt ; (25)
cmp #$FF cmp #$FF
bne :+ bne :+
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -336,8 +338,8 @@ SER_PUT:
; Put byte into send buffer & send ; Put byte into send buffer & send
: ldy SendFreeCnt : ldy SendFreeCnt
bne :+ bne :+
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
: ldy SendTail : ldy SendTail
@ -346,7 +348,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$FF ; TryHard = true lda #$FF ; TryHard = true
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -359,7 +362,8 @@ SER_STATUS:
lda ACIA_STATUS,x lda ACIA_STATUS,x
ldx #$00 ldx #$00
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -379,11 +383,12 @@ SER_IOCTL:
bcs :+ bcs :+
stx Slot stx Slot
tax ; SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
: lda #<SER_ERR_INV_IOCTL : lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -69,7 +69,8 @@ INSTALL:
lda #$34 lda #$34
sta PACTL sta PACTL
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -62,7 +62,8 @@ JOY_COUNT = 4 ; Number of joysticks we support
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -137,9 +137,10 @@ INSTALL:
ldx YPos+1 ldx YPos+1
jsr CMOVEY jsr CMOVEY
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -268,9 +268,10 @@ INSTALL:
and #$0f and #$0f
sta old_porta_vbi sta old_porta_vbi
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -132,9 +132,10 @@ INSTALL:
ldx YPos+1 ldx YPos+1
jsr CMOVEY jsr CMOVEY
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -135,8 +135,8 @@ my_CIOV:
.code .code
invbaud: invbaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
openerr: openerr:
rts rts
@ -229,8 +229,9 @@ SER_OPEN:
jsr my_CIOV jsr my_CIOV
bmi cioerr bmi cioerr
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
inverr: jmp my___inviocb inverr: jmp my___inviocb
@ -240,8 +241,8 @@ cioerr:
jsr my_fddecusage ; decrement usage counter of fd as open failed jsr my_fddecusage ; decrement usage counter of fd as open failed
init_err: init_err:
ldx #0
lda #SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #0 ; return value is char
rts rts
;---- open the device ;---- open the device
@ -313,8 +314,9 @@ SER_CLOSE:
stx rshand+1 stx rshand+1
inx inx
stx cm_run stx cm_run
@done: lda #<SER_ERR_OK @done: lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -365,16 +367,16 @@ SER_GET:
rts rts
@nix_da:lda #SER_ERR_NO_DATA @nix_da:lda #SER_ERR_NO_DATA
ldx #0 ldx #0 ; return value is char
rts rts
ser_error: ser_error:
lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/ lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/
ldx #0 ldx #0 ; return value is char
rts rts
ni_err: lda #SER_ERR_NOT_OPEN ni_err: lda #SER_ERR_NOT_OPEN
ldx #0 ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -427,8 +429,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -456,8 +458,8 @@ search: lda HATABS,y ; get device name
; R: device not found, return error ; R: device not found, return error
lda #<SER_ERR_NO_DEVICE lda #SER_ERR_NO_DEVICE
ldx #0 ldx #0 ; return value is char
rts rts
; R: device found, initialize jump table into main program ; R: device found, initialize jump table into main program
@ -554,8 +556,9 @@ found: lda ptr3
pla pla
sta ptr3 sta ptr3
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts

View File

@ -47,7 +47,8 @@ INSTALL:
lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in
sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -62,8 +62,9 @@ INSTALL:
sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high
reset: reset:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -55,11 +55,12 @@ INSTALL:
lda VIA::PRA lda VIA::PRA
and #%00100000 and #%00100000
bne ijkPresent bne ijkPresent
lda #<JOY_ERR_NO_DEVICE lda #JOY_ERR_NO_DEVICE
.byte $2C ; Skip next opcode .byte $2C ; Skip next opcode
ijkPresent: ijkPresent:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -58,7 +58,8 @@ temp2: .byte $00
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -141,8 +141,9 @@ SER_CLOSE:
sta ACIA::CMD,x sta ACIA::CMD,x
; Done, return an error code ; Done, return an error code
: lda #<SER_ERR_OK : lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
stx Index ; Mark port as closed stx Index ; Mark port as closed
rts rts
@ -205,8 +206,9 @@ SER_OPEN:
; Done ; Done
stx Index ; Mark port as open stx Index ; Mark port as open
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
@ -235,8 +237,8 @@ SER_GET:
: lda RecvFreeCnt ; (25) : lda RecvFreeCnt ; (25)
cmp #$FF cmp #$FF
bne :+ bne :+
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -277,8 +279,8 @@ SER_PUT:
; Put byte into send buffer & send ; Put byte into send buffer & send
: ldy SendFreeCnt : ldy SendFreeCnt
bne :+ bne :+
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
: ldy SendTail : ldy SendTail
@ -287,7 +289,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$FF ; TryHard = true lda #$FF ; TryHard = true
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -299,7 +302,8 @@ SER_STATUS:
lda ACIA::STATUS lda ACIA::STATUS
ldx #$00 ldx #$00
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -308,8 +312,8 @@ SER_STATUS:
; Must return an SER_ERR_xx code in a/x. ; Must return an SER_ERR_xx code in a/x.
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -215,7 +215,8 @@ SETPALETTE:
jsr PAPER jsr PAPER
ldy #1 ldy #1
jsr flipcolor jsr flipcolor
dey ; TGI_ERR_OK .assert TGI_ERR_OK = 0, error
dey
sty ERROR sty ERROR
sty PARAM1+1 sty PARAM1+1
jmp INK jmp INK

View File

@ -87,16 +87,17 @@ INSTALL:
cli cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@ram_present: @ram_present:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -120,16 +120,16 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@ -87,16 +87,17 @@ INSTALL:
cli cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@ram_present: @ram_present:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -68,8 +68,9 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -107,8 +107,9 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -97,13 +97,14 @@ INSTALL:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@notpresent: @notpresent:
@readonly: @readonly:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -126,8 +126,9 @@ size_found:
pagecount_ok: pagecount_ok:
stx pagecount stx pagecount
sty pagecount+1 sty pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
; common REU setup for size check ; common REU setup for size check

View File

@ -121,8 +121,9 @@ INSTALL:
lda vdc_cset_save lda vdc_cset_save
jsr vdcputreg jsr vdcputreg
@keep64kBit: @keep64kBit:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@ -53,8 +53,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -194,9 +194,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -228,9 +228,10 @@ INSTALL:
jsr MoveX jsr MoveX
cli cli
; Done, return zero. ; Done
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts

View File

@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@ -187,8 +187,9 @@ SetNMI: sta NMIVec
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -264,22 +265,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -300,8 +302,9 @@ SER_CLOSE:
; Return OK ; Return OK
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -322,8 +325,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -370,7 +373,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@ -379,7 +382,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -392,7 +396,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -402,8 +407,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -77,12 +77,13 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
rts rts
nomem: ldx #>EM_ERR_NO_DEVICE nomem: ldx #EM_ERR_NO_DEVICE
lda #<EM_ERR_NO_DEVICE lda #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -120,13 +120,14 @@ INSTALL:
dex dex
@noextradex: @noextradex:
stx bankcount stx bankcount
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@not_present: @not_present:
cli cli
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -158,13 +158,14 @@ INSTALL:
jsr restore_data jsr restore_data
cpy #$01 cpy #$01
beq @present beq @present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -147,13 +147,14 @@ INSTALL:
jsr restore_data jsr restore_data
cpy #$01 cpy #$01
beq @present beq @present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -121,16 +121,17 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE .assert EM_ERR_OK = 0, error
tax
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@ -76,13 +76,14 @@ INSTALL:
beq @setok beq @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -82,13 +82,14 @@ INSTALL:
cmp #$AA cmp #$AA
bne @notpresent bne @notpresent
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; use rts from UNINSTALL below ; use rts from UNINSTALL below
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -65,8 +65,9 @@ window: .res 256 ; Memory "window"
INSTALL: INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -98,13 +98,13 @@ INSTALL:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
@notpresent: @notpresent:
@readonly: @readonly:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -127,8 +127,9 @@ size_found:
pagecount_ok: pagecount_ok:
stx pagecount stx pagecount
sty pagecount+1 sty pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
; common REU setup for size check ; common REU setup for size check
@ -152,6 +153,7 @@ reu_size_check_common:
nodevice: nodevice:
lda #EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
.assert EM_ERR_OK = 0, error
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -87,8 +87,8 @@ INSTALL:
bne @L0 bne @L0
iny iny
bne @L0 bne @L0
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ; ldx #0 ; return value is char
rts rts
@present: @present:
@ -131,8 +131,9 @@ INSTALL:
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
@endok: @endok:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@ -93,15 +93,16 @@ INSTALL:
; DTV not found ; DTV not found
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
ldx #$FF ldx #$FF
stx curpage+1 ; Invalidate curpage stx curpage+1 ; Invalidate curpage
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A/X = EM_ERR_OK inx
txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -59,8 +59,9 @@ temp4: .byte 0
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -100,12 +100,14 @@ masktable:
; ;
INSTALL: INSTALL:
lda #JOY_ERR_OK ; Assume we have a joystick lda #JOY_ERR_OK ; Assume we have a "joystick"
ldx VIC_CLK_128 ; Test for a C128 .assert JOY_ERR_OK = 0, error
cpx #$FF tax ; Set high byte
ldy VIC_CLK_128 ; Test for a C128
cpy #$FF
bne @C128 ; Jump if we have one bne @C128 ; Jump if we have one
lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad
@C128: ldx #0 ; Set high byte @C128:
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -52,8 +52,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -56,8 +56,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -152,9 +152,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@ -307,8 +308,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -168,6 +168,7 @@ INSTALL:
; Done, return zero. ; Done, return zero.
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts
@ -319,8 +320,8 @@ INFO: jsr POS
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -156,9 +156,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@ -312,8 +313,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -139,9 +139,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@ -297,8 +298,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -161,8 +161,9 @@ SetNMI: sta NMIVec
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -238,22 +239,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -274,8 +276,9 @@ SER_CLOSE:
; Return OK ; Return OK
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -296,8 +299,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -344,7 +347,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@ -353,7 +356,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -366,7 +370,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -376,8 +381,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -9,8 +9,6 @@
.import pusha0, tosudiva0 .import pusha0, tosudiva0
.importzp sreg, ptr1, ptr2 .importzp sreg, ptr1, ptr2
.macpack generic
initcwd: initcwd:
lda #<__cwd lda #<__cwd
ldx #>__cwd ldx #>__cwd
@ -27,15 +25,20 @@ devicestr:
lda #10 lda #10
jsr tosudiva0 jsr tosudiva0
ldy #0 ldy #0
lda sreg tax ; result of the division (lsb)
beq @L0 ; >=10 beq @L0 ; < 10
add #'0'
clc
adc #'0'
sta (ptr2),y sta (ptr2),y
iny iny
@L0: lda ptr1 ; rem @L0:
add #'0' lda sreg ; reminder of the division
clc
adc #'0'
sta (ptr2),y sta (ptr2),y
iny iny
lda #0
lda #0 ; terminating 0
sta (ptr2),y sta (ptr2),y
rts rts

View File

@ -81,8 +81,9 @@ INSTALL:
sbc #$00 sbc #$00
sta pagecount sta pagecount
@L1: lda #<EM_ERR_OK @L1: lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -175,6 +175,7 @@ INSTALL:
; Done, return zero. ; Done, return zero.
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts
@ -331,8 +332,8 @@ INFO: jsr POS
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -140,7 +140,8 @@ INSTALL:
; Done, return zero. ; Done, return zero.
ldx #>MOUSE_ERR_OK ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@ -315,8 +316,8 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -148,8 +148,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -217,22 +218,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -253,8 +255,8 @@ SER_GET:
@L1: lda RecvFreeCnt @L1: lda RecvFreeCnt
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -301,7 +303,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@ -310,7 +312,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -328,7 +331,8 @@ SER_STATUS:
sta (ptr1,x) sta (ptr1,x)
lda IndReg lda IndReg
sta ExecReg sta ExecReg
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -338,8 +342,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -81,8 +81,9 @@ INSTALL:
sbc #$00 sbc #$00
sta pagecount sta pagecount
@L1: lda #<EM_ERR_OK @L1: lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -149,8 +149,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -218,22 +219,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -254,8 +256,8 @@ SER_GET:
@L1: lda RecvFreeCnt @L1: lda RecvFreeCnt
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -302,7 +304,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@ -311,7 +313,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -339,8 +342,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -502,10 +502,10 @@ DoFormat:
; It is a character ; It is a character
jsr GetIntArg ; Get the argument (promoted to int) jsr GetIntArg ; Get the argument (promoted to int)
sta Buf ; Place it as zero terminated string... sta Buf ; Place it into the buffer
lda #0 ldx #0
sta Buf+1 ; ...into the buffer lda #1 ; Buffer length is 1
jmp HaveArg ; Done jmp HaveArg1
; Is it an integer? ; Is it an integer?
@ -671,6 +671,7 @@ HaveArg:
lda Str lda Str
ldx Str+1 ldx Str+1
jsr _strlen ; Get length of argument jsr _strlen ; Get length of argument
HaveArg1: ; Jumped into here from %c handling
sta ArgLen sta ArgLen
stx ArgLen+1 stx ArgLen+1

View File

@ -59,7 +59,8 @@ JOY_RIGHT = $08
; ;
INSTALL: lda #JOY_ERR_OK INSTALL: lda #JOY_ERR_OK
ldx #>$0000 .assert JOY_ERR_OK = 0, error
tax
; rts ; Fall through ; rts ; Fall through
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -55,8 +55,9 @@ JOY_COUNT = $05 ; Number of joysticks we support
; Must return a JOY_ERR_xx code in .XA . ; Must return a JOY_ERR_xx code in .XA .
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -139,7 +139,8 @@ INSTALL:
; Done, return zero ; Done, return zero
ldx #>MOUSE_ERR_OK ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@ -300,8 +301,8 @@ INFO: jsr BUTTONS ; Will not touch ptr1
; specific data in ptr1, and the ioctl code in A. ; specific data in ptr1, and the ioctl code in A.
; Must return an error code in .XA . ; Must return an error code in .XA .
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
; rts ; Fall through ; rts ; Fall through
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -47,8 +47,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -125,8 +125,9 @@ INSTALL:
pla pla
sta $01 sta $01
plp plp
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@ -53,8 +53,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -10,7 +10,7 @@
.include "modload.inc" .include "modload.inc"
.import joy_clear_ptr .import joy_clear_ptr
.import return0 .import return0, return1
@ -31,7 +31,6 @@ _joy_unload:
jmp return0 ; Return JOY_ERR_OK jmp return0 ; Return JOY_ERR_OK
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #JOY_ERR_NO_DRIVER .assert JOY_ERR_NO_DRIVER = 1, error
rts jmp return1 ; Return JOY_ERR_NO_DRIVER

View File

@ -58,8 +58,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -75,8 +75,9 @@ SER_UNINSTALL:
SER_CLOSE: SER_CLOSE:
; Disable interrupts ; Disable interrupts
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -190,8 +191,8 @@ SER_OPEN:
cmp #SER_BAUD_134_5 cmp #SER_BAUD_134_5
beq setbaudrate beq setbaudrate
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
setprescaler: setprescaler:
stx TIM4CTLA stx TIM4CTLA
@ -238,12 +239,13 @@ checkhs:
lda contrl lda contrl
ora #RxIntEnable|ResetErr ora #RxIntEnable|ResetErr
sta SERCTL sta SERCTL
lda #<SER_ERR_OK lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
invparameter: invparameter:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -255,8 +257,8 @@ SER_GET:
lda RxPtrIn lda RxPtrIn
cmp RxPtrOut cmp RxPtrOut
bne GetByte bne GetByte
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
GetByte: GetByte:
ldy RxPtrOut ldy RxPtrOut
@ -277,8 +279,8 @@ SER_PUT:
ina ina
cmp TxPtrOut cmp TxPtrOut
bne PutByte bne PutByte
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
PutByte: PutByte:
ldy TxPtrIn ldy TxPtrIn
@ -296,7 +298,8 @@ PutByte:
sta TxDone sta TxDone
plp plp
@L1: @L1:
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -317,8 +320,8 @@ SER_STATUS:
; Must return an SER_ERR_xx code in a/x. ; Must return an SER_ERR_xx code in a/x.
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -8,7 +8,7 @@
.include "mouse-kernel.inc" .include "mouse-kernel.inc"
.include "modload.inc" .include "modload.inc"
.import return0 .import return0, return1
@ -29,7 +29,6 @@ _mouse_unload:
jmp return0 ; Return MOUSE_ERR_OK jmp return0 ; Return MOUSE_ERR_OK
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #<MOUSE_ERR_NO_DRIVER .assert MOUSE_ERR_NO_DRIVER = 1, error
rts jmp return1 ; Return MOUSE_ERR_NO_DRIVER

View File

@ -53,7 +53,8 @@ JOY_COUNT = 2 ; Number of joysticks we support
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -50,8 +50,9 @@ padbuffer: .res JOY_COUNT
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -51,8 +51,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -58,8 +58,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -157,8 +157,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -225,22 +226,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -261,8 +263,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@ -309,7 +311,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@ -318,7 +320,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@ -331,7 +334,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -341,8 +345,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts ; Run into IRQ instead rts ; Run into IRQ instead
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@ -10,7 +10,7 @@
.include "modload.inc" .include "modload.inc"
.import ser_clear_ptr .import ser_clear_ptr
.import return0 .import return0, return1
@ -28,10 +28,10 @@ _ser_unload:
tax tax
pla ; Get pointer to driver pla ; Get pointer to driver
jsr _mod_free ; Free the driver jsr _mod_free ; Free the driver
jmp return0 ; Return SER_ERR_OK .assert SER_ERR_OK = 0, error
jmp return0
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #<SER_ERR_NO_DRIVER .assert SER_ERR_NO_DRIVER = 1, error
rts jmp return1

View File

@ -46,8 +46,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@ -54,8 +54,9 @@ INSTALL:
sta VIA2::PRB sta VIA2::PRB
; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after ; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after
; But if some one press fire or press direction, we could reach others values which could break joystick detection. ; But if some one press fire or press direction, we could reach others values which could break joystick detection.
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -119,16 +119,16 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@ -71,12 +71,13 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
rts rts
nomem: ldx #>EM_ERR_NO_DEVICE nomem: ldx #0 ; return value is char
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -53,8 +53,9 @@ JOY_COUNT = 3 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -57,8 +57,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@ -115,7 +115,11 @@ install:
$(INSTALL) ../bin/* $(DESTDIR)$(bindir) $(INSTALL) ../bin/* $(DESTDIR)$(bindir)
avail: avail:
ifneq ($(patsubst %,../bin/%,$(PROGS)),$(wildcard $(patsubst %,../bin/%,$(PROGS))))
$(error executables are missing, please run make first)
else
$(foreach prog,$(PROGS),$(AVAIL_recipe)) $(foreach prog,$(PROGS),$(AVAIL_recipe))
endif
unavail: unavail:
$(foreach prog,$(PROGS),$(UNAVAIL_recipe)) $(foreach prog,$(PROGS),$(UNAVAIL_recipe))

View File

@ -66,6 +66,7 @@ static const char* const FeatureKeys[FEAT_COUNT] = {
"addrsize", "addrsize",
"bracket_as_indirect", "bracket_as_indirect",
"string_escapes", "string_escapes",
"long_jsr_jmp_rts",
}; };
@ -97,37 +98,30 @@ feature_t FindFeature (const StrBuf* Key)
feature_t SetFeature (const StrBuf* Key) void SetFeature (feature_t Feature, unsigned char On)
/* Find the feature and set the corresponding flag if the feature is known. /* Set the corresponding feature flag if Feature is valid.
** In any case, return the feature found. An invalid Key will return
** FEAT_UNKNOWN.
*/ */
{ {
/* Map the string to an enum value */
feature_t Feature = FindFeature (Key);
/* Set the flags */ /* Set the flags */
switch (Feature) { switch (Feature) {
case FEAT_DOLLAR_IS_PC: DollarIsPC = 1; break; case FEAT_DOLLAR_IS_PC: DollarIsPC = On; break;
case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = 1; break; case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = On; break;
case FEAT_LOOSE_STRING_TERM: LooseStringTerm = 1; break; case FEAT_LOOSE_STRING_TERM: LooseStringTerm = On; break;
case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = 1; break; case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = On; break;
case FEAT_AT_IN_IDENTIFIERS: AtInIdents = 1; break; case FEAT_AT_IN_IDENTIFIERS: AtInIdents = On; break;
case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = 1; break; case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = On; break;
case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= 1; break; case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= On; break;
case FEAT_ORG_PER_SEG: OrgPerSeg = 1; break; case FEAT_ORG_PER_SEG: OrgPerSeg = On; break;
case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break; case FEAT_PC_ASSIGNMENT: PCAssignment = On; break;
case FEAT_MISSING_CHAR_TERM: MissingCharTerm = 1; break; case FEAT_MISSING_CHAR_TERM: MissingCharTerm = On; break;
case FEAT_UBIQUITOUS_IDENTS: UbiquitousIdents = 1; break; case FEAT_UBIQUITOUS_IDENTS: UbiquitousIdents = On; break;
case FEAT_C_COMMENTS: CComments = 1; break; case FEAT_C_COMMENTS: CComments = On; break;
case FEAT_FORCE_RANGE: ForceRange = 1; break; case FEAT_FORCE_RANGE: ForceRange = On; break;
case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break; case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= On; break;
case FEAT_ADDRSIZE: AddrSize = 1; break; case FEAT_ADDRSIZE: AddrSize = On; break;
case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = 1; break; case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = On; break;
case FEAT_STRING_ESCAPES: StringEscapes = 1; break; case FEAT_STRING_ESCAPES: StringEscapes = On; break;
default: /* Keep gcc silent */ break; case FEAT_LONG_JSR_JMP_RTS: LongJsrJmpRts = On; break;
default: break;
} }
/* Return the value found */
return Feature;
} }

View File

@ -68,6 +68,7 @@ typedef enum {
FEAT_ADDRSIZE, FEAT_ADDRSIZE,
FEAT_BRACKET_AS_INDIRECT, FEAT_BRACKET_AS_INDIRECT,
FEAT_STRING_ESCAPES, FEAT_STRING_ESCAPES,
FEAT_LONG_JSR_JMP_RTS,
/* Special value: Number of features available */ /* Special value: Number of features available */
FEAT_COUNT FEAT_COUNT
@ -86,10 +87,8 @@ feature_t FindFeature (const StrBuf* Key);
** feature is invalid, return FEAT_UNKNOWN. ** feature is invalid, return FEAT_UNKNOWN.
*/ */
feature_t SetFeature (const StrBuf* Key); void SetFeature (feature_t Feature, unsigned char On);
/* Find the feature and set the corresponding flag if the feature is known. /* Set the corresponding feature flag if Feature is valid.
** In any case, return the feature found. An invalid Key will return
** FEAT_UNKNOWN.
*/ */

View File

@ -67,6 +67,8 @@ unsigned char LineCont = 0; /* Allow line continuation */
unsigned char LargeAlignment = 0; /* Don't warn about large alignments */ unsigned char LargeAlignment = 0; /* Don't warn about large alignments */
unsigned char RelaxChecks = 0; /* Relax a few assembler checks */ unsigned char RelaxChecks = 0; /* Relax a few assembler checks */
unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */ unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */
unsigned char LongJsrJmpRts = 0; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
/* Emulation features */ /* Emulation features */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */ unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */

View File

@ -69,6 +69,8 @@ extern unsigned char LineCont; /* Allow line continuation */
extern unsigned char LargeAlignment; /* Don't warn about large alignments */ extern unsigned char LargeAlignment; /* Don't warn about large alignments */
extern unsigned char RelaxChecks; /* Relax a few assembler checks */ extern unsigned char RelaxChecks; /* Relax a few assembler checks */
extern unsigned char StringEscapes; /* Allow C-style escapes in strings */ extern unsigned char StringEscapes; /* Allow C-style escapes in strings */
extern unsigned char LongJsrJmpRts; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
extern unsigned char WarningsAsErrors; /* Error if any warnings */
/* Emulation features */ /* Emulation features */
extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */ extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */

View File

@ -120,9 +120,21 @@ static void PutJMP (const InsDesc* Ins);
** to check for this case and is otherwise identical to PutAll. ** to check for this case and is otherwise identical to PutAll.
*/ */
static void PutJMP816 (const InsDesc* Ins);
/* Handle the JMP instruction for the 816.
** Allowing the long_jsr_jmp_rts feature to permit a long JMP.
** Note that JMP [abs] and JML [abs] are always both permitted for instruction $DC,
** because the [] notation for long indirection makes the generated instruction unambiguous.
*/
static void PutJSR816 (const InsDesc* Ins);
/* Handle the JSR instruction for the 816.
** Allowing the long_jsr_jmp_rts feature to permit a long JSR.
*/
static void PutRTS (const InsDesc* Ins attribute ((unused))); static void PutRTS (const InsDesc* Ins attribute ((unused)));
/* Handle the RTS instruction for the 816. In smart mode emit a RTL opcode if /* Handle the RTS instruction for the 816. In smart mode emit a RTL opcode if
** the enclosing scope is FAR. ** the enclosing scope is FAR, but only if the long_jsr_jmp_rts feature applies.
*/ */
static void PutAll (const InsDesc* Ins); static void PutAll (const InsDesc* Ins);
@ -169,7 +181,7 @@ static const struct {
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 }, { "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll }, { "CLC", 0x0000001, 0x18, 0, PutAll },
@ -240,7 +252,7 @@ static const struct {
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 }, { "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll }, { "CLC", 0x0000001, 0x18, 0, PutAll },
@ -330,7 +342,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x12, 0, PutPCRel8 }, /* DTV */ { "BRA", 0x0020000, 0x12, 0, PutPCRel8 }, /* DTV */
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll }, { "CLC", 0x0000001, 0x18, 0, PutAll },
@ -406,7 +418,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll }, { "CLC", 0x0000001, 0x18, 0, PutAll },
@ -498,7 +510,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll }, { "CLC", 0x0000001, 0x18, 0, PutAll },
@ -610,7 +622,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BSR", 0x0040000, 0x63, 0, PutPCRel4510 }, { "BSR", 0x0040000, 0x63, 0, PutPCRel4510 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
@ -735,7 +747,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000005, 0x00, 6, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BRL", 0x0040000, 0x82, 0, PutPCRel16 }, { "BRL", 0x0040000, 0x82, 0, PutPCRel16 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
@ -744,7 +756,7 @@ static const struct {
{ "CLI", 0x0000001, 0x58, 0, PutAll }, { "CLI", 0x0000001, 0x58, 0, PutAll },
{ "CLV", 0x0000001, 0xb8, 0, PutAll }, { "CLV", 0x0000001, 0xb8, 0, PutAll },
{ "CMP", 0x0b8f6fc, 0xc0, 0, PutAll }, { "CMP", 0x0b8f6fc, 0xc0, 0, PutAll },
{ "COP", 0x0000004, 0x02, 6, PutAll }, { "COP", 0x0800005, 0x02, 6, PutAll },
{ "CPA", 0x0b8f6fc, 0xc0, 0, PutAll }, /* == CMP */ { "CPA", 0x0b8f6fc, 0xc0, 0, PutAll }, /* == CMP */
{ "CPX", 0x0c0000c, 0xe0, 1, PutAll }, { "CPX", 0x0c0000c, 0xe0, 1, PutAll },
{ "CPY", 0x0c0000c, 0xc0, 1, PutAll }, { "CPY", 0x0c0000c, 0xc0, 1, PutAll },
@ -758,9 +770,9 @@ static const struct {
{ "INX", 0x0000001, 0xe8, 0, PutAll }, { "INX", 0x0000001, 0xe8, 0, PutAll },
{ "INY", 0x0000001, 0xc8, 0, PutAll }, { "INY", 0x0000001, 0xc8, 0, PutAll },
{ "JML", 0x4000010, 0x5c, 1, PutAll }, { "JML", 0x4000010, 0x5c, 1, PutAll },
{ "JMP", 0x4010818, 0x4c, 6, PutAll }, { "JMP", 0x4010818, 0x4c, 6, PutJMP816 },
{ "JSL", 0x0000010, 0x20, 7, PutAll }, { "JSL", 0x0000010, 0x20, 7, PutAll },
{ "JSR", 0x0010018, 0x20, 7, PutAll }, { "JSR", 0x0010018, 0x20, 7, PutJSR816 },
{ "LDA", 0x0b8f6fc, 0xa0, 0, PutAll }, { "LDA", 0x0b8f6fc, 0xa0, 0, PutAll },
{ "LDX", 0x0c0030c, 0xa2, 1, PutAll }, { "LDX", 0x0c0030c, 0xa2, 1, PutAll },
{ "LDY", 0x0c0006c, 0xa0, 1, PutAll }, { "LDY", 0x0c0006c, 0xa0, 1, PutAll },
@ -821,7 +833,7 @@ static const struct {
{ "TYA", 0x0000001, 0x98, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll },
{ "TYX", 0x0000001, 0xbb, 0, PutAll }, { "TYX", 0x0000001, 0xbb, 0, PutAll },
{ "WAI", 0x0000001, 0xcb, 0, PutAll }, { "WAI", 0x0000001, 0xcb, 0, PutAll },
{ "WDM", 0x0000004, 0x42, 6, PutAll }, { "WDM", 0x0800004, 0x42, 6, PutAll },
{ "XBA", 0x0000001, 0xeb, 0, PutAll }, { "XBA", 0x0000001, 0xeb, 0, PutAll },
{ "XCE", 0x0000001, 0xfb, 0, PutAll } { "XCE", 0x0000001, 0xfb, 0, PutAll }
} }
@ -897,7 +909,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll }, { "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BSR", 0x0020000, 0x44, 0, PutPCRel8 }, { "BSR", 0x0020000, 0x44, 0, PutPCRel8 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
@ -1627,12 +1639,46 @@ static void PutJMP (const InsDesc* Ins)
static void PutRTS (const InsDesc* Ins attribute ((unused))) static void PutJMP816 (const InsDesc* Ins)
/* Handle the RTS instruction for the 816. In smart mode emit a RTL opcode if /* Handle the JMP instruction for the 816.
** the enclosing scope is FAR. ** Allowing the long_jsr_jmp_rts feature to permit a long JMP.
** Note that JMP [abs] and JML [abs] are always both permitted for instruction $DC,
** because the [] notation for long indirection makes the generated instruction unambiguous.
*/ */
{ {
if (SmartMode && CurrentScope->AddrSize == ADDR_SIZE_FAR) { if (LongJsrJmpRts) {
PutJMP (Ins);
} else {
InsDesc InsAbs = *Ins;
InsAbs.AddrMode &= ~(AM65_ABS_LONG);
PutJMP (&InsAbs);
}
}
static void PutJSR816 (const InsDesc* Ins)
/* Handle the JSR instruction for the 816.
** Allowing the long_jsr_jmp_rts feature to permit a long JSR.
*/
{
if (LongJsrJmpRts) {
PutAll (Ins);
} else {
InsDesc InsAbs = *Ins;
InsAbs.AddrMode &= ~(AM65_ABS_LONG);
PutJMP (&InsAbs);
}
}
static void PutRTS (const InsDesc* Ins attribute ((unused)))
/* Handle the RTS instruction for the 816. In smart mode emit a RTL opcode if
** the enclosing scope is FAR, but only if the long_jsr_jmp_rts feature applies.
*/
{
if (LongJsrJmpRts && SmartMode && CurrentScope->AddrSize == ADDR_SIZE_FAR) {
Emit0 (0x6B); /* RTL */ Emit0 (0x6B); /* RTL */
} else { } else {
Emit0 (0x60); /* RTS */ Emit0 (0x60); /* RTS */

View File

@ -390,7 +390,20 @@ void MacDef (unsigned Style)
{ {
Macro* M; Macro* M;
TokNode* N; TokNode* N;
FilePos Pos;
int HaveParams; int HaveParams;
int LastTokWasSep;
/* For classic macros, remember if we are at the beginning of the line.
** If the macro name and parameters pass our checks then we will be on a
** new line, so set it now
*/
LastTokWasSep = 1;
/* Save the position of the start of the macro definition to allow
** using Perror to display the error if .endmacro isn't found
*/
Pos = CurTok.Pos;
/* We expect a macro name here */ /* We expect a macro name here */
if (CurTok.Tok != TOK_IDENT) { if (CurTok.Tok != TOK_IDENT) {
@ -491,14 +504,16 @@ void MacDef (unsigned Style)
while (1) { while (1) {
/* Check for end of macro */ /* Check for end of macro */
if (Style == MAC_STYLE_CLASSIC) { if (Style == MAC_STYLE_CLASSIC) {
/* In classic macros, only .endmacro is allowed */ /* In classic macros, if .endmacro is not at the start of the line
if (CurTok.Tok == TOK_ENDMACRO) { ** it will be added to the macro definition instead of closing it.
*/
if (CurTok.Tok == TOK_ENDMACRO && LastTokWasSep) {
/* Done */ /* Done */
break; break;
} }
/* May not have end of file in a macro definition */ /* May not have end of file in a macro definition */
if (CurTok.Tok == TOK_EOF) { if (CurTok.Tok == TOK_EOF) {
Error ("'.ENDMACRO' expected"); PError (&Pos, "'.ENDMACRO' expected for macro '%m%p'", &M->Name);
goto Done; goto Done;
} }
} else { } else {
@ -573,6 +588,11 @@ void MacDef (unsigned Style)
} }
++M->TokCount; ++M->TokCount;
/* Save if last token was a separator to know if .endmacro is at
** the start of a line
*/
LastTokWasSep = TokIsSep(CurTok.Tok);
/* Read the next token */ /* Read the next token */
NextTok (); NextTok ();
} }

View File

@ -489,12 +489,15 @@ static void OptDebugInfo (const char* Opt attribute ((unused)),
static void OptFeature (const char* Opt attribute ((unused)), const char* Arg) static void OptFeature (const char* Opt attribute ((unused)), const char* Arg)
/* Set an emulation feature */ /* Set an emulation feature */
{ {
/* Make a string buffer from Arg */ /* Make a string buffer from Arg and use it to find the feature. */
StrBuf Feature; StrBuf StrFeature;
feature_t Feature = FindFeature (SB_InitFromString (&StrFeature, Arg));
/* Set the feature, check for errors */ /* Enable the feature, check for errors */
if (SetFeature (SB_InitFromString (&Feature, Arg)) == FEAT_UNKNOWN) { if (Feature == FEAT_UNKNOWN) {
AbEnd ("Illegal emulation feature: '%s'", Arg); AbEnd ("Illegal emulation feature: '%s'", Arg);
} else {
SetFeature (Feature, 1);
} }
} }
@ -656,6 +659,15 @@ static void OptVersion (const char* Opt attribute ((unused)),
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Generate an error if any warnings occur */
{
WarningsAsErrors = 1;
}
static void DoPCAssign (void) static void DoPCAssign (void)
/* Start absolute code */ /* Start absolute code */
{ {
@ -940,6 +952,7 @@ int main (int argc, char* argv [])
{ "--target", 1, OptTarget }, { "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose }, { "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion }, { "--version", 0, OptVersion },
{ "--warnings-as-errors", 0, OptWarningsAsErrors },
}; };
/* Name of the global name space */ /* Name of the global name space */
@ -1144,6 +1157,10 @@ int main (int argc, char* argv [])
SegDump (); SegDump ();
} }
if (WarningCount > 0 && WarningsAsErrors) {
Error("Warnings as errors");
}
/* If we didn't have an errors, finish off the line infos */ /* If we didn't have an errors, finish off the line infos */
DoneLineInfo (); DoneLineInfo ();

View File

@ -1023,7 +1023,10 @@ static void DoFatal (void)
static void DoFeature (void) static void DoFeature (void)
/* Switch the Feature option */ /* Switch the Feature option */
{ {
/* Allow a list of comma separated keywords */ feature_t Feature;
unsigned char On;
/* Allow a list of comma separated feature keywords with optional +/- or ON/OFF */
while (1) { while (1) {
/* We expect an identifier */ /* We expect an identifier */
@ -1034,18 +1037,24 @@ static void DoFeature (void)
/* Make the string attribute lower case */ /* Make the string attribute lower case */
LocaseSVal (); LocaseSVal ();
Feature = FindFeature(&CurTok.SVal);
/* Set the feature and check for errors */ if (Feature == FEAT_UNKNOWN) {
if (SetFeature (&CurTok.SVal) == FEAT_UNKNOWN) {
/* Not found */ /* Not found */
ErrorSkip ("Invalid feature: '%m%p'", &CurTok.SVal); ErrorSkip ("Invalid feature: '%m%p'", &CurTok.SVal);
return; return;
} else { }
/* Skip the keyword */
NextTok (); NextTok ();
/* Optional +/- or ON/OFF */
On = 1;
if (CurTok.Tok != TOK_COMMA && !TokIsSep (CurTok.Tok)) {
SetBoolOption(&On);
} }
/* Allow more than one keyword */ /* Apply feature setting. */
SetFeature (Feature, On);
/* Allow more than one feature separated by commas. */
if (CurTok.Tok == TOK_COMMA) { if (CurTok.Tok == TOK_COMMA) {
NextTok (); NextTok ();
} else { } else {

View File

@ -306,7 +306,7 @@ void SegAlign (unsigned long Alignment, int FillVal)
ActiveSeg->Align = CombinedAlignment; ActiveSeg->Align = CombinedAlignment;
/* Output a warning for larger alignments if not suppressed */ /* Output a warning for larger alignments if not suppressed */
if (CombinedAlignment >= LARGE_ALIGNMENT && !LargeAlignment) { if (CombinedAlignment >= LARGE_ALIGNMENT && CombinedAlignment > ActiveSeg->Align && CombinedAlignment > Alignment && !LargeAlignment) {
Warning (0, "Combined alignment is suspiciously large (%lu)", Warning (0, "Combined alignment is suspiciously large (%lu)",
CombinedAlignment); CombinedAlignment);
} }

View File

@ -570,7 +570,18 @@ void SymCheck (void)
/* Check for open scopes */ /* Check for open scopes */
if (CurrentScope->Parent != 0) { if (CurrentScope->Parent != 0) {
Error ("Local scope was not closed"); if (CurrentScope->Label) {
/* proc has a label indicating the line it was opened. */
LIError (&CurrentScope->Label->DefLines,
"Local proc '%s' was not closed",
GetString (CurrentScope->Name));
} else {
/* scope has no label to track a line number, uses end-of-document line instead.
** Anonymous scopes will reveal their internal automatic name.
*/
Error ("Local scope '%s' was not closed",
GetString (CurrentScope->Name));
}
} }
/* First pass: Walk through all symbols, checking for undefined's and /* First pass: Walk through all symbols, checking for undefined's and

View File

@ -1153,6 +1153,8 @@ static unsigned Opt_a_toscmpbool (StackOpData* D, const char* BoolTransformer)
/* Save lhs into zeropage */ /* Save lhs into zeropage */
AddStoreLhsA (D); AddStoreLhsA (D);
/* AddStoreLhsA may have moved the OpIndex, recalculate insertion point to prevent label migration. */
D->IP = D->OpIndex + 1;
/* cmp */ /* cmp */
X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI); X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI);
@ -1206,6 +1208,8 @@ static unsigned Opt_a_tosicmp (StackOpData* D)
/* RHS src is not directly comparable */ /* RHS src is not directly comparable */
X = NewCodeEntry (OP65_STA, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); X = NewCodeEntry (OP65_STA, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI);
InsertEntry (D, X, D->Rhs.A.ChgIndex + 1); InsertEntry (D, X, D->Rhs.A.ChgIndex + 1);
/* RHS insertion may have moved the OpIndex, recalculate insertion point to prevent label migration. */
D->IP = D->OpIndex + 1;
/* Cmp with stored RHS */ /* Cmp with stored RHS */
X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI);

Some files were not shown because too many files have changed in this diff Show More