diff --git a/.github/checks/Makefile b/.github/checks/Makefile new file mode 100644 index 000000000..dc42d14ca --- /dev/null +++ b/.github/checks/Makefile @@ -0,0 +1,13 @@ + +.PHONY: check tabs lastline spaces + +check: tabs lastline spaces + +tabs: tabs.sh + @./tabs.sh + +lastline: lastline.sh + @./lastline.sh + +spaces: spaces.sh + @./spaces.sh diff --git a/.github/checks/lastline.sh b/.github/checks/lastline.sh new file mode 100755 index 000000000..d80d2fb57 --- /dev/null +++ b/.github/checks/lastline.sh @@ -0,0 +1,25 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` +CHECK_PATH=. + +cd $SCRIPT_PATH/../../ + +nl=' +' +nl=$'\n' +r1="${nl}$" +FILES=`find $CHECK_PATH -type f \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | while read f; do + t=$(tail -c2 $f; printf x) + [[ ${t%x} =~ $r1 ]] || echo "$f" +done` + +cd $OLDCWD + +if [ x"$FILES"x != xx ]; then + echo "error: found following files that have no newline at the end:" >&2 + for n in $FILES; do + echo $n >&2 + done + exit -1 +fi diff --git a/.github/checks/spaces.sh b/.github/checks/spaces.sh new file mode 100755 index 000000000..945e9acc3 --- /dev/null +++ b/.github/checks/spaces.sh @@ -0,0 +1,18 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` +CHECK_PATH=. + +cd $SCRIPT_PATH/../../ + +FILES=`find $CHECK_PATH -type f \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l ' $'` + +cd $OLDCWD + +if [ x"$FILES"x != xx ]; then + echo "error: found dangling spaces in the following files:" >&2 + for n in $FILES; do + echo $n >&2 + done + exit -1 +fi diff --git a/.github/checks/tabs.sh b/.github/checks/tabs.sh new file mode 100755 index 000000000..1c32def17 --- /dev/null +++ b/.github/checks/tabs.sh @@ -0,0 +1,18 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` +CHECK_PATH=. + +cd $SCRIPT_PATH/../../ + +FILES=`find $CHECK_PATH -type f \( \( -name \*.inc -a \! -name Makefile.inc \) -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l $'\t'` + +cd $OLDCWD + +if [ x"$FILES"x != xx ]; then + echo "error: found TABs in the following files:" >&2 + for n in $FILES; do + echo $n >&2 + done + exit -1 +fi diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 6ab8543de..e9176f8c4 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -21,6 +21,9 @@ jobs: - name: Checkout Source uses: actions/checkout@v2 + - name: Do some simple style checks + shell: bash + run: make -j2 check - name: Build the tools. shell: bash run: make -j2 bin USER_CFLAGS=-Werror diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index fb4b3aa13..47abc3564 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -46,6 +46,9 @@ jobs: - name: Checkout Source uses: actions/checkout@v2 + - name: Do some simple style checks + shell: bash + run: make -j2 check - name: Build the tools. shell: bash run: | diff --git a/.gitignore b/.gitignore index ad4d26c3f..9112484b8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ /testwrk/ /wrk/ /cc65.zip +/util/atari/*.exe +/util/gamate/*.exe + diff --git a/Contributing.md b/Contributing.md new file mode 100644 index 000000000..6258ce523 --- /dev/null +++ b/Contributing.md @@ -0,0 +1,113 @@ +This document contains all kinds of information that you should know if you want to contribute to the cc65 project. Before you start, please read all of it. If something is not clear to you, please ask - this document is an ongoing effort and may well be incomplete. + +(''Note:'' The word "must" indicates a requirement. The word "should" indicates a recomendation.) + +# generally + +* You must obey these rules when contributing new code or documentation to cc65. We are well aware that not all existing code may respect all rules outlined here - but this is no reason for you not to respect them. +* One commit/patch/PR per issue. Do not mix several things unless they are very closely related. + +# Codestyle rules + +## All Sources + +### TABs and spaces + +This is an ongoing controversial topic - everyone knows that. However, the following is how we do it :) + +* TAB characters must be expanded to spaces. +* 4 spaces per indention level (rather than 8) are preferred, especially if there are many different levels. +* No extra spaces at the end of lines. +* All text files must end with new-line characters. Don't leave the last line "dangling". + +The (bash) scipts used to check the above rules can be found in ```.github/check```. You can also run all checks using ```make check```. + +### misc + +* 80 characters is the desired maximum width of files. But, it isn't a "strong" rule; sometimes, you will want to type longer lines, in order to keep the parts of expressions or comments together on the same line. +* You should avoid typing non-ASCII characters. +* If you change "normal" source code into comments, then you must add a comment about why that code is a comment. +* When you want to create a comment from several lines of code, you should use preprocessor lines, instead of ```/* */``` or "```;```". Example: +
+#if 0
+    one ();
+    two ();
+    three = two () + one ();
+#endif
+
+* You should type upper case characters for hex values. +* When you type zero-page addresses in hexadecimal, you should type two hex characters (after the hex prefix). When you type non-zero-page addresses in hex, you should type four hex characters. +* When you type lists of addresses, it is a good idea to sort them in ascending numerical order. That makes it easier for readers to build mental pictures of where things are in an address space. And, it is easier to see how big the variables and buffers are. Example: +
+xCoord := $0703
+yCoord := $0705        ; (this address implies that xCoord is 16 bits)
+cmdbuf := $0706        ; (this address implies that yCoord is 8 bits)
+cmdlen := $0786        ; (this address implies that cmdbuf is 128 bytes)
+color  := $0787
+
+ +## C Sources + +* Your files should obey the C89 standard. +* All declarations in a block must be at the beginning of that block. +* You should put a blank line between a list of local variable declarations and the first line of code. +* You must use ANSI C comments (```/* */```); you must not use C++ comments (```//```). +* The normal indentation width should be four spaces. +* When a function's argument list wraps around to a next line, you should indent that next line by either the normal width or enough spaces to align it with the arguments on the previous line. +* When you add functions to an existing file, you should separate them by the same number of blank lines that separate the functions that already are in that file. + +(The next two rules will be changed at some time in the future; but, for now:) + +* You must separate function names and parameter/argument lists by one space. +* When declaring/defining pointers, you must put the asterisk (```*```) next to the data type, with a space between it and the variable's name. Examples: +
+    int* namedPtr[5];
+    char* nextLine (FILE* f);
+
+ +## Assembly Sources + +* Op-code mnemonics must have lower-case letters. The names of instruction macroes may have upper-case letters. +* 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. +* 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.) +* 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. +* Comments that are put on the right side of instructions must be aligned (start in the same character columns). +* Assembly source fields (label, operation, operand, comment) should start ''after'' character columns that are multiples of eight (such as 1, 9, 17, 33, and 41). + +## LinuxDoc Sources + +* TAB characters must be expanded to spaces. +* All text files must end with new-line characters. Don't leave the last line "dangling". +* 80 characters is the desired maximum width of files. +* You should avoid typing non-ASCII characters. + +* You should put blank lines between LinuxDoc sections: + * Three blank lines between `````` sections. + * Two blank lines between `````` sections. + * One blank line between other sections. + +# Library implementation rules + +* By default the toolchain must output a "standard" binary for the platform, no emulator formats, no extra headers used by tools. If the resulting binaries can not be run as is on emulators or eg flash cartridges, the process of converting them to something that can be used with these should be documented in the user manual. +* Generally every function should live in a seperate source file - unless the functions are so closely related that splitting makes no sense. +* Source files should not contain commented out code - if they do, there should be a comment that explains why that commented out code exists. + +# Makefile rules + +* Makefiles must generally work on both *nix (ba)sh and windows cmd.exe. +* Makefiles must not use external tools that are not provided by the cc65 toolchain itself. + +The only exception to the above are actions that are exclusive to the github actions - those may rely on bash and/or linux tools. + +# Documentation rules + +## User manual (LinuxDoc) + +* This is the primary documentation. + +## Wiki + +* The Wiki is strictly for additional information that does not fit into the regular user manual (LinuxDoc). The wiki must not duplicate any information that is present in the user manual diff --git a/Makefile b/Makefile index 540c214fc..f565727e6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples test util +.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples test util check .SUFFIXES: @@ -24,6 +24,9 @@ samples: test: @$(MAKE) -C test --no-print-directory $@ +check: + @$(MAKE) -C .github/checks --no-print-directory $@ + util: @$(MAKE) -C util --no-print-directory $@ diff --git a/README.md b/README.md index 93b91aa80..fa23b1be2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ [Documentation](https://cc65.github.io/doc) -[Wiki](https://github.com/cc65/wiki/wiki) +[Contributing](Contributing.md) to the CC65 project. + +The [Wiki](https://github.com/cc65/wiki/wiki) contains extra info that does not fit into the regular documentation. [![Snapshot Build](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml/badge.svg?branch=master)](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml) @@ -27,6 +29,7 @@ including - the Atari 8-bit machines. - the Atari 2600 console. - the Atari 5200 console. +- the Atari 7800 console. - GEOS for the C64, C128 and Apple //e. - the Bit Corporation Gamate console. - the NEC PC-Engine (aka TurboGrafx-16) console. diff --git a/asminc/_file.inc b/asminc/_file.inc index 2f9938a3e..a9ac1e34a 100644 --- a/asminc/_file.inc +++ b/asminc/_file.inc @@ -24,4 +24,4 @@ _FPUSHBACK = $08 ; File table .global __filetab - + diff --git a/asminc/atari.mac b/asminc/atari.mac index 8e76888d7..3916254d0 100644 --- a/asminc/atari.mac +++ b/asminc/atari.mac @@ -1,5 +1,5 @@ ; Convert characters to screen codes - + ; Helper macro that converts and outputs one character .macro _scrcode char .if (char >= 0) .and (char <= 31) diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index a17268de2..b560c06af 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -7,7 +7,7 @@ ;------------------------------------------------------------------------- ; ATASCII CHARACTER DEFS ;------------------------------------------------------------------------- - + ATEOL = $9B ; END-OF-LINE, used by CONIO ;------------------------------------------------------------------------- @@ -27,9 +27,9 @@ CH_VLINE = $01 ; exclamation mark POKMSK = $00 ; Mask for Pokey IRQ enable RTCLOK = $01 ; 60 hz. clock -JUMP = $01 +JUMP = $01 CRITIC = $03 ; Critical section -ATRACT = $04 ; Attract Mode +ATRACT = $04 ; Attract Mode SDLSTL = $05 ; DLISTL Shadow SDLSTH = $06 ; DLISTH " @@ -66,20 +66,20 @@ SAVMSC = $1B ; pointer to screen memory (conio) ;------------------------------------------------------------------------- ;Interrupt Vectors - -VIMIRQ = $0200 ; Immediate IRQ + +VIMIRQ = $0200 ; Immediate IRQ ; Preset $FC03 (SYSIRQ) VVBLKI = $0202 ; Vblank immediate ; Preset $FCB8 (SYSVBL) VVBLKD = $0204 ; Vblank deferred ; Preset $FCB2 (XITVBL) -VDSLST = $0206 ; Display List +VDSLST = $0206 ; Display List ; Preset $FEA1 (OSDLI) VKYBDI = $0208 ; Keyboard immediate ; Preset $FD02 (SYSKBD) VKYBDF = $020A ; Deferred Keyboard ; Preset $FCB2 (XITVBL) -VTRIGR = $020C ; Soft Trigger +VTRIGR = $020C ; Soft Trigger VBRKOP = $020E ; BRK Opcode VSERIN = $0210 ; Serial in Ready VSEROR = $0212 ; Serial Out Ready diff --git a/asminc/atari7800.inc b/asminc/atari7800.inc new file mode 100644 index 000000000..a7625aa8a --- /dev/null +++ b/asminc/atari7800.inc @@ -0,0 +1,8 @@ +; Atari 7800 TIA & RIOT read / write registers +; +; Karri Kaksonen (karri@sipo.fi), 2022 + +; TIA, RIOT & MARIA registers mapping +.include "atari7800_tia.inc" +.include "atari7800_riot.inc" +.include "atari7800_maria.inc" diff --git a/asminc/atari7800_maria.inc b/asminc/atari7800_maria.inc new file mode 100644 index 000000000..39624d21d --- /dev/null +++ b/asminc/atari7800_maria.inc @@ -0,0 +1,39 @@ +; Atari 7800 MARIA read / write registers +; + +; Read registers +BKGRND := $20 +P0C1 := $21 +P0C2 := $22 +P0C3 := $23 +MWSYNC := $24 +P1C1 := $25 +P1C2 := $26 +P1C3 := $27 +MSTAT := $28 +P2C1 := $29 +P2C2 := $2A +P2C3 := $2B +DPPH := $2C +P3C1 := $2D +P3C2 := $2E +P3C3 := $2F +DPPL := $30 +P4C1 := $31 +P4C2 := $32 +P4C3 := $33 +CHBASE := $34 +P5C1 := $35 +P5C2 := $36 +P5C3 := $37 +OFFSET := $38 +P6C1 := $39 +P6C2 := $3A +P6C3 := $3B +CTRL := $3C +P7C1 := $3D +P7C2 := $3E +P7C3 := $3F + +; Write registers + diff --git a/asminc/atari7800_riot.inc b/asminc/atari7800_riot.inc new file mode 100644 index 000000000..780e34df3 --- /dev/null +++ b/asminc/atari7800_riot.inc @@ -0,0 +1,20 @@ +; Atari 7800 RIOT read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +SWCHA := $0280 +CTLSWA := $0281 +SWCHB := $0282 +CTLSWB := $0283 +INTIM := $0284 +TIMINT := $0285 + +; Write registers +TIM1T := $0294 +TIM8T := $0295 +TIM64T := $0296 +T1024T := $0297 diff --git a/asminc/atari7800_tia.inc b/asminc/atari7800_tia.inc new file mode 100644 index 000000000..f4439e421 --- /dev/null +++ b/asminc/atari7800_tia.inc @@ -0,0 +1,69 @@ +; Atari 7800 TIA read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +VSYNC := $00 +VBLANK := $01 +WSYNC := $02 +RSYNC := $03 +NUSIZ0 := $04 +NUSIZ1 := $05 +COLUP0 := $06 +COLUP1 := $07 +COLUPF := $08 +COLUBK := $09 +CTRLPF := $0A +REFP0 := $0B +REFP1 := $0C +PF0 := $0D +PF1 := $0E +PF2 := $0F +RESP0 := $10 +RESP1 := $11 +RESM0 := $12 +RESM1 := $13 +RESBL := $14 +AUDC0 := $15 +AUDC1 := $16 +AUDF0 := $17 +AUDF1 := $18 +AUDV0 := $19 +AUDV1 := $1A +GRP0 := $1B +GRP1 := $1C +ENAM0 := $1D +ENAM1 := $1E +ENABL := $1F +HMP0 := $20 +HMP1 := $21 +HMM0 := $22 +HMM1 := $23 +HMBL := $24 +VDELP0 := $25 +VDELP1 := $26 +VDELBL := $27 +RESMP0 := $28 +RESMP1 := $29 +HMOVE := $2A +HMCLR := $2B +CXCLR := $2C + +; Write registers +CXM0P := $00 +CXM1P := $01 +CXP0FB := $02 +CXP1FB := $03 +CXM0FB := $04 +CXM1FB := $05 +CXBLPF := $06 +CXPPMM := $07 +INPT0 := $08 +INPT1 := $09 +INPT2 := $0A +INPT3 := $0B +INPT4 := $0C +INPT5 := $0D diff --git a/asminc/atari_antic.inc b/asminc/atari_antic.inc index a4557c7b4..9a097e05a 100644 --- a/asminc/atari_antic.inc +++ b/asminc/atari_antic.inc @@ -76,13 +76,13 @@ DL_CHR20x8x2 = 6 ; colour (duochrome per character), 20 character DL_CHR20x16x2 = 7 ; colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) DL_MAP40x8x4 = 8 ; colour, 40 pixel & 8 scanlines per mode line (GR. 3) -DL_MAP80x4x2 = 9 ; 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) -DL_MAP80x4x4 = 10 ; colour, 80 pixel & 4 scanlines per mode line (GR.5) -DL_MAP160x2x2 = 11 ; 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) -DL_MAP160x1x2 = 12 ; 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) -DL_MAP160x2x4 = 13 ; 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) -DL_MAP160x1x4 = 14 ; 4 colours, 160 pixel & 1 scanline per mode line (GR.15) -DL_MAP320x1x1 = 15 ; monochrome, 320 pixel & 1 scanline per mode line (GR.8) +DL_MAP80x4x2 = 9 ; 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) +DL_MAP80x4x4 = 10 ; colour, 80 pixel & 4 scanlines per mode line (GR.5) +DL_MAP160x2x2 = 11 ; 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) +DL_MAP160x1x2 = 12 ; 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) +DL_MAP160x2x4 = 13 ; 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) +DL_MAP160x1x4 = 14 ; 4 colours, 160 pixel & 1 scanline per mode line (GR.15) +DL_MAP320x1x1 = 15 ; monochrome, 320 pixel & 1 scanline per mode line (GR.8) ; modifiers on mode lines... diff --git a/asminc/em-kernel.inc b/asminc/em-kernel.inc index 889ffba98..9e89b6f4e 100644 --- a/asminc/em-kernel.inc +++ b/asminc/em-kernel.inc @@ -75,7 +75,7 @@ EMD_API_VERSION = $02 ;------------------------------------------------------------------------------ ; Driver entry points - + .global emd_install .global emd_uninstall .global emd_pagecount diff --git a/asminc/errno.inc b/asminc/errno.inc index 6e5cce42b..1efe88cda 100644 --- a/asminc/errno.inc +++ b/asminc/errno.inc @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 16.05.2000 ; diff --git a/asminc/lynx.inc b/asminc/lynx.inc index 81a60bf2e..403d15d07 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -135,35 +135,35 @@ STIMCTLB = $FD1F TIM0BKUP = $FD00 TIM0CTLA = $FD01 TIM0CNT = $FD02 -TIM0CTLB = $FD03 +TIM0CTLB = $FD03 TIM1BKUP = $FD04 TIM1CTLA = $FD05 TIM1CNT = $FD06 -TIM1CTLB = $FD07 +TIM1CTLB = $FD07 TIM2BKUP = $FD08 TIM2CTLA = $FD09 TIM2CNT = $FD0A -TIM2CTLB = $FD0B +TIM2CTLB = $FD0B TIM3BKUP = $FD0C TIM3CTLA = $FD0D TIM3CNT = $FD0E -TIM3CTLB = $FD0F +TIM3CTLB = $FD0F TIM4BKUP = $FD10 TIM4CTLA = $FD11 TIM4CNT = $FD12 -TIM4CTLB = $FD13 +TIM4CTLB = $FD13 TIM5BKUP = $FD14 TIM5CTLA = $FD15 TIM5CNT = $FD16 -TIM5CTLB = $FD17 +TIM5CTLB = $FD17 TIM6BKUP = $FD18 TIM6CTLA = $FD19 TIM6CNT = $FD1A -TIM6CTLB = $FD1B +TIM6CTLB = $FD1B TIM7BKUP = $FD1C TIM7CTLA = $FD1D TIM7CNT = $FD1E -TIM7CTLB = $FD1F +TIM7CTLB = $FD1F ; Mikey Audio diff --git a/asminc/opcodes.inc b/asminc/opcodes.inc index e6b7e73df..b610360e1 100644 --- a/asminc/opcodes.inc +++ b/asminc/opcodes.inc @@ -3,23 +3,23 @@ ; ; Christian Krüger, latest change: 18-Sep-2010 ; -; This software is provided 'as-is', without any expressed or implied -; warranty. In no event will the authors be held liable for any damages -; arising from the use of this software. -; -; Permission is granted to anyone to use this software for any purpose, -; including commercial applications, and to alter it and redistribute it -; freely, subject to the following restrictions: -; -; 1. The origin of this software must not be misrepresented; you must not -; claim that you wrote the original software. If you use this software -; in a product, an acknowledgment in the product documentation would be -; appreciated but is not required. -; 2. Altered source versions must be plainly marked as such, and must not -; be misrepresented as being the original software. -; 3. This notice may not be removed or altered from any source -; distribution. -; +; This software is provided 'as-is', without any expressed or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software +; in a product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; 2. Altered source versions must be plainly marked as such, and must not +; be misrepresented as being the original software. +; 3. This notice may not be removed or altered from any source +; distribution. +; ; Opcode-Table ; ------------ diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 7d4c1e31d..703dbaa3b 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -17,7 +17,7 @@ FNAME_LEN = 11 ; Maximum length of file-name ; --------------------------------------------------------------------------- ; I/O Identifier ; Theses identifers are used for channel management -; +; XKBD = $80 ; Keyboard XRSE = $83 ; RS232 in @@ -87,27 +87,27 @@ HRSFB := $57 VABKP1 := $58 ; RS232T -; b0-b3 : speed +; b0-b3 : speed ; 1111 => 19200 bps (please note that telestrat can't handle this speed without stopping all IRQ except ACIA's one) ; 1100 => 9600 bps (default from TELEMON) -; 1110 => 4800 bps -; 1010 => 2400 bps -; 1000 => 1200 bps -; 0111 => 600 bps -; 0110 => 300 bps -; 0101 => 150 bps -; 0010 => 75 bps +; 1110 => 4800 bps +; 1010 => 2400 bps +; 1000 => 1200 bps +; 0111 => 600 bps +; 0110 => 300 bps +; 0101 => 150 bps +; 0010 => 75 bps ; b4 : 0 external clock, 1 internal clock ; b6-b5 : 00 8 bits ; 01 7 bits ; 10 6 bits ; 11 5 bits -; b7 : 0 a stop +; b7 : 0 a stop RS232T := $59 -; RS232C +; RS232C ; b0-b3 : 0 ; b4 : 1 if echo ; b5 : 1 if parity @@ -218,7 +218,7 @@ SCREEN := $BB80 ; TELEMON primitives (2.4 & 3.x) -; all values are used to call bank 7 of telestrat cardridge. It works with 'brk value' +; all values are used to call bank 7 of telestrat cardridge. It works with 'brk value' XOP0 = $00 ; Open device on channel 0 XOP1 = $01 ; Open device on channel 1 XOP2 = $02 ; Open device on channel 2 @@ -275,14 +275,14 @@ XFWRITE = $3B ; Only in TELEMON 3.x write file (bank 7 of Orix ; Clock primitive XRECLK = $3C ; Reset clock XCLCL = $3D ; Close clock -XWRCLK = $3E ; Displays clock in the adress in A & Y registers +XWRCLK = $3E ; Displays clock in the address in A & Y registers ; Sound primitives XSONPS = $40 ; Send data to PSG register (14 values) XOUPS = $42 ; Send Oups sound into PSG XPLAY = $43 ; Play a sound -XSOUND = $44 -XMUSIC = $45 +XSOUND = $44 +XMUSIC = $45 XZAP = $46 ; Send Zap sound to PSG XSHOOT = $47 @@ -303,13 +303,13 @@ XFWR = $4E ; Put a char on the first screen. Only available ; Keyboard primitives XALLKB = $50 ; Read Keyboard, and populate KBDCOL XKBDAS = $51 ; Ascii conversion -XGOKBD = $52 ; Swap keyboard type (Qwerty, French ...) +XGOKBD = $52 ; Swap keyboard type (Qwerty, French ...) ; Buffer management XECRBU = $54 ; Write A or AY in the buffer XLISBU = $55 ; Read A or AY in the buffer XTSTBU = $56 -XVIDBU = $57 ; Flush the buffer +XVIDBU = $57 ; Flush the buffer XINIBU = $58 ; Initialize the buffer X XDEFBU = $59 ; Reset all value of the buffer XBUSY = $5A ; Test if the buffer is empty @@ -328,7 +328,7 @@ XMSAVE = $61 ; Write a file to Minitel XFREE = $62 ; Only in TELEMON 3.x (bank 7 of Orix) -; Next Minitel primitives +; Next Minitel primitives XWCXFI = $63 ; Wait connection XLIGNE = $64 ; XDECON = $65 ; Minitel disconnection @@ -340,7 +340,7 @@ XHRSSE = $8C ; Set hires position cursor XDRAWA = $8D ; Draw a line absolute XDRAWR = $8E ; Draw a line (relative) XCIRCL = $8F ; Draw a circle -XCURSE = $90 ; Plot a pixel +XCURSE = $90 ; Plot a pixel XCURMO = $91 ; Move to x,y pos in Hires XPAPER = $92 XINK = $93 @@ -358,8 +358,8 @@ XPING = $9D ; Send Ping sound to PSG PWD_PTR = $00 ; --------------------------------------------------------------------------- -; -BUFTRV := $100 +; +BUFTRV := $100 ; --------------------------------------------------------------------------- @@ -377,7 +377,7 @@ TIMES := $211 TIMEM := $212 TIMEH := $213 FLGCLK := $214 -FLGCLK_FLAG := $215 +FLGCLK_FLAG := $215 FLGCUR := $216 ; Cursor management flag ; screens position managements @@ -466,7 +466,7 @@ DESALO := $52D FISALO := $52F EXSALO := $531 EXTDEF := $55D ; Default extension. At the start of telemon, it's set to ".COM" -BUFEDT := $590 ; Buffer edition +BUFEDT := $590 ; Buffer edition MAX_BUFEDT_LENGTH=110 @@ -480,7 +480,7 @@ BUFBUF := $c080 ; --------------------------------------------------------------------------- ; Stratsed vectors -; Stratsed is the main OS for Telestrat +; Stratsed is the main OS for Telestrat XMERGE := $FF0E XFST := $FF11 XSPUT := $FF14 @@ -532,7 +532,7 @@ XPMAP := $FFA7 XRWTS := $FFAA ; --------------------------------------------------------------------------- -; MACRO +; MACRO .macro BRK_TELEMON value .byte $00,value diff --git a/asminc/tgi-vectorfont.inc b/asminc/tgi-vectorfont.inc index ffe6ac686..124fe93cc 100644 --- a/asminc/tgi-vectorfont.inc +++ b/asminc/tgi-vectorfont.inc @@ -54,7 +54,7 @@ TGI_VF_CCOUNT = (TGI_VF_LASTCHAR - TGI_VF_FIRSTCHAR + 1) ; Font data loaded directly from file .struct TGI_VECTORFONT TOP .byte ; Height of char - BOTTOM .byte ; Descender + BOTTOM .byte ; Descender HEIGHT .byte ; Maximum char height WIDTHS .byte ::TGI_VF_CCOUNT ; Char widths CHARS .word ::TGI_VF_CCOUNT ; Pointer to character defs diff --git a/asminc/utsname.inc b/asminc/utsname.inc index 2c7052ce1..6d978dd21 100644 --- a/asminc/utsname.inc +++ b/asminc/utsname.inc @@ -33,7 +33,7 @@ -; Struct utsname +; Struct utsname .struct utsname sysname .byte 17 nodename .byte 9 diff --git a/asminc/zeropage.inc b/asminc/zeropage.inc index 1ba035868..6627d86b6 100644 --- a/asminc/zeropage.inc +++ b/asminc/zeropage.inc @@ -12,7 +12,7 @@ .globalzp ptr1, ptr2, ptr3, ptr4 .globalzp tmp1, tmp2, tmp3, tmp4 .globalzp regbank - + ; The size of the register bank regbanksize = 6 diff --git a/cfg/atari7800.cfg b/cfg/atari7800.cfg new file mode 100644 index 000000000..4d20ab0d9 --- /dev/null +++ b/cfg/atari7800.cfg @@ -0,0 +1,67 @@ +# Atari VCS 7800 linker configuration file for cc65 +# In order to add the a78 header to the build you can add +# "--force-import __EXEHDR__" to the command line + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0600; # C stack + __CARTSIZE__: type = weak, value = $8000; + __VEC_BOTTOM__: value = $fffa, type = export; + __VEC_SIZE__: value = $6, type = export; + __ENCRYPT_BOTTOM__: value = $ff7a, type = export; + __ENCRYPT_SIZE__: value = $80, type = export; + __MEMORY_TOP__: value = __ENCRYPT_BOTTOM__, type = export; + __INIT_SIZE__: value = 121, type = export; + __MEMORY_INIT__: value = __MEMORY_TOP__ - __INIT_SIZE__, type = export; + __MEMORY_BOTTOM__: value = $10000 - __CARTSIZE__, type = weak; + __FREE_ROM_SIZE__: value = __MEMORY_INIT__ - __MEMORY_BOTTOM__, type = export; +} + +MEMORY { + ZP: file = "", define = yes, start = $0040, size = $00C0, type = rw; + SP: file = "", define = yes, start = $0140, size = $00C0, type = rw; + RAM1: file = "", define = yes, start = $1800, size = $0840, type = rw; + RAM2: file = "", define = yes, start = $2100, size = $0040, type = rw; + RAM3: file = "", define = yes, start = $2200, size = $0600, type = rw; + # For emulators you also need a header file + HEADER: file = %O, start = $0000, size = 128; + # "Normal" cartridge rom. Multiple banks arent supported + # by this script. You may change the rom size, but keep + # two things in mind: + # - start must be a multiple of $1000 + # - ROM must end at $ff79 + ROM: file = %O, define = yes, start = __MEMORY_BOTTOM__, size = __FREE_ROM_SIZE__, type = ro, fill = yes, fillval = $ff; + ROMS: file = %O, define = yes, start = __MEMORY_INIT__, size = __INIT_SIZE__, type = ro, fill = yes, fillval = $ff; + # Encryption stuff + ROME: file = %O, start = __ENCRYPT_BOTTOM__, size = __ENCRYPT_SIZE__, type = ro, fill = yes, fillval = $ff; + # Interrupt vectors + ROMV: file = %O, start = __VEC_BOTTOM__, size = __VEC_SIZE__, type = ro, fill = yes, fillval = $ff; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; + STARTUP: load = ROMS, type = ro, define = yes; + ONCE: load = ROMS, type = ro, define = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, define = yes, align = 256; + DATA: load = ROM, run = RAM1, type = rw, define = yes; + BSS: load = RAM1, type = bss, define = yes; + VECTORS: load = ROMV, type = ro, define = yes; + ENCRYPTION: load = ROME, type = ro define = yes; +} + +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg index ad0d760f3..7949375d3 100644 --- a/cfg/sym1-32k.cfg +++ b/cfg/sym1-32k.cfg @@ -29,7 +29,7 @@ MEMORY { EXT: file = "", define = yes, start = $9000, size = $1000; IO: file = "", define = yes, start = $A000, size = $1000; RAE1: file = "", define = yes, start = $B000, size = $1000; - BASROM: file = "", define = yes, start = $C000, size = $1000; + BASROM: file = "", define = yes, start = $C000, size = $2000; RAE2: file = "", define = yes, start = $E000, size = $1000; TOP: file = "", define = yes, start = $F000, size = $1000; } diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg index 32d3cbb3a..468a76fe0 100644 --- a/cfg/sym1-4k.cfg +++ b/cfg/sym1-4k.cfg @@ -29,7 +29,7 @@ MEMORY { EXT: file = "", define = yes, start = $9000, size = $1000; IO: file = "", define = yes, start = $A000, size = $1000; RAE1: file = "", define = yes, start = $B000, size = $1000; - BASROM: file = "", define = yes, start = $C000, size = $1000; + BASROM: file = "", define = yes, start = $C000, size = $2000; RAE2: file = "", define = yes, start = $E000, size = $1000; TOP: file = "", define = yes, start = $F000, size = $1000; } diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg index 32d3cbb3a..468a76fe0 100644 --- a/cfg/sym1.cfg +++ b/cfg/sym1.cfg @@ -29,7 +29,7 @@ MEMORY { EXT: file = "", define = yes, start = $9000, size = $1000; IO: file = "", define = yes, start = $A000, size = $1000; RAE1: file = "", define = yes, start = $B000, size = $1000; - BASROM: file = "", define = yes, start = $C000, size = $1000; + BASROM: file = "", define = yes, start = $C000, size = $2000; RAE2: file = "", define = yes, start = $E000, size = $1000; TOP: file = "", define = yes, start = $F000, size = $1000; } diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 09052ade1..63b40c6f8 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -370,7 +370,7 @@ The names in the parentheses denote the symbols to be used for static linking of In memory constrained situations the memory from $803 to $1FFF can be made available to a program by calling

diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index a105cb47a..15ceed04f 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -376,7 +376,7 @@ The names in the parentheses denote the symbols to be used for static linking of In memory constrained situations the memory from $803 to $1FFF can be made available to a program by calling

diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index 599ffe3c9..29e6aadb3 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -84,7 +84,7 @@ The names are the usual ones you can find in system reference manuals. Example: tics = OS.rtclok[1] // get ticks ... - + Atari 5200 specific functions

@@ -221,7 +221,7 @@ you cannot use any of the following functions (and a few others): CAR format

-AtariROMMaker ( ) +AtariROMMaker ( ) can be used to create a + +

+Atari 7800 specific information for cc65 +<author> +<url url="mailto:karri@sipo.fi" name="Karri Kaksonen"><newline> + +<abstract> +An overview over the Atari 7800 runtime system as it is implemented +for the cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Atari 7800 runtime system as it +comes with the cc65 C compiler. It describes the memory layout, Atari +7800 specific header files and any pitfalls specific to that platform. + +<sect>Binary format<p> + +The default binary output format generated by the linker for the Atari +7800 target is a 48K cartridge image. + +<sect>A78 header<p> + +There is lots of different cart hardware available for the atari7800. +Some carts have ROM, RAM, sound hardware, non-volatile high score chips. +In order to know what kind of hardware the cart build requires there is +a header file of 128 bytes in front of the binary. + +The default build creates a cart file for a 48K rom cart without any +extra features like the pokey audio chip or extra RAM. + +In order to make cc65 more user friendly the build will add the a78 +header automatically. This allows you to run the binary on emulators +and flash carts on the real console. + +<sect>Encryption<p> + +In order to boot the game in a mode that supports atari7800 functions +the cart must be encrypted after the linking phase. +There is a program called sign7800 that can be used to sign the cart. +The encryption is not required for running the cart on emulators. +You can also run atari2600 games without encryption. + +<sect>Memory layout<p> + +cc65 generated programs with the default setup can use RAM from +from $1800 to $203f. +The 4k RAM is then mapped to zero page area. +$2040 to $20ff is visible as zero page. +After that we have a vero small RAM area that is unused. +$2100 to $213f. +Then we mirror a second block from the RAM to become the hardware stack. +This would be from $2140 to $21ff. + +The C-stack starts at $2800 and it can grow down to $2200. + +size of the system stack can be customized by defining the +__STACKSIZE__ linker variable. + +Special locations: + +<descrip> + <tag/Stack/ The C runtime stack is located at $2800 - + __STACKSIZE__ and growing downwards. + + <tag/Heap/ The C heap is located at $2200 and grows upwards. + +</descrip><p> + +<sect>Start-up condition<p> + +When powered-up, the Atari 7800 TIA registers contain random +values. During the initialization phase, the start-up code needs to +initialize the TIA registers to sound values (or else the console has +an unpredictable behavior). In this implementation, zeros are written +to all of TIA registers during the start-up phase. + +Note that RIOT registers (mostly timers) are left uninitialized, as +they don't have any consequence on the console behavior. + +<sect>Platform specific header files<p> + +Programs containing Atari 7800 specific code may use the +<tt/atari7800.h/ header file. + +The following pseudo variables declared in the <tt/atari7800.h/ header +file allow access to the Atari 7800 TIA, MARIA & RIOT chips registers. + +<descrip> + + <tag><tt/TIA/</tag> The <tt/TIA/ structure allows read/write access + to the Atari 7800 TIA chip registers. See the <tt/_tia.h/ header + file located in the include directory for the declaration of the + structure. Also refer to the Stella Programmer's Guide by Steve + Wright for a detailed description of the chip and its registers. + + <tag><tt/RIOT/</tag> The <tt/RIOT/ structure allows read/write + access to the Atari 7800 RIOT chip registers. See the + <tt/_riot.h/ header file located in the include directory for the + declaration of the structure. Also refer to the Stella Programmer's + Guide by Steve Wright for a detailed description of the chip and its + registers. + + <tag><tt/MARIA/</tag> The <tt/MARIA/ structure allows read/write + access to the Atari 7800 MARIA chip registers. See the + <tt/_maria.h/ header file located in the include directory for the + declaration of the structure. + +</descrip><p> + + +<sect>Loadable drivers<p> + +There are no drivers for the Atari 7800. + + +<sect>Limitations<p> + +TBD + + +<sect>Other hints<p> + +One may write a custom linker configuration file to tune the memory +layout of a program. See the <tt/atari7800.cfg/ file in the cfg +directory as a starting point. + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/doc/c64.sgml b/doc/c64.sgml index de37ed4b7..8c1b3754e 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -126,7 +126,7 @@ and $FF3F. In memory constrained situations the memory from $400 to $7FF can be made available to a program by calling <tt/_heapadd ((void *) 0x0400, 0x0400);/ at the beginning of <tt/main()/. Doing so is beneficial even if the program -doesn't use the the heap explicitly because loading a driver uses the heap implicitly. +doesn't use the heap explicitly because loading a driver uses the heap implicitly. Using <tt/c64-soft80.o/ is as simple as placing it on the linker command line like this: diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 309fbf28d..19fd3aa2a 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3108,7 +3108,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH <sect1><tt>.IFDEF</tt><label id=".IFDEF"><p> Conditional assembly: Check if a symbol is defined. Must be followed by - a symbol name. The condition is true if the the given symbol is already + a symbol name. The condition is true if the given symbol is already defined, and false otherwise. See also: <tt><ref id=".DEFINED" name=".DEFINED"></tt> @@ -3143,7 +3143,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH <sect1><tt>.IFNDEF</tt><label id=".IFNDEF"><p> Conditional assembly: Check if a symbol is defined. Must be followed by - a symbol name. The condition is true if the the given symbol is not + a symbol name. The condition is true if the given symbol is not defined, and false otherwise. See also: <tt><ref id=".DEFINED" name=".DEFINED"></tt> @@ -3152,7 +3152,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH <sect1><tt>.IFNREF</tt><label id=".IFNREF"><p> Conditional assembly: Check if a symbol is referenced. Must be followed - by a symbol name. The condition is true if if the the given symbol was + by a symbol name. The condition is true if the given symbol was not referenced before, and false otherwise. See also: <tt><ref id=".REFERENCED" name=".REFERENCED"></tt> @@ -3197,7 +3197,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH <sect1><tt>.IFREF</tt><label id=".IFREF"><p> Conditional assembly: Check if a symbol is referenced. Must be followed - by a symbol name. The condition is true if if the the given symbol was + by a symbol name. The condition is true if the given symbol was referenced before, and false otherwise. This command may be used to build subroutine libraries in include files @@ -3622,7 +3622,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE" <sect1><tt>.PDTV</tt><label id=".PDTV"><p> - Enable the 6502DTV instruction set. This is a superset of the 6502 + Enable the 6502DTV instruction set. This is a superset of the 6502 instruction set. See: <tt><ref id=".P02" name=".P02"></tt> @@ -4763,6 +4763,7 @@ compiler, depending on the target system selected: <item><tt/__APPLE2ENH__/ - Target system is <tt/apple2enh/ <item><tt/__ATARI2600__/ - Target system is <tt/atari2600/ <item><tt/__ATARI5200__/ - Target system is <tt/atari5200/ +<item><tt/__ATARI7800__/ - Target system is <tt/atari7800/ <item><tt/__ATARI__/ - Target system is <tt/atari/ or <tt/atarixl/ <item><tt/__ATARIXL__/ - Target system is <tt/atarixl/ <item><tt/__ATMOS__/ - Target system is <tt/atmos/ diff --git a/doc/cc65.sgml b/doc/cc65.sgml index df58a0a95..67323931c 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -198,6 +198,189 @@ Here is a description of all the command line options: Enables debug mode, for debugging the behavior of cc65. + <tag><tt>--debug-tables name</tt></tag> + + Writes symbol table information to a file, which includes details on structs, unions + functions, and global variables. For example, given the following code: + + <tscreen><verb> + struct l { + unsigned char m; + unsigned char n; + }; + + struct hello { + unsigned char j; + unsigned char k; + struct l l; + }; + + struct sub { + unsigned char x; + unsigned char y; + }; + + union xy { + struct sub xy; + unsigned int mem; + }; + + typedef struct hello thingy; + + unsigned char single; + + unsigned char test_local_vars_main(void) { + static unsigned char wahoo; + static unsigned char bonanza = 0x42; + unsigned char i; + unsigned int j; + unsigned int *random; + unsigned char *lol; + signed char whoa; + struct hello wow; + thingy *cool; + union xy xy; + + return 0; + } + </verb></tscreen> + + The following output would be produced: + + <tscreen><verb> + SC_FUNC: _test_local_vars_main: Symbol table + ============================================ + __fixargs__: + Flags: SC_CONST SC_DEF + Type: unsigned int + __argsize__: + Flags: SC_CONST SC_DEF + Type: unsigned char + wahoo: + AsmName: M0001 + Flags: SC_STATIC SC_DEF SC_REF + Type: unsigned char + bonanza: + AsmName: M0002 + Flags: SC_STATIC SC_DEF SC_REF + Type: unsigned char + i: + Flags: SC_AUTO SC_DEF SC_REF + Type: unsigned char + j: + Flags: SC_AUTO SC_DEF SC_REF + Type: unsigned int + random: + Flags: SC_AUTO SC_DEF SC_REF + Type: unsigned int * + lol: + Flags: SC_AUTO SC_DEF SC_REF + Type: unsigned char * + whoa: + Flags: SC_AUTO SC_DEF SC_REF + Type: signed char + wow: + Flags: SC_AUTO SC_DEF SC_REF + Type: struct hello + cool: + Flags: SC_AUTO SC_DEF SC_REF + Type: struct hello * + xy: + Flags: SC_AUTO SC_DEF SC_REF + Type: union xy + + + + + Global symbol table + =================== + thingy: + AsmName: _thingy + Flags: SC_TYPEDEF 0x100000 + Type: struct hello + single: + AsmName: _single + Flags: SC_STATIC SC_EXTERN SC_STORAGE SC_DEF SC_REF 0x100000 + Type: unsigned char + test_local_vars_main: + AsmName: _test_local_vars_main + Flags: SC_FUNC SC_STATIC SC_EXTERN SC_DEF 0x100000 + Type: unsigned char (void) + + + + + Global tag table + ================ + l: + Flags: SC_STRUCT SC_DEF + Type: (none) + hello: + Flags: SC_STRUCT SC_DEF + Type: (none) + sub: + Flags: SC_STRUCT SC_DEF + Type: (none) + xy: + Flags: SC_UNION SC_DEF + Type: (none) + + + + + Global struct and union definitions + ========================= + + SC_STRUCT: l + ============ + m: + Flags: SC_STRUCTFIELD + Type: unsigned char + n: + Flags: SC_STRUCTFIELD + Type: unsigned char + + + + + SC_STRUCT: hello + ================ + j: + Flags: SC_STRUCTFIELD + Type: unsigned char + k: + Flags: SC_STRUCTFIELD + Type: unsigned char + l: + Flags: SC_STRUCTFIELD + Type: struct l + + + + + SC_STRUCT: sub + ============== + x: + Flags: SC_STRUCTFIELD + Type: unsigned char + y: + Flags: SC_STRUCTFIELD + Type: unsigned char + + + + + SC_UNION: xy + ============ + xy: + Flags: SC_STRUCTFIELD + Type: struct sub + mem: + Flags: SC_STRUCTFIELD + Type: unsigned int + </verb></tscreen> + + <tag><tt>--debug-opt name</tt></tag> The named file contains a list of specific optimization steps to enable or disable. diff --git a/doc/da65.sgml b/doc/da65.sgml index 1702694a0..bf074a667 100644 --- a/doc/da65.sgml +++ b/doc/da65.sgml @@ -119,9 +119,9 @@ Here is a description of all the command line options: <item>4510 </itemize> - 6502x is for the NMOS 6502 with unofficial opcodes. 6502dtv is for the - emulated CPU of the C64DTV device. huc6280 is the CPU of the PC engine. - 4510 is the CPU of the Commodore C65. Support for the 65816 currently + 6502x is for the NMOS 6502 with unofficial opcodes. 6502dtv is for the + emulated CPU of the C64DTV device. huc6280 is the CPU of the PC engine. + 4510 is the CPU of the Commodore C65. Support for the 65816 currently is not available. @@ -253,8 +253,8 @@ for this CPU. Invalid opcodes are translated into <tt/.byte/ commands. With the command line option <tt><ref id="option--cpu" name="--cpu"></tt>, the disassembler may be told to recognize either the 65SC02 or 65C02 CPUs. The latter understands the same opcodes as the former, plus 16 additional bit -manipulation and bit test-and-branch commands. Using 6502x as CPU the illegal -opcodes of 6502 CPU are detected and displayed. 6502dtv setting recognizes the +manipulation and bit test-and-branch commands. Using 6502x as CPU the illegal +opcodes of 6502 CPU are detected and displayed. 6502dtv setting recognizes the emulated CPU instructons of the C64DTV device. diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 1a9dcaa77..a8593ebb5 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -6127,7 +6127,7 @@ pointer you're passing somewhere else, otherwise <tscreen><verb> ptr = realloc (ptr, size); </verb></tscreen> -will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/. +will lose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/. <item>The function is only available as fastcall function, so it may only be used in presence of a prototype. </itemize> diff --git a/doc/geos.sgml b/doc/geos.sgml index c3601e741..8a43d134b 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -1332,7 +1332,7 @@ This function returns the GEOS Kernal version combined (by logical OR) with the <p> This function returns the PAL/NTSC flag combined (by logical OR) with the 40/80 columns flag. This is not the best way to check if the screen has 40 or 80 columns since a PAL/NTSC check is always -performed and it can take as long as a full raster frame. If you just want to know if the +performed and it can take as long as a full raster frame. If you just want to know if the screen has 40 or 80 columns use the expression <tt/graphMode & 0x80/ which returns <tt/0/ for 40 columns and <tt/0x80/ for 80 columns. Remember that this value can be changed during runtime. It is unclear if this will work for GEOS 64 so you probably do not want to test diff --git a/doc/index.sgml b/doc/index.sgml index 3bb085bf6..bb3ad5357 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -124,6 +124,9 @@ <tag><htmlurl url="atari5200.html" name="atari5200.html"></tag> Topics specific to the Atari 5200 Game Console. + <tag><htmlurl url="atari7800.html" name="atari7800.html"></tag> + Topics specific to the Atari 7800 Game Console. + <tag><htmlurl url="atmos.html" name="atmos.html"></tag> Topics specific to the Oric Atmos. diff --git a/doc/intro.sgml b/doc/intro.sgml index 5d1889d76..1eebe24c4 100644 --- a/doc/intro.sgml +++ b/doc/intro.sgml @@ -410,7 +410,7 @@ Available at <url url="https://github.com/commanderx16/x16-emulator/releases">: Emulates the Commander X16 Single Board Computer, with sound, SD card images, -VGA and NTSC video, and a NES game controller emulation. Includes a monitor. +VGA and NTSC video, and a NES game controller emulation. Includes a monitor. It runs on all SDL2 platforms. Compile the tutorial with @@ -459,7 +459,7 @@ Substitute the name of a Commodore computer for that <tt/<sys>/: Start the desired version of the emulator (CBM610 programs run on the CBM II [<tt/xcbm2/] emulator). -Choose <bf>File>Autostart disk/tape image...</bf>, choose your executable, +Choose <bf>File>Autostart disk/tape image...</bf>, choose your executable, and click <bf/OK/. The file has a 14-byte header which corresponds to a PRG-format BASIC program, @@ -500,7 +500,7 @@ prompt. Before you can run the cartridge image produced by the linker, the binary has to be patched using the <bf/gamate-fixcart/ tool that is included in the cc65 -package in the util/gamata directory. +package in the util/gamate/ directory. <tscreen><verb> gamate-fixcart <image.bin> diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 87c2cae51..307caeaa4 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -166,6 +166,7 @@ Here is a description of all of the command-line options: <item>apple2 <item>apple2enh <item>atari2600 + <item>atari7800 <item>atari <item>atarixl <item>atmos diff --git a/doc/lynx.sgml b/doc/lynx.sgml index 0eef70535..76cfb377c 100644 --- a/doc/lynx.sgml +++ b/doc/lynx.sgml @@ -36,7 +36,7 @@ Here is a small traditional Hello World program for the Atari Lynx. <tscreen><verb> #include <lynx.h> #include <tgi.h> -#include <6502.h> +#include <6502.h> void main(void) { tgi_install(tgi_static_stddrv); diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 075d95849..310de4667 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -112,7 +112,7 @@ For a C test compiled and linked with <tt/--target sim6502/ the command line arguments to <tt/sim65/ will be passed to <tt/main/, and the return value from <tt/main/ will become sim65's exit code. The <tt/exit/ function may also be used to terminate with an exit code. - + Exit codes are limited to 8 bits. The standard C library high level file input and output is functional. diff --git a/doc/sym1.sgml b/doc/sym1.sgml index 5961984bd..0d4cc8a20 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -15,21 +15,40 @@ An overview over the Sym-1 runtime system as it is implemented for the cc65 C co <sect>Overview<p> -This file contains an overview of the Sym-1 runtime system as it comes with the cc65 C compiler. It describes the memory layout, Sym-1 specific header files, available drivers, and any pitfalls specific to the platform. +This file contains an overview of the Sym-1 runtime system as it comes with the cc65 C compiler. +It describes the memory layout, Sym-1 specific header files, available drivers, and any pitfalls +specific to the platform. -Please note that Sym-1 specific functions are just mentioned here, they are described in detail in the separate <url url="funcref.html" name="function reference">. Even functions marked as "platform dependent" may be available on more than one platform. Please see the function reference for more information. +Please note that Sym-1 specific functions are just mentioned here, they are described in detail +in the separate <url url="funcref.html" name="function reference">. Even functions marked as +"platform dependent" may be available on more than one platform. Please see the +function reference for more information. <sect>Binary format<p> -The output format generated by the linker for the Sym-1 target is a raw binary BIN file, which is essentially a memory image. You can convert this to a HEX file using BIN2HEX, which is a popular open-source conversion utility program. A HEX file has ASCII representations of the hexadecimal byte values of the machine-language program. So the HEX file can be transferred to the Sym-1 using the RS-232 terminal port, just as if the machine-code was entered by hand. Enter 'm 200' in the monitor and start the HEX file transfer. +The output format generated by the linker for the Sym-1 target is a raw binary BIN file, which +is essentially a memory image. You can convert this to a HEX file using BIN2HEX, which is a +popular open-source conversion utility program. A HEX file has ASCII representations of the +hexadecimal byte values of the machine-language program. So the HEX file can be transferred +to the Sym-1 using the RS-232 terminal port, just as if the machine-code was entered by hand. +Enter 'm 200' in the monitor and start the HEX file transfer. <p> -Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 on-board memory is limited to 4 kbytes but system memory can be increased to 32 kbytes of contiguous RAM with aftermarket add-on boards. So choose the config file that matches your system configuration before compiling and linking user programs. +Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 +on-board memory is limited to 4 kbytes but system memory can be increased to 32 kbytes of +contiguous RAM with aftermarket add-on boards. So choose the config file that matches your +system configuration before compiling and linking user programs. <sect>Memory layout<p> -The ROMs and I/O areas are defined in the configuration files, as are most of the entry points for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked using 4k config run in the memory range of $200 - $0FFF. The 32k config expands this range to $7FFF. The starting memory location and entry point for running the program is $200, so when the program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control back to the monitor ROM when the program terminates, providing the '.' prompt. +The ROMs and I/O areas are defined in the configuration files, as are most of the entry points +for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked +using 4k config run in the memory range of $200 - $0FFF. The 32k config expands +this range to $7FFF. Memory above 32k can be used to extend the heap, as described below. +The starting memory location and entry point for running the program is $200, so when the +program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control +back to the monitor ROM when the program terminates, providing the '.' prompt. Special locations: @@ -38,10 +57,12 @@ Special locations: Conio support is not currently available for the Sym-1. But stdio console functions are available. <tag/Stack/ - The C runtime stack is located at $0FFF on 4KB Syms, or at $7FFF for 32KB systems. The stack always grows downwards. + The C runtime stack is located at $0FFF on 4kb Syms, or at $7FFF for 32kb systems. + The stack always grows downwards. <tag/Heap/ - The C heap is located at the end of the program and grows towards the C runtime stack. + The C heap is located at the end of the program and grows towards the C runtime stack. Extended + memory can be added to the heap, as described below. </descrip><p> @@ -51,7 +72,8 @@ Programs containing Sym-1 code may use the <tt/sym1.h/ header file. See the hea <sect1>Hardware access<p> -The pseudo variables declared in the <tt/sym1.inc/ include file allow access to hardware located in the address space. See the include file for more information. +The pseudo variables declared in the <tt/sym1.inc/ include file allow access to hardware located in the +address space. See the include file for more information. <sect>Loadable drivers<p> @@ -61,7 +83,9 @@ No graphics drivers are currently available for the Sym-1. <sect1>Extended memory drivers<p> -No extended memory drivers are currently available for the Sym-1. +There are no extended memory drivers for the Sym-1. However, there is a way to access memory beyond the +32kb boundary, if extended memory is physically present in the system. See the example program, +symExtendedMemory, in the samples directory. <sect1>Joystick drivers<p> @@ -73,7 +97,8 @@ No mouse drivers are currently available for the Sym-1. <sect1>RS232 device drivers<p> -No communication port drivers are currently available for the Sym-1. It has only the "master console" e.g. stdin and stdout. +No communication port drivers are currently available for the Sym-1. It has only the "master console" +e.g. stdin and stdout. <sect>Limitations<p> @@ -94,29 +119,45 @@ To be more specific, this limitation means that you cannot use any of the follow <sect>Other hints<p> <sect1>sym1.h<p> -This header exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. See the <tt/sym1.h/ include file for a list of the functions available. +This header exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. +See the <tt/sym1.h/ include file for a list of the functions available. <sect2>Limited memory applications<p> -As stated earlier, there are config files for 4KB and 32KB systems. If you have 32KB RAM, then you will probably want to use the sym1-32k configuration, but if not - if you are using the sym1-4k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf. Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers. +As stated earlier, there are config files for 4kb and 32kb systems. If you have 32kb RAM, then you will probably +want to use the sym1-32k configuration, but if not - if you are using the sym1-4k configuration - then you may +want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf. +Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers. -<sect3>Sample programs<p> +<sect3>Using extended memory<p> -All the samples will run on the "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the samples/sym1 directory: +Memory may be physically present that is addressed at locations above the monitor ROM at $8000. This extended +memory is accessible by adding to the heap, as described in the symExtendedMemory sample program. + +<sect4>Sample programs<p> + +All the samples will run on the "stock" 4kb Sym-1, except for symIO and symNotepad, which require 32kb. +Additionally, symExtendedMemory shows how to access memory above 32kb, so it expects more than 32kb. +These sample programs can be found in the samples/sym1 directory: <itemize> -<item>symHello prints "Hello World!" and then inputs characters, which are echoed on the screen. It also makes a "beep" sound.</item> -<item>symTiny does the same as symHello, but does it with puts() rather than printf() to show the difference in compiled binary size.</item> +<item>symHello prints "Hello World!" and then inputs characters, which are echoed on the screen. + It also makes a "beep" sound.</item> +<item>symTiny does the same as symHello, but does it with puts() rather than printf() to show the difference + in compiled binary size.</item> <item>symDisplay allows entry of a message, which is then displayed by scrolling it across the front panel display.</item> <item>symIO allows access to the Sym-1 digital I/O ports.</item> <item>symNotepad is a simple text entry/retrieval program that uses tape storage.</item> +<item>symExtendedMemory demonstrates how to access upper-memory and add it to the heap.</item> </itemize> <sect>License<p> -This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. +This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held +liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter +it and redistribute it freely, subject to the following restrictions: <enum> <item> The origin of this software must not be misrepresented; you must not diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index 385bd69f9..e12846091 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -192,9 +192,9 @@ port cardridge. Telemon 2.4 returns in keyboard buffer the direction of the joysticks. This means that if you get input from keyboard by conio cgetc function, you will get direction from joysticks. -Anyway, if you don't want to use ROM, you can use joysticks standard drivers in your code. +Anyway, if you don't want to use ROM, you can use joysticks standard drivers in your code. -The standard driver manages two joysticks. Only one button is managed for these joysticks. +The standard driver manages two joysticks. Only one button is managed for these joysticks. Telestrat can handle one button for the left port, and three buttons for the right port (but this port was designed for a mouse). @@ -217,7 +217,7 @@ RS232 port with Telemon calls (see XSOUT primitive for example) Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which -handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, +handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). <itemize> @@ -227,10 +227,10 @@ Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). </itemize> <sect1>conio<p> -Functions textcolor and bgcolor are available only with Telemon 3.0 (Orix). -Telemon 2.4 primitives can't handle any change of colors in text mode except with XINK or -XPAPER primitives which put on the first and second columns ink and paper attributes. -The only way to change color on the same line for text is to handle it in pure assembly +Functions textcolor and bgcolor are available only with Telemon 3.0 (Orix). +Telemon 2.4 primitives can't handle any change of colors in text mode except with XINK or +XPAPER primitives which put on the first and second columns ink and paper attributes. +The only way to change color on the same line for text is to handle it in pure assembly without systems calls. <sect>Other hints<p> diff --git a/doc/using-make.sgml b/doc/using-make.sgml index e324b7484..9898e9626 100644 --- a/doc/using-make.sgml +++ b/doc/using-make.sgml @@ -76,13 +76,13 @@ ifneq ($(MAKECMDGOALS),clean) endif %.o: %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< $(PROGRAM): $(SOURCES:.c=.o) - $(CC) $(LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ clean: - $(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map + $(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map </verb></tscreen> <bf/Important:/ When using the sample Makefile above via copy & paste it is diff --git a/include/_antic.h b/include/_antic.h index 717f7f820..742237332 100644 --- a/include/_antic.h +++ b/include/_antic.h @@ -137,7 +137,7 @@ struct __antic { ** Called during every vertical blank; see SYSVBV, VVBLKI, CRITIC, and VVBLKD, ** as well as the SETVBV routine. */ -#define NMIEN_VBI 0x40 +#define NMIEN_VBI 0x40 /* [Reset] key pressed */ #define NMIEN_RESET 0x20 diff --git a/include/_atari5200os.h b/include/_atari5200os.h index db0f7f0c9..5bba43016 100644 --- a/include/_atari5200os.h +++ b/include/_atari5200os.h @@ -31,19 +31,19 @@ struct __os { /*Page zero*/ - unsigned char pokmsk; // = $00 System mask for POKEY IRQ enable + unsigned char pokmsk; // = $00 System mask for POKEY IRQ enable unsigned char rtclok[2]; // = $01,$02 Real time clock - unsigned char critic; // = $03 Critical section flag + unsigned char critic; // = $03 Critical section flag unsigned char atract; // = $04 Attract mode counter - + union { struct { unsigned char sdlstl; // = $05 Save display list LO unsigned char sdlsth; // = $06 Save display list HI }; void* sdlst; // = $05,$06 Display list shadow - }; - + }; + unsigned char sdmctl; // = $07 DMACTL shadow unsigned char pcolr0; // = $08 PM color 0 unsigned char pcolr1; // = $09 PM color 1 @@ -55,10 +55,10 @@ struct __os { unsigned char color3; // = $0F PF color 3 unsigned char color4; // = $10 PF color 4 unsigned char _free_1[0xEF]; // = $11-$FF User space - + /*Stack*/ unsigned char stack[0x100]; // = $100-$1FF Stack - + /*Page 2 OS variables*/ void (*vinter)(void); // = $200 Immediate IRQ vector void (*vvblki)(void); // = $202 Immediate VBI vector @@ -74,7 +74,7 @@ struct __os { void (*vtimr1)(void); // = $216 POKEY timer 1 IRQ vector void (*vtimr2)(void); // = $218 POKEY timer 2 IRQ vector void (*vtimr4)(void); // = $21A POKEY timer 4 IRQ vector - + }; #endif diff --git a/include/_atarios.h b/include/_atarios.h index 5e1374fa5..ec33b98c9 100644 --- a/include/_atarios.h +++ b/include/_atarios.h @@ -66,7 +66,7 @@ struct __dcb { unsigned char dtimlo; /* device timeout in seconds */ unsigned char dunuse; /* - unused - */ unsigned int dbyt; /* # of bytes to transfer */ - union { + union { struct { unsigned char daux1; /* 1st command auxiliary byte */ unsigned char daux2; /* 2nd command auxiliary byte */ @@ -105,7 +105,7 @@ struct __dos2x { unsigned char* zbufp; /* points to user filename */ unsigned char* zdrva; /* points to serveral buffers (mostly VTOC) */ unsigned char* zsba; /* points to sector buffer */ - unsigned char errno; /* number of occured error */ + unsigned char errno; /* number of occurred error */ }; typedef struct __dos2x dos2x_t; @@ -167,28 +167,28 @@ struct __os { #ifdef OSA unsigned char* linzbs; // = $00/$01 LINBUG RAM (WILL BE REPLACED BY MONITOR RAM) -#else +#else unsigned char linflg; // = $00 LNBUG FLAG (0 = NOT LNBUG) unsigned char ngflag; // = $01 MEMORY STATUS (0 = FAILURE) -#endif +#endif unsigned char* casini; // = $02/$03 CASSETTE INIT LOCATION unsigned char* ramlo; // = $04/$05 RAM POINTER FOR MEMORY TEST - -#ifdef OSA + +#ifdef OSA unsigned char tramsz; // = $06 FLAG FOR LEFT CARTRIDGE unsigned char tstdat; // = $07 FLAG FOR RIGHT CARTRIDGE -#else +#else unsigned char trnsmz; // = $06 TEMPORARY REGISTER FOR RAM SIZE unsigned char tstdat; // = $07 UNUSED (NOT TOUCHED DURING RESET/COLD START) #endif - - // Cleared upon Coldstart only - + + // Cleared upon Coldstart only + unsigned char warmst; // = $08 WARM START FLAG - unsigned char bootq; // = $09 SUCCESSFUL BOOT FLAG + unsigned char bootq; // = $09 SUCCESSFUL BOOT FLAG void (*dosvec)(void); // = $0A/$0B DISK SOFTWARE START VECTOR void (*dosini)(void); // = $0C/$0D DISK SOFTWARE INIT ADDRESS - unsigned char* appmhi; // = $0E/$0F APPLICATIONS MEMORY HI LIMIT + unsigned char* appmhi; // = $0E/$0F APPLICATIONS MEMORY HI LIMIT // Cleared upon Coldstart or Warmstart @@ -199,26 +199,26 @@ struct __os { unsigned char iccomt; // = $17 COMMAND FOR VECTOR unsigned char* dskfms; // = $18/$19 DISK FILE MANAGER POINTER unsigned char* dskutl; // = $1A/$1B DISK UTILITIES POINTER -#ifdef OSA +#ifdef OSA unsigned char ptimot; // = $1C PRINTER TIME OUT REGISTER unsigned char pbpnt; // = $1D PRINT BUFFER POINTER unsigned char pbufsz; // = $1E PRINT BUFFER SIZE unsigned char ptemp; // = $1F TEMPORARY REGISTER -#else +#else unsigned char abufpt[4]; // = $1C-$1F ACMI BUFFER POINTER AREA -#endif +#endif iocb_t ziocb; // = $20-$2F ZERO PAGE I/O CONTROL BLOCK - + unsigned char status; // = $30 INTERNAL STATUS STORAGE unsigned char chksum; // = $31 CHECKSUM (SINGLE BYTE SUM WITH CARRY) unsigned char* bufr; // = $32/$33 POINTER TO DATA BUFFER unsigned char* bfen; // = $34/$35 NEXT BYTE PAST END OF THE DATA BUFFER LO -#ifdef OSA +#ifdef OSA unsigned char cretry; // = $36 NUMBER OF COMMAND FRAME RETRIES unsigned char dretry; // = $37 NUMBER OF DEVICE RETRIES -#else +#else unsigned int ltemp; // = $36/$37 LOADER TEMPORARY -#endif +#endif unsigned char bufrfl; // = $38 DATA BUFFER FULL FLAG unsigned char recvdn; // = $39 RECEIVE DONE FLAG unsigned char xmtdon; // = $3A TRANSMISSION DONE FLAG @@ -227,22 +227,22 @@ struct __os { unsigned char bptr; // = $3D CASSETTE BUFFER POINTER unsigned char ftype; // = $3E CASSETTE IRG TYPE unsigned char feof; // = $3F CASSETTE EOF FLAG (0 // = QUIET) - + unsigned char freq; // = $40 CASSETTE BEEP COUNTER unsigned char soundr; // = $41 NOISY I/0 FLAG. (ZERO IS QUIET) unsigned char critic; // = $42 DEFINES CRITICAL SECTION (CRITICAL IF NON-Z) dos2x_t fmszpg; // = $43-$49 DISK FILE MANAGER SYSTEM ZERO PAGE -#ifdef OSA +#ifdef OSA unsigned char ckey; // = $4A FLAG SET WHEN GAME START PRESSED unsigned char cassbt; // = $4B CASSETTE BOOT FLAG -#else +#else void* zchain; // = $4A/$4B HANDLER LINKAGE CHAIN POINTER -#endif +#endif unsigned char dstat; // = $4C DISPLAY STATUS unsigned char atract; // = $4D ATRACT FLAG unsigned char drkmsk; // = $4E DARK ATRACT MASK unsigned char colrsh; // = $4F ATRACT COLOR SHIFTER (EOR'ED WITH PLAYFIELD - + unsigned char tmpchr; // = $50 TEMPORARY CHARACTER unsigned char hold1; // = $51 TEMPORARY unsigned char lmargn; // = $52 LEFT MARGIN (NORMALLY 2, CC65 C STARTUP CODE SETS IT TO 0) @@ -255,68 +255,68 @@ struct __os { unsigned int oldcol; // = $5B/$5C PRIOR COLUMN unsigned char oldchr; // = $5D DATA UNDER CURSOR unsigned char* oldadr; // = $5E/$5F SAVED CURSOR MEMORY ADDRESS - -#ifdef OSA + +#ifdef OSA unsigned char newrow; // = $60 POINT DRAW GOES TO unsigned int newcol; // = $61/$62 COLUMN DRAW GOES TO -#else +#else unsigned char* fkdef; // = $60/$61 FUNCTION KEY DEFINITION TABLE unsigned char palnts; // = $62 PAL/NTSC INDICATOR (0 // = NTSC) -#endif +#endif unsigned char logcol; // = $63 POINTS AT COLUMN IN LOGICAL LINE unsigned char* adress; // = $64/$65 TEMPORARY ADDRESS - unsigned int mlttmp; // = $66/$67 TEMPORARY / FIRST BYTE IS USED IN OPEN AS TEMP - unsigned int savadr; // = $68/$69 SAVED ADDRESS + unsigned int mlttmp; // = $66/$67 TEMPORARY / FIRST BYTE IS USED IN OPEN AS TEMP + unsigned int savadr; // = $68/$69 SAVED ADDRESS unsigned char ramtop; // = $6A RAM SIZE DEFINED BY POWER ON LOGIC unsigned char bufcnt; // = $6B BUFFER COUNT unsigned char* bufstr; // = $6C/$6D EDITOR GETCH POINTER unsigned char bitmsk; // = $6E BIT MASK unsigned char shfamt; // = $6F SHIFT AMOUNT FOR PIXEL JUSTIFUCATION - + unsigned int rowac; // = $70/$71 DRAW WORKING ROW unsigned int colac; // = $72/$73 DRAW WORKING COLUMN unsigned char* endpt; // = $74/$75 END POINT unsigned char deltar; // = $76 ROW DIFFERENCE unsigned int deltac; // = $77/$78 COLUMN DIFFERENCE -#ifdef OSA - unsigned char rowinc; // = $79 ROWINC +#ifdef OSA + unsigned char rowinc; // = $79 ROWINC unsigned char colinc; // = $7A COLINC -#else +#else unsigned char* keydef; // = $79/$7A 2-BYTE KEY DEFINITION TABLE ADDRESS -#endif +#endif unsigned char swpflg; // = $7B NON-0 1F TXT AND REGULAR RAM IS SWAPPED unsigned char holdch; // = $7C CH IS MOVED HERE IN KGETCH BEFORE CNTL & SH unsigned char insdat; // = $7D 1-BYTE TEMPORARY unsigned int countr; // = $7E/$7F 2-BYTE DRAW ITERATION COUNT - + unsigned char _free_1[0xD4-0x7F-1]; // USER SPACE - + // Floating Point Package Page Zero Address Equates - fpreg_t fpreg[4]; // = $D4-$EB 4 REGSITERS, ACCCESS LIKE "fpreg[FPIDX_R0].fr" - unsigned char frx; // = $EC 1-BYTE TEMPORARY + fpreg_t fpreg[4]; // = $D4-$EB 4 REGSITERS, ACCCESS LIKE "fpreg[FPIDX_R0].fr" + unsigned char frx; // = $EC 1-BYTE TEMPORARY unsigned char eexp; // = $ED VALUE OF EXP -#ifdef OS_REV2 +#ifdef OS_REV2 unsigned char frsign; // = $EE ##REV2## 1-BYTE FLOATING POINT SIGN unsigned char plycnt; // = $EF ##REV2## 1-BYTE POLYNOMIAL DEGREE unsigned char sgnflg; // = $F0 ##REV2## 1-BYTE SIGN FLAG unsigned char xfmflg; // = $F1 ##REV2## 1-BYTE TRANSFORM FLAG -#else +#else unsigned char nsign; // = $EE SIGN OF # unsigned char esign; // = $EF SIGN OF EXPONENT unsigned char fchrflg; // = $F0 1ST CHAR FLAG unsigned char digrt; // = $F1 # OF DIGITS RIGHT OF DECIMAL -#endif +#endif unsigned char cix; // = $F2 CURRENT INPUT INDEX - unsigned char* inbuff; // = $F3/$F4 POINTS TO USER'S LINE INPUT BUFFER + unsigned char* inbuff; // = $F3/$F4 POINTS TO USER'S LINE INPUT BUFFER unsigned int ztemp1; // = $F5/$F6 2-BYTE TEMPORARY unsigned int ztemp4; // = $F7/$F8 2-BYTE TEMPORARY unsigned int ztemp3; // = $F9/$FA 2-BYTE TEMPORARY - - union { + + union { unsigned char degflg; // = $FB ##OLD## SAME AS RADFLG unsigned char radflg; // = $FB ##OLD## 0=RADIANS, 6=DEGREES }; - + fpreg_t* flptr; // = $FC/$FD 2-BYTE FLOATING POINT NUMBER POINTER fpreg_t* fptr2; // = $FE/$FF 2-BYTE FLOATING POINT NUMBER POINTER @@ -356,28 +356,28 @@ struct __os { union { struct { unsigned char sdlstl; // = $0230 SAVE DISPLAY LIST LOW BYTE - unsigned char sdlsth; // = $0231 SAVE DISPLAY LIST HI BYTE + unsigned char sdlsth; // = $0231 SAVE DISPLAY LIST HI BYTE }; void* sdlst; // = $0230/$0231 (same as above as pointer) }; unsigned char sskctl; // = $0232 SKCTL REGISTER RAM -#ifdef OSA +#ifdef OSA unsigned char _spare_1; // = $0233 No OS use. #else unsigned char lcount; // = $0233 ##1200xl## 1-byte relocating loader record -#endif +#endif unsigned char lpenh; // = $0234 LIGHT PEN HORIZONTAL VALUE unsigned char lpenv; // = $0235 LIGHT PEN VERTICAL VALUE void (*brkky)(void); // = $0236/$0237 BREAK KEY VECTOR -#ifdef OSA +#ifdef OSA unsigned char spare2[2]; // = $0238/$0239 No OS use. -#else +#else void (*vpirq)(void); // = $0238/$0239 ##rev2## 2-byte parallel device IRQ vector -#endif +#endif unsigned char cdevic; // = $023A COMMAND FRAME BUFFER - DEVICE unsigned char ccomnd; // = $023B COMMAND union { - struct { + struct { unsigned char caux1; // = $023C COMMAND AUX BYTE 1 unsigned char caux2; // = $023D COMMAND AUX BYTE 2 }; @@ -389,15 +389,15 @@ struct __os { unsigned char dbsect; // = $0241 NUMBER OF DISK BOOT SECTORS unsigned char* bootad; // = $0242/$0243 ADDRESS WHERE DISK BOOT LOADER WILL BE PUT unsigned char coldst; // = $0244 COLDSTART FLAG (1=IN MIDDLE OF COLDSTART> -#ifdef OSA +#ifdef OSA unsigned char spare3; // = $0245 No OS use. -#else +#else unsigned char reclen; // = $0245 ##1200xl## 1-byte relocating loader record length -#endif +#endif unsigned char dsktim; // = $0246 DISK TIME OUT REGISTER -#ifdef OSA +#ifdef OSA unsigned char linbuf[40]; // = $0247-$026E ##old## CHAR LINE BUFFER -#else +#else unsigned char pdvmsk; // = $0247 ##rev2## 1-byte parallel device selection mask unsigned char shpdvs; // = $0248 ##rev2## 1-byte PDVS (parallel device select) unsigned char pdimsk; // = $0249 ##rev2## 1-byte parallel device IRQ selection @@ -409,7 +409,7 @@ struct __os { unsigned char vsflag; // = $026C ##1200xl## 1-byte fine vertical scroll count unsigned char keydis; // = $026D ##1200xl## 1-byte keyboard disable unsigned char fine; // = $026E ##1200xl## 1-byte fine scrolling mode -#endif +#endif unsigned char gprior; // = $026F GLOBAL PRIORITY CELL unsigned char paddl0; // = $0270 1-BYTE POTENTIOMETER 0 unsigned char paddl1; // = $0271 1-BYTE POTENTIOMETER 1 @@ -435,30 +435,30 @@ struct __os { unsigned char strig1; // = $0285 1-BYTE JOYSTICK TRIGGER 1 unsigned char strig2; // = $0286 1-BYTE JOYSTICK TRIGGER 2 unsigned char strig3; // = $0287 1-BYTE JOYSTICK TRIGGER 3 -#ifdef OSA +#ifdef OSA unsigned char cstat; // = $0288 ##old## cassette status register -#else +#else unsigned char hibyte; // = $0288 ##1200xl## 1-byte relocating loader high byte -#endif +#endif unsigned char wmode; // = $0289 1-byte cassette WRITE mode unsigned char blim; // = $028A 1-byte cassette buffer limit #ifdef OSA unsigned char _reserved_2[5]; // = $028B-$028F RESERVED -#else +#else unsigned char imask; // = $028B ##rev2## (not used) void (*jveck)(void); // = $028C/$028D 2-byte jump vector unsigned newadr; // = $028E/028F ##1200xl## 2-byte relocating address -#endif +#endif unsigned char txtrow; // = $0290 TEXT ROWCRS unsigned txtcol; // = $0291/$0292 TEXT COLCRS unsigned char tindex; // = $0293 TEXT INDEX unsigned char* txtmsc; // = $0294/$0295 FOOLS CONVRT INTO NEW MSC unsigned char txtold[6]; // = $0296-$029B OLDROW & OLDCOL FOR TEXT (AND THEN SOME) -#ifdef OSA +#ifdef OSA unsigned char tmpx1; // = $029C ##old## 1--byte temporary register -#else +#else unsigned char cretry; // = $029C ##1200xl## 1-byte number of command frame retries -#endif +#endif unsigned char hold3; // = $029D 1-byte temporary unsigned char subtmp; // = $029E 1-byte temporary unsigned char hold2; // = $029F 1-byte (not used) @@ -473,41 +473,41 @@ struct __os { unsigned tmpcol; // = $02B9/$02BA 2-byte temporary column unsigned char scrflg; // = $02BB SET IF SCROLL OCCURS unsigned char hold4; // = $02BC TEMP CELL USED IN DRAW ONLY -#ifdef OSA +#ifdef OSA unsigned char hold5; // = $02BD ##old## DITTO -#else +#else unsigned char dretry; // = $02BD ##1200xl## 1-byte number of device retries -#endif +#endif unsigned char shflok; // = $02BE 1-byte shift/control lock flags unsigned char botscr; // = $02BF BOTTOM OF SCREEN 24 NORM 4 SPLIT unsigned char pcolr0; // = $02C0 1-byte player-missile 0 color/luminance unsigned char pcolr1; // = $02C1 1-byte player-missile 1 color/luminance unsigned char pcolr2; // = $02C2 1-byte player-missile 2 color/luminance - unsigned char pcolr3; // = $02C3 1-byte player-missile 3 color/luminance + unsigned char pcolr3; // = $02C3 1-byte player-missile 3 color/luminance unsigned char color0; // = $02C4 1-byte playfield 0 color/luminance unsigned char color1; // = $02C5 1-byte playfield 1 color/luminance unsigned char color2; // = $02C6 1-byte playfield 2 color/luminance unsigned char color3; // = $02C7 1-byte playfield 3 color/luminance unsigned char color4; // = $02C8 1-byte background color/luminance -#ifdef OSA +#ifdef OSA unsigned char _spare_2[23]; // = $02C9-$02DF No OS use. #else union { unsigned char parmbl[6]; // = $02C9 ##rev2## 6-byte relocating loader parameter - struct { + struct { void (*runadr)(void); // = $02C9 ##1200xl## 2-byte run address unsigned int hiused; // = $02CB ##1200xl## 2-byte highest non-zero page address unsigned int zhiuse; // = $02CD ##1200xl## 2-byte highest zero page address - }; - }; - union { + }; + }; + union { unsigned char oldpar[6]; // = $02CF ##rev2## 6-byte relocating loader parameter - struct { + struct { void (*gbytea)(void); // = $02CF ##1200xl## 2-byte GET-BYTE routine address unsigned int loadad; // = $02D1 ##1200xl## 2-byte non-zero page load address unsigned int zloada; // = $02D3 ##1200xl## 2-byte zero page load address - }; - }; + }; + }; unsigned int dsctln; // = $02D5 ##1200xl## 2-byte disk sector length unsigned int acmisr; // = $02D7 ##1200xl## 2-byte ACMI interrupt service routine unsigned char krpdel; // = $02D9 ##1200xl## 1-byte auto-repeat delay @@ -517,78 +517,78 @@ struct __os { unsigned char dmasav; // = $02DD ##1200xl## 1-byte SDMCTL save/restore unsigned char pbpnt; // = $02DE ##1200xl## 1-byte printer buffer pointer unsigned char pbufsz; // = $02DF ##1200xl## 1-byte printer buffer size -#endif - union { +#endif + union { unsigned char glbabs[4]; // = $02E0-$02E3 byte global variables for non-DOS users - struct { + struct { void (*runad)(void); // = $02E0 ##map## 2-byte binary file run address void (*initad)(void); // = $02E2 ##map## 2-byte binary file initialization address - }; - }; + }; + }; unsigned char ramsiz; // = $02E4 RAM SIZE (HI BYTE ONLY) void* memtop; // = $02E5 TOP OF AVAILABLE USER MEMORY void* memlo; // = $02E7 BOTTOM OF AVAILABLE USER MEMORY -#ifdef OSA +#ifdef OSA unsigned char _spare_3; // = $02E9 No OS use. -#else +#else unsigned char hndlod; // = $02E9 ##1200xl## 1-byte user load flag -#endif +#endif unsigned char dvstat[4]; // = $02EA-$02ED STATUS BUFFER - union { + union { unsigned int cbaud; // = $02EE/$02EF 2-byte cassette baud rate - struct { + struct { unsigned char cbaudl; // = $02EE 1-byte low cassette baud rate unsigned char cbaudh; // = $02EF 1-byte high cassette baud rate - }; - }; + }; + }; unsigned char crsinh; // = $02F0 CURSOR INHIBIT (00 = CURSOR ON) unsigned char keydel; // = $02F1 KEY DELAY unsigned char ch1; // = $02F2 1-byte prior keyboard character unsigned char chact; // = $02F3 CHACTL REGISTER RAM unsigned char chbas; // = $02F4 CHBAS REGISTER RAM -#ifdef OSA +#ifdef OSA unsigned char _spare_4[5]; // = $02F5-$02F9 No OS use. -#else +#else unsigned char newrow; // = $02F5 ##1200xl## 1-byte draw destination row unsigned int newcol; // = $02F6/$02F7 ##1200xl## 2-byte draw destination column unsigned char rowinc; // = $02F8 ##1200xl## 1-byte draw row increment unsigned char colinc; // = $02F9 ##1200xl## 1-byte draw column increment -#endif +#endif unsigned char char_; // = $02FA 1-byte internal character (naming changed due to do keyword conflict) unsigned char atachr; // = $02FB ATASCII CHARACTER unsigned char ch; // = $02FC GLOBAL VARIABLE FOR KEYBOARD unsigned char fildat; // = $02FD RIGHT FILL DATA <DRAW> unsigned char dspflg; // = $02FE DISPLAY FLAG DISPLAY CNTLS IF NON-ZERO unsigned char ssflag; // = $02FF START/STOP FLAG FOR PAGING (CNTL 1). CLEARE - + // --- Page 3 --- dcb_t dcb; // = $0300-$030B DEVICE CONTROL BLOCK unsigned int timer1; // = $030C/$030D INITIAL TIMER VALUE -#ifdef OSA +#ifdef OSA unsigned char addcor; // = $030E ##old## ADDITION CORRECTION -#else +#else unsigned char jmpers; // = $030E ##1200xl## 1-byte jumper options -#endif +#endif unsigned char casflg; // = $030F CASSETTE MODE WHEN SET unsigned int timer2; // = $0310/$0311 2-byte final baud rate timer value unsigned char temp1; // = $0312 TEMPORARY STORAGE REGISTER -#ifdef OSA +#ifdef OSA unsigned char _spare_5; // = $0313 unused unsigned char temp2; // = $0314 ##old## TEMPORARY STORAGE REGISTER -#else +#else unsigned char temp2; // = $0313 ##1200xl## 1-byte temporary unsigned char ptimot; // = $0314 ##1200xl## 1-byte printer timeout -#endif +#endif unsigned char temp3; // = $0315 TEMPORARY STORAGE REGISTER unsigned char savio; // = $0316 SAVE SERIAL IN DATA PORT unsigned char timflg; // = $0317 TIME OUT FLAG FOR BAUD RATE CORRECTION unsigned char stackp; // = $0318 SIO STACK POINTER SAVE CELL unsigned char tstat; // = $0319 TEMPORARY STATUS HOLDER -#ifdef OSA +#ifdef OSA hatabs_t hatabs[12]; // = $031A-$033D handler address table unsigned int zeropad; // = $033E/$033F zero padding -#else +#else hatabs_t hatabs[11]; // = $031A-$033A handler address table unsigned int zeropad; // = $033B/$033C zero padding unsigned char pupbt1; // = $033D ##1200xl## 1-byte power-up validation byte 1 @@ -598,9 +598,9 @@ struct __os { iocb_t iocb[8]; // = $0340-$03BF 8 I/O Control Blocks unsigned char prnbuf[40]; // = $03C0-$3E7 PRINTER BUFFER -#ifdef OSA +#ifdef OSA unsigned char _spare_6[151]; // = $03E8-$047F unused -#else +#else unsigned char superf; // = $03E8 ##1200xl## 1-byte editor super function flag unsigned char ckey; // = $03E9 ##1200xl## 1-byte cassette boot request flag unsigned char cassbt; // = $03EA ##1200xl## 1-byte cassette boot flag @@ -639,7 +639,7 @@ struct __basic { void* starp; // = $8C/$8D ADDRESS FOR THE STRING AND ARRAY TABLE void* runstk; // = $8E/$8F ADDRESS OF THE RUNTIME STACK void* memtop; // = $90/$91 POINTER TO THE TOP OF BASIC MEMORY - + unsigned char _internal_1[0xBA-0x91-1]; // INTERNAL DATA unsigned int stopln; // = $BA/$BB LINE WHERE A PROGRAM WAS STOPPED diff --git a/include/_maria.h b/include/_maria.h new file mode 100644 index 000000000..461119fda --- /dev/null +++ b/include/_maria.h @@ -0,0 +1,63 @@ +/*****************************************************************************/ +/* */ +/* _maria.h */ +/* */ +/* Atari 7800, Maria chip register hardware structures */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +/* + * MARIA registers + */ +struct __maria { + unsigned char bkgrnd; + unsigned char p0c1; + unsigned char p0c2; + unsigned char p0c3; + unsigned char wsync; + unsigned char p1c1; + unsigned char p1c2; + unsigned char p1c3; + unsigned char mstat; + unsigned char p2c1; + unsigned char p2c2; + unsigned char p2c3; + unsigned char dpph; + unsigned char p3c1; + unsigned char p3c2; + unsigned char p3c3; + unsigned char dppl; + unsigned char p4c1; + unsigned char p4c2; + unsigned char p4c3; + unsigned char chbase; + unsigned char p5c1; + unsigned char p5c2; + unsigned char p5c3; + unsigned char offset; + unsigned char p6c1; + unsigned char p6c2; + unsigned char p6c3; + unsigned char ctrl; + unsigned char p7c1; + unsigned char p7c2; + unsigned char p7c3; +}; diff --git a/include/_pokey.h b/include/_pokey.h index 88d6949aa..15af4919e 100644 --- a/include/_pokey.h +++ b/include/_pokey.h @@ -131,7 +131,7 @@ struct __pokey_write { #define SKCTL_KEYBOARD_SCANNING 0x02 /* Enable keyboard scanning circuit */ /* Fast pot scan -** The pot scan counter completes its sequence in two TV line times instead of +** The pot scan counter completes its sequence in two TV line times instead of ** one frame time (228 scan lines). Not as accurate as the normal pot scan */ #define SKCTL_FAST_POT_SCAN 0x04 @@ -204,7 +204,7 @@ struct __pokey_read { #define SKSTAT_DATA_READ_INGORING_SHIFTREG 0x10 /* Data can be read directly from the serial input port, ignoring the shift register. */ #define SKSTAT_KEYBOARD_OVERRUN 0x20 /* Keyboard over-run; Reset BITs 7, 6 and 5 (latches) to 1, using SKREST */ #define SKSTAT_INPUT_OVERRUN 0x40 /* Serial data input over-run. Reset latches as above. */ -#define SKSTAT_INPUT_FRAMEERROR 0x80 /* Serial data input frame error caused by missing or extra bits. Reset latches as above. */ +#define SKSTAT_INPUT_FRAMEERROR 0x80 /* Serial data input frame error caused by missing or extra bits. Reset latches as above. */ /* KBCODE, internal keyboard codes for Atari 8-bit computers, diff --git a/include/accelerator.h b/include/accelerator.h index fdd2ebaf7..b5d8d0194 100644 --- a/include/accelerator.h +++ b/include/accelerator.h @@ -180,7 +180,7 @@ unsigned char detect_c128 (void); unsigned char __fastcall__ set_chameleon_speed (unsigned char speed); /* Set the speed of the C64 Chameleon cartridge, the following inputs - * are accepted: + * are accepted: * SPEED_SLOW : 1 Mhz mode * SPEED_1X : 1 Mhz mode * SPEED_2X : 2 Mhz mode diff --git a/include/apple2.h b/include/apple2.h index 57d7086ce..015e8f378 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -159,11 +159,11 @@ extern struct { unsigned day :5; unsigned mon :4; unsigned year :7; - } createdate; /* Current date: 0 */ + } createdate; /* Current date: 0 */ struct { unsigned char min; unsigned char hour; - } createtime; /* Current time: 0 */ + } createtime; /* Current time: 0 */ } _datetime; /* The addresses of the static drivers */ diff --git a/include/atari7800.h b/include/atari7800.h new file mode 100644 index 000000000..4fdaacfcc --- /dev/null +++ b/include/atari7800.h @@ -0,0 +1,65 @@ +/*****************************************************************************/ +/* */ +/* Atari VCS 7800 TIA & RIOT registers addresses */ +/* */ +/* Karri Kaksonen (karri@sipo.fi), 2022 */ +/* */ +/* */ +/*****************************************************************************/ + + + +#ifndef _ATARI7800_H +#define _ATARI7800_H + +/* Check for errors */ +#if !defined(__ATARI7800__) +# error This module may only be used when compiling for the Atari 7800! +#endif + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Color defines */ +#define COLOR_BLACK 0x00 +#define COLOR_GREY 0x01 +#define COLOR_LIGHTGREY 0x02 +#define COLOR_WHITE 0x03 + +/* TGI color defines (default palette) */ +#define TGI_COLOR_BLACK COLOR_BLACK +#define TGI_COLOR_GREY COLOR_GREY +#define TGI_COLOR_LIGHTGREY COLOR_LIGHTGREY +#define TGI_COLOR_WHITE COLOR_WHITE + +/* Masks for joy_read */ +#define JOY_RIGHT_MASK 0x80 +#define JOY_LEFT_MASK 0x40 +#define JOY_DOWN_MASK 0x20 +#define JOY_UP_MASK 0x10 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 + +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASK JOY_BTN_2_MASK + +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) + +/* No support for dynamically loadable drivers */ +#define DYN_DRV 0 + +#include <_tia.h> +#define TIA (*(struct __tia*)0x0000) + +#include <_riot.h> +#define RIOT (*(struct __riot*)0x0280) + +#include <_maria.h> +#define MARIA (*(struct __maria*)0x0020) + +/* End of atari7800.h */ +#endif diff --git a/include/cc65.h b/include/cc65.h index 7e9c2cae2..2b05cc17a 100644 --- a/include/cc65.h +++ b/include/cc65.h @@ -59,21 +59,21 @@ unsigned long __fastcall__ udiv32by16r16 (unsigned long rhs, unsigned lhs); */ int __fastcall__ imul8x8r16 (signed char lhs, signed char rhs); -/* Multiplicate two signed 8 bit to yield an signed 16 bit result */ +/* Multiply two signed 8 bit to yield an signed 16 bit result */ long __fastcall__ imul16x16r32 (int lhs, int rhs); -/* Multiplicate two signed 16 bit to yield a signed 32 bit result */ +/* Multiply two signed 16 bit to yield a signed 32 bit result */ unsigned __fastcall__ umul8x8r16 (unsigned char lhs, unsigned char rhs); -/* Multiplicate two unsigned 8 bit to yield an unsigned 16 bit result */ +/* Multiply two unsigned 8 bit to yield an unsigned 16 bit result */ unsigned long __fastcall__ umul16x8r32 (unsigned lhs, unsigned char rhs); -/* Multiplicate an unsigned 16 bit by an unsigned 8 bit number yielding a 24 +/* Multiply an unsigned 16 bit by an unsigned 8 bit number yielding a 24 ** bit unsigned result that is extended to 32 bits for easier handling from C. */ unsigned long __fastcall__ umul16x16r32 (unsigned lhs, unsigned rhs); -/* Multiplicate two unsigned 16 bit to yield an unsigned 32 bit result */ +/* Multiply two unsigned 16 bit to yield an unsigned 32 bit result */ unsigned int __fastcall__ mul20 (unsigned char value); /* Multiply an 8 bit unsigned value by 20 and return the 16 bit unsigned diff --git a/include/dbg.h b/include/dbg.h index 7b4f67e31..4cca826ec 100644 --- a/include/dbg.h +++ b/include/dbg.h @@ -39,7 +39,7 @@ ** are declared here. ** ** To use the debugger, just call DbgInit in your application. Once it has -** been called, the debugger will catch any BRK opcode. Use the BREAK macro +** been called, the debugger will catch any BRK opcode. Use the BREAK macro ** defined below to insert breakpoints into your code. ** ** There are currently a lot of things that cannot be debugged, graphical @@ -121,4 +121,4 @@ void __fastcall__ DbgInit (unsigned unused); - + diff --git a/include/errno.h b/include/errno.h index ae76b6c05..92d304938 100644 --- a/include/errno.h +++ b/include/errno.h @@ -84,7 +84,7 @@ extern int _errno; int __fastcall__ _osmaperrno (unsigned char oserror); -/* Map an operating system specific error code (for example from _oserror) +/* Map an operating system specific error code (for example from _oserror) ** into one of the E... codes above. It is user callable. */ diff --git a/include/gamate.h b/include/gamate.h index 8b9790e39..bc6de3f98 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -145,6 +145,8 @@ /* constants for the conio implementation */ #define COLOR_BLACK 0x03 +#define COLOR_GRAY2 0x02 +#define COLOR_GRAY1 0x01 #define COLOR_WHITE 0x00 #define CH_HLINE 1 diff --git a/include/geos/gmemory.h b/include/geos/gmemory.h index ba8e9f211..1e9ca83b4 100644 --- a/include/geos/gmemory.h +++ b/include/geos/gmemory.h @@ -12,7 +12,7 @@ void __fastcall__ CopyString(char *dest, const char *source); char __fastcall__ CmpString(const char *dest, const char *source); void __fastcall__ CopyFString(char len, char *dest, const char *source); -char __fastcall__ CmpFString(char len, char *dest, const char *source); +char __fastcall__ CmpFString(char len, char *dest, const char *source); unsigned __fastcall__ CRC(const char *buffer, unsigned len); void* __fastcall__ ClearRam(char *dest, unsigned len); diff --git a/include/lynx.h b/include/lynx.h index 4b0390a13..e5ff88a99 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -52,24 +52,25 @@ /* Color defines */ -#define COLOR_BLACK 0x00 -#define COLOR_RED 0x01 -#define COLOR_PINK 0x02 -#define COLOR_LIGHTGREY 0x03 -#define COLOR_GREY 0x04 -#define COLOR_DARKGREY 0x05 -#define COLOR_BROWN 0x06 -#define COLOR_PEACH 0x07 -#define COLOR_YELLOW 0x08 -#define COLOR_LIGHTGREEN 0x09 -#define COLOR_GREEN 0x0A -#define COLOR_DARKBROWN 0x0B +#define COLOR_TRANSPARENT 0x00 +#define COLOR_BLACK 0x01 +#define COLOR_RED 0x02 +#define COLOR_PINK 0x03 +#define COLOR_LIGHTGREY 0x04 +#define COLOR_GREY 0x05 +#define COLOR_DARKGREY 0x06 +#define COLOR_BROWN 0x07 +#define COLOR_PEACH 0x08 +#define COLOR_YELLOW 0x09 +#define COLOR_LIGHTGREEN 0x0A +#define COLOR_GREEN 0x0B #define COLOR_VIOLET 0x0C #define COLOR_BLUE 0x0D #define COLOR_LIGHTBLUE 0x0E #define COLOR_WHITE 0x0F /* TGI color defines (default palette) */ +#define TGI_COLOR_TRANSPARENT COLOR_TRANSPARENT #define TGI_COLOR_BLACK COLOR_BLACK #define TGI_COLOR_RED COLOR_RED #define TGI_COLOR_PINK COLOR_PINK @@ -81,7 +82,6 @@ #define TGI_COLOR_YELLOW COLOR_YELLOW #define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN #define TGI_COLOR_GREEN COLOR_GREEN -#define TGI_COLOR_DARKBROWN COLOR_DARKBROWN #define TGI_COLOR_VIOLET COLOR_VIOLET #define TGI_COLOR_BLUE COLOR_BLUE #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE diff --git a/include/stdlib.h b/include/stdlib.h index b929e8f02..99151317f 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -52,8 +52,8 @@ typedef unsigned size_t; /* Those non-standard cc65 exit constants definitions are in addition ** to the EXIT_SUCCESS and EXIT_FAILURE constants, which should not be -** redefined -*/ +** redefined +*/ #define EXIT_ASSERT 2 #define EXIT_ABORT 3 diff --git a/include/sys/utsname.h b/include/sys/utsname.h index a601d9eed..fdd87dec3 100644 --- a/include/sys/utsname.h +++ b/include/sys/utsname.h @@ -41,7 +41,7 @@ /*****************************************************************************/ /* Data */ /*****************************************************************************/ - + /* diff --git a/include/target.h b/include/target.h index af401ec35..7663a39dd 100644 --- a/include/target.h +++ b/include/target.h @@ -43,6 +43,8 @@ # include <atari2600.h> #elif defined(__ATARI5200__) # include <atari5200.h> +#elif defined(__ATARI7800__) +# include <atari7800.h> #elif defined(__ATMOS__) # include <atmos.h> #elif defined(__CBM__) diff --git a/libsrc/Makefile b/libsrc/Makefile index 60946b59f..177314bdf 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -21,6 +21,7 @@ TARGETS = apple2 \ atarixl \ atari2600 \ atari5200 \ + atari7800 \ atmos \ creativision \ $(CBMS) \ diff --git a/libsrc/apple2/color.s b/libsrc/apple2/color.s index 3b0c5b6d4..c54207288 100644 --- a/libsrc/apple2/color.s +++ b/libsrc/apple2/color.s @@ -13,4 +13,4 @@ _textcolor := return1 _bgcolor := return0 -_bordercolor := return0 \ No newline at end of file +_bordercolor := return0 diff --git a/libsrc/apple2/exec.s b/libsrc/apple2/exec.s index c0cd98650..0ff4bc6f0 100644 --- a/libsrc/apple2/exec.s +++ b/libsrc/apple2/exec.s @@ -18,7 +18,7 @@ typerr: lda #$4A ; "Incompatible file format" ; Cleanup name oserr: jsr popname ; Preserves A - + ; Set __oserror jmp __mappederrno @@ -129,7 +129,7 @@ setbuf: lda #$00 ; Low byte .assert MLI::OPEN::PATHNAME = MLI::INFO::PATHNAME, error ; Lower file level to avoid program file - ; being closed by C libary shutdown code + ; being closed by C library shutdown code ldx LEVEL stx level beq :+ @@ -185,13 +185,13 @@ setbuf: lda #$00 ; Low byte lda #$00 ; '\0' beq :- ; Branch always - ; Call loader stub after C libary shutdown + ; Call loader stub after C library shutdown : lda #<target ldx #>target sta done+1 stx done+2 - ; Initiate C libary shutdown + ; Initiate C library shutdown jmp _exit .bss diff --git a/libsrc/apple2/iobuf.s b/libsrc/apple2/iobuf.s index 77433ce61..f5aacb74a 100644 --- a/libsrc/apple2/iobuf.s +++ b/libsrc/apple2/iobuf.s @@ -2,7 +2,7 @@ ; Oliver Schmidt, 10.9.2009 ; ; Default ProDOS 8 I/O buffer management -; +; .export iobuf_alloc, iobuf_free .import _posix_memalign, _free diff --git a/libsrc/apple2/mcbdefault.s b/libsrc/apple2/mcbdefault.s index c24c5df56..556a9d8fb 100644 --- a/libsrc/apple2/mcbdefault.s +++ b/libsrc/apple2/mcbdefault.s @@ -8,13 +8,13 @@ ; .export _mouse_def_callbacks - + .include "apple2.inc" ; ------------------------------------------------------------------------ .bss - + backup: .res 1 visible:.res 1 diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s index c3d10f057..dfc69a942 100644 --- a/libsrc/apple2/mou/a2.stdmou.s +++ b/libsrc/apple2/mou/a2.stdmou.s @@ -152,7 +152,7 @@ next: inc ptr1+1 sta xparam+1 sta jump+2 - ; Disable interrupts now because setting the slot number makes + ; Disable interrupts now because setting the slot number makes ; the IRQ handler (maybe called due to some non-mouse IRQ) try ; calling the firmware which isn't correctly set up yet sei @@ -167,7 +167,7 @@ next: inc ptr1+1 asl asl sta yparam+1 - + ; The AppleMouse II Card needs the ROM switched in ; to be able to detect an Apple //e and use RDVBL bit $C082 @@ -175,7 +175,7 @@ next: inc ptr1+1 ; Reset mouse hardware ldx #INITMOUSE jsr firmware - + ; Switch in LC bank 2 for R/O bit $C080 @@ -236,12 +236,12 @@ UNINSTALL: SETBOX: sta ptr1 stx ptr1+1 - + ; Set x clamps ldx #$00 ldy #MOUSE_BOX::MINX jsr :+ - + ; Set y clamps ldx #$01 ldy #MOUSE_BOX::MINY @@ -257,7 +257,7 @@ SETBOX: sta pos1_lo iny lda (ptr1),y - sta box,y + sta box,y sta pos1_hi ; Skip one word @@ -267,11 +267,11 @@ SETBOX: ; Set high clamp iny lda (ptr1),y - sta box,y + sta box,y sta pos2_lo iny lda (ptr1),y - sta box,y + sta box,y sta pos2_hi txa diff --git a/libsrc/apple2/opendir.c b/libsrc/apple2/opendir.c index 040593118..1144d8511 100644 --- a/libsrc/apple2/opendir.c +++ b/libsrc/apple2/opendir.c @@ -57,7 +57,7 @@ extern char _cwd[FILENAME_MAX]; -DIR* __fastcall__ opendir (register const char* name) +DIR* __fastcall__ opendir (register const char* name) { register DIR* dir; diff --git a/libsrc/apple2/write.s b/libsrc/apple2/write.s index 21f4a45a4..d9dd73ca9 100644 --- a/libsrc/apple2/write.s +++ b/libsrc/apple2/write.s @@ -111,4 +111,4 @@ errno: jmp __directerrno ; Set __oserror oserr: jmp __mappederrno - + diff --git a/libsrc/atari/break.s b/libsrc/atari/break.s index 0cfba1c5a..ae4c8e007 100644 --- a/libsrc/atari/break.s +++ b/libsrc/atari/break.s @@ -63,7 +63,7 @@ L1: lda #<brk_handler ; Set the break vector to our routine lda #$00 sta oldvec ; Clear the old vector stx oldvec+1 -@L9: rts +@L9: rts .endproc diff --git a/libsrc/atari/cclear.s b/libsrc/atari/cclear.s index 7fe3f0f1b..3d3b841cf 100644 --- a/libsrc/atari/cclear.s +++ b/libsrc/atari/cclear.s @@ -17,7 +17,7 @@ _cclearxy: _cclear: cmp #0 ; Is the length zero? beq L9 ; Jump if done - sta tmp1 + sta tmp1 L1: lda #0 ; Blank - screen code jsr cputdirect ; Direct output dec tmp1 diff --git a/libsrc/atari/ctype.s b/libsrc/atari/ctype.s index 2f219f8c3..ca2d3a67f 100644 --- a/libsrc/atari/ctype.s +++ b/libsrc/atari/ctype.s @@ -12,7 +12,7 @@ .include "ctypetable.inc" .export __ctypeidx - + ; The tables are readonly, put them into the rodata segment .rodata diff --git a/libsrc/atari/cvline.s b/libsrc/atari/cvline.s index 735e47dd2..96ceef5c1 100644 --- a/libsrc/atari/cvline.s +++ b/libsrc/atari/cvline.s @@ -5,7 +5,7 @@ ; void cvline (unsigned char length); ; .include "atari.inc" - + .export _cvlinexy, _cvline .import gotoxy, putchar, setcursor .importzp tmp1 diff --git a/libsrc/atari/diopncls.s b/libsrc/atari/diopncls.s index 2cdeba78b..528c0fad8 100644 --- a/libsrc/atari/diopncls.s +++ b/libsrc/atari/diopncls.s @@ -137,7 +137,7 @@ _dio_open: iny lda #1 -finish: sta (ptr2),y ; set default sector size +finish: sta (ptr2),y ; set default sector size fini2: lda ptr2 ldx ptr2+1 rts diff --git a/libsrc/atari/dioqsize.s b/libsrc/atari/dioqsize.s index f26667af7..caef0588f 100644 --- a/libsrc/atari/dioqsize.s +++ b/libsrc/atari/dioqsize.s @@ -12,7 +12,7 @@ .proc _dio_query_sectsize sta ptr1 ; handle - stx ptr1+1 + stx ptr1+1 lda #0 sta __oserror diff --git a/libsrc/atari/doesclrscr.s b/libsrc/atari/doesclrscr.s index f937f9ac5..4b2f30b2a 100644 --- a/libsrc/atari/doesclrscr.s +++ b/libsrc/atari/doesclrscr.s @@ -12,7 +12,7 @@ .ifdef __ATARIXL__ _doesclrscrafterexit = return1 ; the c65 runtime always clears the screen at program termination -.else +.else _doesclrscrafterexit: jsr __is_cmdline_dos ; currently (unless a DOS behaving differently is popping up) eor #$01 ; we can get by with the inverse of __is_cmdline_dos diff --git a/libsrc/atari/emd/atr130.s b/libsrc/atari/emd/atr130.s index f2d5777d5..7f4d51590 100644 --- a/libsrc/atari/emd/atr130.s +++ b/libsrc/atari/emd/atr130.s @@ -11,7 +11,7 @@ ; Bit 2: bank control ; Bit 1: BASIC on/off ; Bit 0: OS RAM on/off -; +; ; Masks: %11100011 $E3 Bank 0 ; %11100111 $E7 Bank 1 ; %11101011 $EB Bank 2 @@ -67,7 +67,7 @@ ; Constants BANK = $4000 ; bank window -STACK = $0100 ; stack location +STACK = $0100 ; stack location PAGES = 256 ; 4 x 16k banks @@ -93,17 +93,17 @@ stacktest: sei @2: sta $4000 ; restore cli rts -stacktest_end: +stacktest_end: stackcopy: sei ; disable interrupts @1: dex ; pre-decrement (full page x=0) ldy #$FF ; this will be replaced STACK+3 - sty $D301 ; set bank + sty $D301 ; set bank lda $FF00,x ; address to copy from STACK+8,+9 ldy #$FF ; this will be replaced STACK+11 - sty $D301 + sty $D301 sta $FF00,x ; address to copy to STACK+16,+17 - cpx #0 + cpx #0 bne @1 ldy #$FF ; portb_save STACK+23 sty $D301 @@ -122,7 +122,7 @@ stackcopy_byte: sei sty $D301 cli rts -stackcopy_byte_end: +stackcopy_byte_end: .data @@ -186,14 +186,14 @@ setpage: INSTALL: lda $D301 ; save state of portb sta portb_save - tay + tay jsr install_test ; doesn't touch Y sty STACK+13 lda $4000 ; test for extended memory jsr STACK - bcs @1 + bcs @1 lda #EM_ERR_OK rts @1: lda #EM_ERR_NO_DEVICE @@ -242,7 +242,7 @@ MAP: jsr setpage ; extract the bank/page lda banks,x sta STACK+3 ; set bank to copy from ; lda ptr1 -; sta STACK+8 +; sta STACK+8 lda ptr1+1 sta STACK+9 ; set copy from address lda portb_save @@ -251,10 +251,10 @@ MAP: jsr setpage ; extract the bank/page lda ptr2 sta STACK+16 lda ptr2+1 - sta STACK+17 ; set copy to address + sta STACK+17 ; set copy to address ldx #0 ; full page copy - jsr STACK ; do the copy! + jsr STACK ; do the copy! ; Return the memory window @@ -298,7 +298,7 @@ COMMIT: lda curpage ; Get the current page sta STACK+3 ; set bank to copy from sta STACK+23 ; set final portb restore lda ptr1 - sta STACK+8 + sta STACK+8 lda ptr1+1 sta STACK+9 ; set copy from address ldx curbank @@ -307,10 +307,10 @@ COMMIT: lda curpage ; Get the current page ;lda ptr2 ;sta STACK+16 lda ptr2+1 - sta STACK+17 ; set copy to address + sta STACK+17 ; set copy to address ldx #0 ; full page copy - jsr STACK ; do the copy! + jsr STACK ; do the copy! commit_done: rts @@ -329,7 +329,7 @@ COPYFROM: ldy #EM_COPY::OFFS lda (ptr3),y - sta STACK+7 ; offset goes into BANK low + sta STACK+7 ; offset goes into BANK low ldy #EM_COPY::PAGE lda (ptr3),y @@ -357,9 +357,9 @@ COPYFROM: add #>BANK ; add to BANK address sta STACK+8 ; current page in bank ldx curbank - lda banks,x - sta STACK+2 ; set bank in stack - lda portb_save + lda banks,x + sta STACK+2 ; set bank in stack + lda portb_save sta STACK+10 ; set bank restore in stack sta STACK+18 ; set final restore too @@ -399,7 +399,7 @@ copyfrom_copy: bne @3 inc STACK+16 -@3: jmp copyfrom_copy ; copy another byte +@3: jmp copyfrom_copy ; copy another byte done: rts @@ -418,7 +418,7 @@ COPYTO: ldy #EM_COPY::OFFS lda (ptr3),y - sta STACK+15 ; offset goes into BANK low + sta STACK+15 ; offset goes into BANK low ldy #EM_COPY::PAGE lda (ptr3),y @@ -446,9 +446,9 @@ COPYTO: add #>BANK ; add to BANK address sta STACK+16 ; current page in bank ldx curbank - lda banks,x - sta STACK+10 ; set bank in stack - lda portb_save + lda banks,x + sta STACK+10 ; set bank in stack + lda portb_save sta STACK+2 ; set bank restore in stack sta STACK+18 ; set final restore too @@ -488,5 +488,5 @@ copyto_copy: bne @3 inc STACK+8 -@3: jmp copyto_copy ; copy another byte +@3: jmp copyto_copy ; copy another byte diff --git a/libsrc/atari/mcbtxtchar.s b/libsrc/atari/mcbtxtchar.s index 4ff79c651..95dd1651a 100644 --- a/libsrc/atari/mcbtxtchar.s +++ b/libsrc/atari/mcbtxtchar.s @@ -74,7 +74,7 @@ prep: jsr getcursor ; Get character at cursor position cmp #mouse_txt_char ; "mouse" character bne overwr ; no, probably program has overwritten it - lda backup ; + lda backup ; jmp setcursor ; Draw character overwr: sta backup rts diff --git a/libsrc/atari/randomize.s b/libsrc/atari/randomize.s index ed4400b55..915fee3bd 100644 --- a/libsrc/atari/randomize.s +++ b/libsrc/atari/randomize.s @@ -10,7 +10,7 @@ .include "atari.inc" -__randomize: +__randomize: ldx VCOUNT ; Use vertical line counter as high byte lda RTCLOK+2 ; Use clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/atari/revers.s b/libsrc/atari/revers.s index 719503940..23126a88f 100644 --- a/libsrc/atari/revers.s +++ b/libsrc/atari/revers.s @@ -4,7 +4,7 @@ ; unsigned char revers (unsigned char onoff); ; .include "atari.inc" - + .export _revers .export _revflag diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index a8ba611b6..eaea35195 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -737,9 +737,9 @@ fn_cont:jsr get_fn_len lda #0 sta ICBLH,x jsr chk_CIO_buf - pla + pla sta ICBLH,x - pla + pla sta ICBLL,x pla tay @@ -756,7 +756,7 @@ chk_CIO_buf: lda ICBAH,x cmp #$c0 bcc @cont -@ret: +@ret: .ifdef DEBUG jsr CIO_buf_noti .endif diff --git a/libsrc/atari/system_check.s b/libsrc/atari/system_check.s index df7c433a4..762fc954f 100644 --- a/libsrc/atari/system_check.s +++ b/libsrc/atari/system_check.s @@ -93,7 +93,7 @@ sdnobw: lda DOS+1 ; SD version ldy #31 ; offset for OSRMFLG lda (DOSVEC),y ; get OSRMFLG bne sdcrts1 - + sdcrts0:clc rts sdcrts1:sec diff --git a/libsrc/atari/xlmemchk.inc b/libsrc/atari/xlmemchk.inc index f8be1c137..ecb874799 100644 --- a/libsrc/atari/xlmemchk.inc +++ b/libsrc/atari/xlmemchk.inc @@ -7,7 +7,7 @@ ; It calculates the value to put into RAMTOP for a subsequent ; "GRAPHICS 0" call, and the lowest address which will be used ; by the screen memory afterwards. -; +; ; inputs: ; __STARTADDRESS__ - load address of the program ; outputs: diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index 1311e874c..8c78fd44f 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -74,7 +74,7 @@ conio_color: .res 1 dlist: .repeat 3 .byte DL_BLK8 .endrepeat - + .byte DL_CHR20x8x2 | DL_LMS .word SCREEN_BUF diff --git a/libsrc/atari5200/cvline.s b/libsrc/atari5200/cvline.s index 204d90382..b4b3f1a3e 100644 --- a/libsrc/atari5200/cvline.s +++ b/libsrc/atari5200/cvline.s @@ -5,7 +5,7 @@ ; void cvline (unsigned char length); ; .include "atari5200.inc" - + .export _cvlinexy, _cvline .import gotoxy, putchar .importzp tmp1 diff --git a/libsrc/atari5200/extra/conioscreen-20x12.s b/libsrc/atari5200/extra/conioscreen-20x12.s index e591bf05a..aeb11cb43 100644 --- a/libsrc/atari5200/extra/conioscreen-20x12.s +++ b/libsrc/atari5200/extra/conioscreen-20x12.s @@ -74,7 +74,7 @@ conio_color: .res 1 dlist: .repeat 3 .byte DL_BLK8 .endrepeat - + .byte DL_CHR20x16x2 | DL_LMS .word SCREEN_BUF diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s index 989bc5ee0..fb7946bea 100644 --- a/libsrc/atari5200/joy/atr5200std.s +++ b/libsrc/atari5200/joy/atr5200std.s @@ -44,7 +44,7 @@ ; 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 lda #JOY_ERR_OK ldx #0 diff --git a/libsrc/atari5200/randomize.s b/libsrc/atari5200/randomize.s index ef462827e..978ccf3f3 100644 --- a/libsrc/atari5200/randomize.s +++ b/libsrc/atari5200/randomize.s @@ -10,7 +10,7 @@ .include "atari5200.inc" -__randomize: +__randomize: ldx VCOUNT ; Use vertical line counter as high byte lda RTCLOK+1 ; Use clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/atari5200/y2k.inc b/libsrc/atari5200/y2k.inc index f8531451c..9f7917cd3 100644 --- a/libsrc/atari5200/y2k.inc +++ b/libsrc/atari5200/y2k.inc @@ -9,16 +9,16 @@ Y2K LDY #$00 ; Copy BIOS opening screen to RAM CPX #$E8 ; Is this a 4 port? BNE Y2K0 ; Jump if not LDA #$42 ; Yes, 4 port system -Y2K0 STA TEMPL -Y2K1 LDA (TEMPL),Y +Y2K0 STA TEMPL +Y2K1 LDA (TEMPL),Y STA $0600,Y - INY + INY BNE Y2K1 LDY #$50 INC TEMPH -Y2K2 LDA (TEMPL),Y +Y2K2 LDA (TEMPL),Y STA $0700,Y - DEY + DEY BPL Y2K2 LDA #$D4 ; Point to copyright string STA $0724 @@ -26,8 +26,8 @@ Y2K2 LDA (TEMPL),Y STA $0725 LDX #$0B ; Store NOP's @ end LDA #$EA -Y2K3 STA $0732,X - DEX +Y2K3 STA $0732,X + DEX BPL Y2K3 LDA #$60 ; Store RTS opcode @ end STA $0750 diff --git a/libsrc/atari7800/clock.s b/libsrc/atari7800/clock.s new file mode 100644 index 000000000..03ae1e970 --- /dev/null +++ b/libsrc/atari7800/clock.s @@ -0,0 +1,69 @@ +; +; 2022-03-15, Karri Kaksonen +; +; clock_t clock (void); +; + + .export _clock, clock_count + .interruptor update_clock, 2 ; (low priority) + .constructor init_clock + + .import sreg: zp + .import _zonecounter + .include "atari7800.inc" + + .macpack generic + + .code + +;----------------------------------------------------------------------------- +; Read the clock counter. +; + .proc _clock + + lda #0 + sta sreg+1 ; Promote 24 bits up to 32 bits + lda clock_count+2 + sta sreg + ldx clock_count+1 + lda clock_count + + rts + .endproc + +;----------------------------------------------------------------------------- +; This interrupt handler increments a 24-bit counter at every video +; vertical-blanking time. +; Update the clock only on interrupt while the drawing on screen is on +; _zonecounter == 1 (from 1st visible scanline to last visible scanline) +; +update_clock: + lda _zonecounter + and #01 + beq @L1 + inc clock_count + bne @L1 + inc clock_count+1 + bne @L1 + inc clock_count+2 +@L1: ;clc ; General interrupt was not reset + rts + +;----------------------------------------------------------------------------- +; Set time to zero at startup +; + .segment "ONCE" +init_clock: + lda #0 + sta clock_count+2 + sta clock_count+1 + sta clock_count + rts + +;----------------------------------------------------------------------------- +; Store time in 3 bytes +; + .bss +clock_count: + .res 3 + diff --git a/libsrc/atari7800/clocks_per_sec.s b/libsrc/atari7800/clocks_per_sec.s new file mode 100644 index 000000000..e2c7d9d8d --- /dev/null +++ b/libsrc/atari7800/clocks_per_sec.s @@ -0,0 +1,34 @@ +; +; 2022-03-15, Karri Kaksonen +; +; clock_t _clocks_per_sec (void); +; + + .export __clocks_per_sec + + .import sreg: zp + .import _paldetected + .include "atari7800.inc" + + .macpack generic + + .code + +;----------------------------------------------------------------------------- +; Return the number of clock ticks in one second. +; + .proc __clocks_per_sec + + lda #0 + tax + sta sreg ; return 32 bits + sta sreg+1 + lda _paldetected + bne pal + lda #60 ; NTSC - 60Hz + rts +pal: + lda #50 ; PAL - 50Hz + rts + .endproc + diff --git a/libsrc/atari7800/crt0.s b/libsrc/atari7800/crt0.s new file mode 100644 index 000000000..e791179f3 --- /dev/null +++ b/libsrc/atari7800/crt0.s @@ -0,0 +1,71 @@ + .export _zonecounter + .export __STARTUP__ : absolute = 1 + .export _exit + .import __ROM_START__ + .import __RAM3_START__, __RAM3_SIZE__ + .import initlib, donelib + .import zerobss, copydata + .import IRQStub + .import push0, _main + .include "atari7800.inc" + .include "zeropage.inc" + +INPTCTRL = $01 + + .segment "STARTUP" +start: + ; Startup sequence recommended by Atari. + ; See the 7800 standards document. + sei ; Initialize 6502 + cld + lda #$07 ; Lock machine in 7800 mode + sta INPTCTRL + lda #$7f ; DMA off + sta CTRL + ldx #0 ; OFFSET must always be 0 + stx OFFSET + stx INPTCTRL ; Make sure joysticks don't freeze + dex ; Stack pointer = $ff + txs + + ; Set up parameter stack + lda #<(__RAM3_START__ + __RAM3_SIZE__) + sta sp + lda #>(__RAM3_START__ + __RAM3_SIZE__) + sta sp+1 + + jsr copydata + jsr zerobss + jsr initlib + + ; Call main program (pass empty command line) + jsr push0 ; argc + jsr push0 ; argv + ldy #4 ; Argument size + jsr _main + +_exit: + jsr donelib + jmp start + +NMIHandler: + inc _zonecounter + jmp IRQStub + +IRQHandler: + rti + + .segment "DATA" +_zonecounter: + .byte 0 + + .segment "ENCRYPTION" + .res 126, $ff ; Reserved for encryption +Lfff8: .byte $ff ; Region verification (always $ff) +Lfff9: .byte $f7 ; Use last 4096 bytes only for encryption +;;;Lfff9: .byte <(((__ROM_START__/4096)<<4) | 7) + + .segment "VECTORS" + .word NMIHandler + .word start + .word IRQHandler diff --git a/libsrc/atari7800/ctype.s b/libsrc/atari7800/ctype.s new file mode 100644 index 000000000..1301965eb --- /dev/null +++ b/libsrc/atari7800/ctype.s @@ -0,0 +1,5 @@ +; Character specification table. +; +; uses the "common" definition + + .include "ctype_common.inc" diff --git a/libsrc/atari7800/exehdr.s b/libsrc/atari7800/exehdr.s new file mode 100644 index 000000000..99e62e3d6 --- /dev/null +++ b/libsrc/atari7800/exehdr.s @@ -0,0 +1,46 @@ +; +; Karri Kaksonen, 2022 +; +; This header contains data for emulators +; + .export __EXEHDR__: absolute = 1 + .import __CARTSIZE__ +; ------------------------------------------------------------------------ +; EXE header + .segment "EXEHDR" + .byte 3 ; version + .byte 'A','T','A','R','I','7','8','0','0',' ',' ',' ',' ',' ',' ',' ' + .byte 'G','a','m','e',' ','n','a','m','e',0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,>__CARTSIZE__,0 ; Set the cart size in the cfg file + ; bit 0 - pokey at 4000 + ; bit 1 - supergame bank switched + ; bit 2 - supergame ram at $4000 + ; bit 3 - rom at $4000 + ; bit 4 - bank 6 at $4000 + ; bit 5 - supergame banked ram + ; bit 6 - pokey at $450 + ; bit 7 - mirror ram at $4000 + ; bit 8 - activision banking + ; bit 9 - absolute banking + ; bit 10 - pokey at $440 + ; bit 11 - ym2151 at $461/462 + ; bit 12 - souper + ; bit 13-15 - Special + ; 0 = Normal cart + .byte 0,0 ; 0 = Normal cart + .byte 1 ; 1 = Joystick, 2 = lightgun + .byte 0 ; No joystick 2 + .byte 0 ; bit0 = 0:NTSC,1:PAL bit1 = 0:component,1:composite + .byte 0 ; Save data peripheral - 1 byte (version 2) + ; 0 = None / unknown (default) + ; 1 = High Score Cart (HSC) + ; 2 = SaveKey + + .byte 0 ; 63 Expansion module + ; 0 = No expansion module (default on all currently released games) + ; 1 = Expansion module required + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 + .byte 'A','C','T','U','A','L',' ','C','A','R','T',' ','D','A','T','A',' ','S','T','A','R','T','S',' ','H','E','R','E' diff --git a/libsrc/atari7800/get_tv.s b/libsrc/atari7800/get_tv.s new file mode 100644 index 000000000..12c54f807 --- /dev/null +++ b/libsrc/atari7800/get_tv.s @@ -0,0 +1,65 @@ +; +; Karri Kaksonen, 2022-03-25 +; +; unsigned char get_tv (void) +; + .include "atari7800.inc" + .include "get_tv.inc" + .export _get_tv + .export _paldetected + +.segment "DATA" + +_paldetected: + .byte $FF + +; --------------------------------------------------------------- +; unsigned char get_tv (void) +; --------------------------------------------------------------- + +.segment "CODE" + +.proc _get_tv: near + +.segment "CODE" + + ldx #$00 + lda #$FF + cmp _paldetected + bne L8 +L1: lda MSTAT + and #$80 + bne L1 +L2: lda MSTAT + and #$80 + beq L2 +L3: lda MSTAT + and #$80 + bne L3 + lda #$00 + sta M0001 + jmp L5 +L4: sta MWSYNC + sta MWSYNC + dec M0001 +L5: lda MSTAT + and #$80 + beq L4 + lda M0001 + cmp #$78 + bcc L6 + lda #TV::NTSC + jmp L7 +L6: lda #TV::PAL +L7: sta _paldetected + ldx #$00 +L8: lda _paldetected + rts + +.segment "BSS" + +M0001: + .res 1,$00 + +.endproc + diff --git a/libsrc/atari7800/irq.s b/libsrc/atari7800/irq.s new file mode 100644 index 000000000..3cfc74541 --- /dev/null +++ b/libsrc/atari7800/irq.s @@ -0,0 +1,36 @@ +; +; IRQ handling (Atari 7800 version) +; + + .export initirq, doneirq, IRQStub + + .import __INTERRUPTOR_COUNT__, callirq + + .include "atari7800.inc" + + .code +; ------------------------------------------------------------------------ + +initirq: +doneirq: + rts + +; ------------------------------------------------------------------------ + +IRQStub: + cld ; Just to be sure + pha + lda #<(__INTERRUPTOR_COUNT__ * 2) + beq @L1 + txa + pha + tya + pha + jsr callirq ; Call the functions + pla + tay + pla + tax +@L1: pla + rti + diff --git a/libsrc/atari7800/joy/atari7800-stdjoy.s b/libsrc/atari7800/joy/atari7800-stdjoy.s new file mode 100644 index 000000000..d76e1d105 --- /dev/null +++ b/libsrc/atari7800/joy/atari7800-stdjoy.s @@ -0,0 +1,161 @@ +; +; Standard joystick driver for the Atari 7800. +; This version tries to use 7800 and 2600 joysticks. +; But assumes that both joysticks are of same type. +; +; Modified by Karri Kaksonen, 2022-03-31 +; Ullrich von Bassewitz, 2002-12-20 +; Using code from Steve Schmidtke +; + + .include "zeropage.inc" + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "atari7800.inc" + + .macpack generic + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _atari7800_stdjoy_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READ + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 2 ; Number of joysticks we support + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an JOY_ERR_xx code in a/x. +; + +INSTALL: + ; Assume 7800 2-button controller, can change + ; to 2600 1-button later + lda #$14 + sta CTLSWB ; enable 2-button 7800 controller 1: set pin 6 to output + ldy #$00 + sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high + +reset: + lda #<JOY_ERR_OK + ldx #>JOY_ERR_OK +; rts ; Run into UNINSTALL instead + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A for 2 fire buttons. + +readbuttons: + ; Y has joystick of interest 0/1 + ; return value: + ; $00: no button, + ; $01: left/B button, + ; $02: right/A button, + ; $03: both buttons + ; preserves X + tya + beq L5 + ; Joystick 1 processing + ; 7800 joystick 1 buttons + ldy #0 ; ........ + bit INPT2 ; Check for right button + bpl L1 + ldy #2 ; ......2. +L1: bit INPT3 ;Check for left button + bpl L2 + iny ; ......21 +L2: tya + bne L4 ; 7800 mode joystick worked + ; 2600 Joystick 1 + bit INPT5 + bmi L4 +L3: iny ; .......1 + lda #0 ; Fallback to 2600 joystick mode + sta CTLSWB +L4: tya ; ......21 + rts + +L5: ; Joystick 0 processing + ; 7800 joystick 0 buttons + ldy #0 ; ........ + bit INPT0 ; Check for right button + bpl L6 + ldy #2 ; ......2. +L6: bit INPT1 ;Check for left button + bpl L7 + iny ; ......21 +L7: tya + bne L4 ; 7800 mode joystick worked + ; 2600 Joystick 0 + bit INPT4 + bmi L4 + bpl L3 + +READ: + tay ; Store joystick 0/1 in Y + beq L8 + lda SWCHA ; Read directions of joystick 1 + rol ; ...RLDU. + rol ; ..RLDU.. + rol ; .RLDU... - joystick 1 + jmp L9 +L8: lda SWCHA ; Read directions of joystick 0 + ror ; .RLDU... - joystick 0 +L9: tax + jsr readbuttons ; A = ......21, X = .RLDU... + ror ; A = .......2 1 + tay ; Y = .......2 + txa ; A = .RLDU... + ror ; A = 1.RLDU.. + tax ; X = 1.RLDU.. + tya ; A = .......2 + ror ; A = ........ 2 + txa ; A = 1.RLDU.. + rol ; A = .RLDU..2 1 + rol ; A = RLDU..21 + eor #$F0 ; The direction buttons were inversed + and #$F3 + rts + diff --git a/libsrc/atari7800/joy_stat_stddrv.s b/libsrc/atari7800/joy_stat_stddrv.s new file mode 100644 index 000000000..eafe0d314 --- /dev/null +++ b/libsrc/atari7800/joy_stat_stddrv.s @@ -0,0 +1,14 @@ +; +; Address of the static standard joystick driver +; +; Oliver Schmidt, 2012-11-01 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _atari7800_stdjoy_joy + +.rodata + +_joy_static_stddrv := _atari7800_stdjoy_joy diff --git a/libsrc/atari7800/libref.s b/libsrc/atari7800/libref.s new file mode 100644 index 000000000..e4afa7eb1 --- /dev/null +++ b/libsrc/atari7800/libref.s @@ -0,0 +1,8 @@ +; +; Oliver Schmidt, 2013-05-31 +; + + .export joy_libref + .import _exit + +joy_libref := _exit diff --git a/libsrc/atmos/cclear.s b/libsrc/atmos/cclear.s index 9d356a8ab..f6416363c 100644 --- a/libsrc/atmos/cclear.s +++ b/libsrc/atmos/cclear.s @@ -6,7 +6,7 @@ ; .export _cclearxy, _cclear - .import setscrptr + .import setscrptr .import rvs .import popax .importzp ptr2 @@ -25,7 +25,7 @@ _cclear: tax ; Is the length zero? beq @L9 ; Jump if done jsr setscrptr ; Set ptr2 to screen, won't use X - lda #' ' + lda #' ' ora rvs @L1: sta (ptr2),y ; Write one char iny ; Next char diff --git a/libsrc/atmos/ctype.s b/libsrc/atmos/ctype.s index 90a3baa6e..57ad8c1a3 100644 --- a/libsrc/atmos/ctype.s +++ b/libsrc/atmos/ctype.s @@ -119,7 +119,7 @@ __ctypeidx: ct_mix CT_NONE_IDX, CT_NONE_IDX ; 186/ba ___________, 187/bb ___________ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 188/bc ___________, 189/bd ___________ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 190/be ___________, 191/bf ___________ - + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 192/c0 ___________, 193/c1 ___________ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 194/c2 ___________, 195/c3 ___________ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 196/c4 ___________, 197/c5 ___________ diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s index 3ded00d67..84e7cb695 100644 --- a/libsrc/c128/emd/c128-reu.s +++ b/libsrc/c128/emd/c128-reu.s @@ -72,7 +72,7 @@ reu_params: .word $0000 ; Host address, lo, hi .byte $00 ; Expansion bank no. .word $0000 ; # bytes to move, lo, hi .byte $00 ; Interrupt mask reg. - .byte $00 ; Adress control reg. + .byte $00 ; Address control reg. .code diff --git a/libsrc/c128/emd/c128-vdc.s b/libsrc/c128/emd/c128-vdc.s index e294ddc18..accb82154 100644 --- a/libsrc/c128/emd/c128-vdc.s +++ b/libsrc/c128/emd/c128-vdc.s @@ -73,7 +73,7 @@ INSTALL: lda #$ff sta curpage sta curpage+1 - + ; do test for VDC presence here??? ldx #VDC_CSET ; determine size of RAM... jsr vdcgetreg @@ -97,29 +97,29 @@ INSTALL: jsr vdcputbyte ; restore original value of test byte ldx #0 ; prepare x with hi of default pagecount - + lda ptr1 ; do bytes match? cmp ptr1+1 bne @have64k lda ptr2 cmp ptr2+1 bne @have64k - + lda #64 ; assumes x = 0, here -> p.c = 64 bne @setpagecnt -@have64k: +@have64k: txa ; assumes x = 0, here inx ; so that a/x becomes 0/1 -> p.c. = 256 -@setpagecnt: +@setpagecnt: sta pagecount stx pagecount+1 txa - bne @keep64kBit - + bne @keep64kBit + ldx #VDC_CSET ; restore 16/64k flag - lda vdc_cset_save - jsr vdcputreg + lda vdc_cset_save + jsr vdcputreg @keep64kBit: lda #<EM_ERR_OK ldx #>EM_ERR_OK diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s index a563305ce..07ac1fbed 100644 --- a/libsrc/c64/emd/c64-reu.s +++ b/libsrc/c64/emd/c64-reu.s @@ -73,7 +73,7 @@ reu_params: .word $0000 ; Host address, lo, hi .byte $00 ; Expansion bank no. .word $0000 ; # bytes to move, lo, hi .byte $00 ; Interrupt mask reg. - .byte $00 ; Adress control reg. + .byte $00 ; Address control reg. .code diff --git a/libsrc/c64/sysuname.s b/libsrc/c64/sysuname.s index 2d185a1c8..1903986c9 100644 --- a/libsrc/c64/sysuname.s +++ b/libsrc/c64/sysuname.s @@ -12,7 +12,7 @@ ;-------------------------------------------------------------------------- ; Data. We define a fixed utsname struct here and just copy it. - + .rodata utsdata: diff --git a/libsrc/cbm/cbm_save.c b/libsrc/cbm/cbm_save.c index 7f774b1b6..2e22b89fc 100644 --- a/libsrc/cbm/cbm_save.c +++ b/libsrc/cbm/cbm_save.c @@ -12,9 +12,9 @@ /* saves a memory area from start to end-1 to a file. */ -unsigned char __fastcall__ cbm_save (const char* name, +unsigned char __fastcall__ cbm_save (const char* name, unsigned char device, - const void* data, + const void* data, unsigned int size) { cbm_k_setlfs(0, device, 0); diff --git a/libsrc/cbm/ctype.s b/libsrc/cbm/ctype.s index 7388f68b8..a66905fe7 100644 --- a/libsrc/cbm/ctype.s +++ b/libsrc/cbm/ctype.s @@ -13,7 +13,7 @@ .include "ctypetable.inc" .export __ctypeidx - + ; The tables are readonly, put them into the rodata segment .rodata diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s index 317f9eaa2..e9f0237cc 100644 --- a/libsrc/cbm/open.s +++ b/libsrc/cbm/open.s @@ -130,7 +130,7 @@ dowrite: beq notrunc jsr scratch -; Complete the the file name. Check for append mode here. +; Complete the file name. Check for append mode here. notrunc: lda tmp3 ; Get the mode again @@ -168,7 +168,7 @@ nofile: ; ... else use SA=0 (read) jsr OPEN bcs oserror -; Open the the drive command channel and read it +; Open the drive command channel and read it ldx fnunit jsr opencmdchannel diff --git a/libsrc/cbm/opendir.c b/libsrc/cbm/opendir.c index b39e6b77e..87b9ab73d 100644 --- a/libsrc/cbm/opendir.c +++ b/libsrc/cbm/opendir.c @@ -38,7 +38,7 @@ DIR* __fastcall__ opendir (register const char* name) d.fd = open (d.name, O_RDONLY); if (d.fd >= 0) { - /* Skip the load address */ + /* Skip the load address */ if (_dirread (&d, buf, sizeof (buf))) { /* Allocate memory for the DIR structure returned */ diff --git a/libsrc/cbm610/revers.s b/libsrc/cbm610/revers.s index eb44f0282..78b8a0591 100644 --- a/libsrc/cbm610/revers.s +++ b/libsrc/cbm610/revers.s @@ -9,7 +9,7 @@ .import RVS: zp .include "cbm610.inc" - + .proc _revers diff --git a/libsrc/common/_heap.s b/libsrc/common/_heap.s index e2470577a..4ec8c80cd 100644 --- a/libsrc/common/_heap.s +++ b/libsrc/common/_heap.s @@ -39,4 +39,4 @@ initheap: sta __heapend+1 rts - + diff --git a/libsrc/common/_heapmaxavail.s b/libsrc/common/_heapmaxavail.s index 4d44fadc1..19ae18b8d 100644 --- a/libsrc/common/_heapmaxavail.s +++ b/libsrc/common/_heapmaxavail.s @@ -6,7 +6,7 @@ ; size_t _heapmaxavail (void); ; ; - + .importzp ptr1, ptr2 .export __heapmaxavail diff --git a/libsrc/common/_longminstr.c b/libsrc/common/_longminstr.c index ffc35aa77..28a19f39b 100644 --- a/libsrc/common/_longminstr.c +++ b/libsrc/common/_longminstr.c @@ -1,9 +1,9 @@ /* ** Ullrich von Bassewitz, 2012-11-26 ** -** Minimum value of a long. Is used in ascii conversions, since this value +** Minimum value of a long. Is used in ascii conversions, since this value ** has no positive counterpart than can be represented in 32 bits. In C, -** since the compiler will convert to the correct character set for the +** since the compiler will convert to the correct character set for the ** target platform. */ diff --git a/libsrc/common/_seterrno.s b/libsrc/common/_seterrno.s index e35c0b342..79021143a 100644 --- a/libsrc/common/_seterrno.s +++ b/libsrc/common/_seterrno.s @@ -2,7 +2,7 @@ ; Ullrich von Bassewitz, 2004-05-13 ; ; __seterrno: Will set __errno to the value in A and return zero in A. Other -; registers aren't changed. The function is C callable, but +; registers aren't changed. The function is C callable, but ; currently only called from asm code. ; diff --git a/libsrc/common/abort.c b/libsrc/common/abort.c index 1dda559bb..1100d33a3 100644 --- a/libsrc/common/abort.c +++ b/libsrc/common/abort.c @@ -7,7 +7,7 @@ #include <stdio.h> -#include <stdlib.h> +#include <stdlib.h> #include <signal.h> diff --git a/libsrc/common/ctypemask.s b/libsrc/common/ctypemask.s index b518a10c0..9238f24e9 100644 --- a/libsrc/common/ctypemask.s +++ b/libsrc/common/ctypemask.s @@ -9,7 +9,7 @@ ; ; ctypemask(int c) ; -; converts a character to test via the is*-functions to the matching ctype-masks +; converts a character to test via the is*-functions to the matching ctype-masks ; If c is out of the 8-bit range, the function returns with carry set and accu cleared. ; Return value is in accu and x has to be always clear when returning ; (makes calling code shorter)! diff --git a/libsrc/common/divt.s b/libsrc/common/divt.s index 914eb569d..7f2b4e1bb 100644 --- a/libsrc/common/divt.s +++ b/libsrc/common/divt.s @@ -18,10 +18,10 @@ .importzp sreg, ptr1, tmp1 _div: jsr tosdivax ; Division-operator does most of the work - + ldy sreg ; low byte remainder from sreg sta sreg ; store low byte quotient to sreg - + lda sreg+1 ; high byte remainder from sreg stx sreg+1 ; store high byte quotient to sreg diff --git a/libsrc/common/doesclrscr.s b/libsrc/common/doesclrscr.s index 49ce2fd12..14d9ab804 100644 --- a/libsrc/common/doesclrscr.s +++ b/libsrc/common/doesclrscr.s @@ -7,6 +7,6 @@ ; .export _doesclrscrafterexit - .import return0 + .import return0 _doesclrscrafterexit = return0 diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index 91d692985..c0733994e 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -161,7 +161,7 @@ bne @L8 ; Error in read. Set the stream error flag and bail out. errno has already -; been set by read(). On entry to label @L7, X must be zero. +; been set by read(). On entry to label @L7, X must be zero. inx ; X = 0 lda #_FERROR diff --git a/libsrc/common/free.s b/libsrc/common/free.s index 00b5e63f8..53796303c 100644 --- a/libsrc/common/free.s +++ b/libsrc/common/free.s @@ -274,7 +274,7 @@ _free: sta ptr2 ; } ; } ; -; +; ; On entry, ptr2 must contain a pointer to the block, which must be at least ; HEAP_MIN_BLOCKSIZE bytes in size, and ptr1 contains the total size of the ; block. diff --git a/libsrc/common/freopen.c b/libsrc/common/freopen.c index d79d3cf15..41b0b094b 100644 --- a/libsrc/common/freopen.c +++ b/libsrc/common/freopen.c @@ -31,7 +31,7 @@ FILE* __fastcall__ freopen (const char* name, const char* mode, FILE* f) ** overwritten by _fopen. */ if (close (f->f_fd) < 0) { - /* An error occured, errno is already set */ + /* An error occurred, errno is already set */ return 0; } diff --git a/libsrc/common/fsetpos.c b/libsrc/common/fsetpos.c index 14690f520..a0cf8d31f 100644 --- a/libsrc/common/fsetpos.c +++ b/libsrc/common/fsetpos.c @@ -21,4 +21,4 @@ int __fastcall__ fsetpos (FILE* f, const fpos_t *pos) return fseek (f, (fpos_t)*pos, SEEK_SET); } - + diff --git a/libsrc/common/fwrite.s b/libsrc/common/fwrite.s index dc0bad1b6..b0fa7ec42 100644 --- a/libsrc/common/fwrite.s +++ b/libsrc/common/fwrite.s @@ -19,7 +19,7 @@ ; ------------------------------------------------------------------------ ; Code - + .proc _fwrite ; Save file and place it into ptr1 diff --git a/libsrc/common/getcwd.s b/libsrc/common/getcwd.s index 4bfc0a5b6..9b856ea7c 100644 --- a/libsrc/common/getcwd.s +++ b/libsrc/common/getcwd.s @@ -53,7 +53,7 @@ overflow: lda #<ERANGE jsr __seterrno ; Returns 0 in A tax ; Return zero - rts + rts ; Success, return buf diff --git a/libsrc/common/itoa.s b/libsrc/common/itoa.s index 176bc2ddd..808f9bc33 100644 --- a/libsrc/common/itoa.s +++ b/libsrc/common/itoa.s @@ -19,7 +19,7 @@ specval: ; Common subroutine to pop the parameters and put them into core ; -dopop: sta tmp1 ; will loose high byte +dopop: sta tmp1 ; will lose high byte ldy #0 lda (sp),y sta ptr2 diff --git a/libsrc/common/ltoa.s b/libsrc/common/ltoa.s index 54b693ecc..78e43e23f 100644 --- a/libsrc/common/ltoa.s +++ b/libsrc/common/ltoa.s @@ -18,7 +18,7 @@ ; Common subroutine to pop the parameters and put them into core ; -dopop: sta tmp1 ; will loose high byte +dopop: sta tmp1 ; will lose high byte jsr popax ; get s to ptr2 sta ptr2 stx ptr2+1 @@ -56,7 +56,7 @@ L1: lda __longminstr,y ; copy -2147483648 dey bpl L1 jmp L10 - + ; Check if the value is negative. If so, write a - sign and negate the ; number. @@ -66,7 +66,7 @@ L2: txa ; get high byte .if (.cpu .bitand CPU_ISET_65SC02) sta (ptr2) -.else +.else ldy #0 sta (ptr2),y ; store sign .endif @@ -79,7 +79,7 @@ L3: lda ptr1 ; negate val ldx ptr1+1 jsr negeax - + sta ptr1 stx ptr1+1 jmp ultoa diff --git a/libsrc/common/memcpy.s b/libsrc/common/memcpy.s index 1ee53be07..fd090c788 100644 --- a/libsrc/common/memcpy.s +++ b/libsrc/common/memcpy.s @@ -67,7 +67,7 @@ memcpy_getparams: ; IMPORTANT! Function has to leave with Y=0! jsr popptr1 ; save src to ptr1 ; save dest to ptr2 - iny ; Y=0 guaranteed by popptr1, we need '1' here... + iny ; Y=0 guaranteed by popptr1, we need '1' here... ; (direct stack access is three cycles faster ; (total cycle count with return)) lda (sp),y diff --git a/libsrc/common/memset.s b/libsrc/common/memset.s index 96f5d9e11..a57a90e5c 100644 --- a/libsrc/common/memset.s +++ b/libsrc/common/memset.s @@ -87,7 +87,7 @@ L3: dey sta (ptr1),y ; set bytes in low sta (ptr2),y ; and high section bne L3 ; flags still up to date from dey! -leave: +leave: jmp popax ; Pop ptr and return as result - + diff --git a/libsrc/common/mul20.s b/libsrc/common/mul20.s index 5b3bbf830..ba29b94dd 100644 --- a/libsrc/common/mul20.s +++ b/libsrc/common/mul20.s @@ -9,7 +9,7 @@ ; ; ; unsigned int __fastcall__ mul20(unsigned char value); -; +; ; REMARKS: Function is defined to return with carry-flag cleared @@ -34,7 +34,7 @@ mul5: adc tmp4 ; * 5 inx ; yes, correct... mul10: stx tmp4 ; continue with classic shifting... - + asl a ; * 10 rol tmp4 diff --git a/libsrc/common/mul40.s b/libsrc/common/mul40.s index 07d6164b5..06780a6e0 100644 --- a/libsrc/common/mul40.s +++ b/libsrc/common/mul40.s @@ -9,7 +9,7 @@ ; ; ; unsigned int __fastcall__ mul40(unsigned char value); -; +; ; REMARKS: Function is defined to return with carry-flag cleared @@ -34,7 +34,7 @@ mul5: adc tmp4 ; * 5 inx ; yes, correct... mul10: stx tmp4 ; continue with classic shifting... - + asl a ; * 10 rol tmp4 diff --git a/libsrc/common/putenv.s b/libsrc/common/putenv.s index 7e44a7cd8..c68d20a32 100644 --- a/libsrc/common/putenv.s +++ b/libsrc/common/putenv.s @@ -185,4 +185,4 @@ error: jsr __seterrno name: .addr 0 ; Pointer to name newsize: .byte 0 ; New environment size - + diff --git a/libsrc/common/raise.s b/libsrc/common/raise.s index db96cdcd0..07898ef90 100644 --- a/libsrc/common/raise.s +++ b/libsrc/common/raise.s @@ -28,9 +28,9 @@ _raise: sta jmpvec+1 lda sigtable+1,x sta jmpvec+2 - + ; Reset the signal handler to SIG_DFL (I don't like this because it may -; introduce race conditions, but it's the simplest way to satisfy the +; introduce race conditions, but it's the simplest way to satisfy the ; standard). lda #<__sig_dfl @@ -51,4 +51,4 @@ _raise: invalidsig: rts - + diff --git a/libsrc/common/rewind.c b/libsrc/common/rewind.c index a4cdfa97c..333230b74 100644 --- a/libsrc/common/rewind.c +++ b/libsrc/common/rewind.c @@ -22,4 +22,4 @@ void __fastcall__ rewind (FILE* f) clearerr(f); } - + diff --git a/libsrc/common/strcspn.s b/libsrc/common/strcspn.s index 9cf159218..4bb01479a 100644 --- a/libsrc/common/strcspn.s +++ b/libsrc/common/strcspn.s @@ -20,7 +20,7 @@ _strcspn: sta tmp1 ; tmp1 = strlen of test chars jsr popptr1 ; get and save s1 to ptr1 - + ldx #0 ; low counter byte stx tmp2 ; high counter byte diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index 060378442..75572db7c 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -9,19 +9,19 @@ .import popax, popptr1 .importzp ptr1, ptr2, ptr3, tmp1, tmp2 .macpack cpu - + _strncat: inx stx tmp2 tax inx stx tmp1 ; save count with each byte incremented separately - + jsr popptr1 ; get src jsr popax ; get dest sta ptr3 ; remember for function return - stx ptr3+1 + stx ptr3+1 stx ptr2+1 tay ; low byte as offset in Y .if (.cpu .bitand ::CPU_ISET_65SC02) diff --git a/libsrc/common/strrchr.s b/libsrc/common/strrchr.s index 3e4fb0810..2858337b5 100644 --- a/libsrc/common/strrchr.s +++ b/libsrc/common/strrchr.s @@ -16,8 +16,8 @@ _strrchr: stx ptr1+1 ldx #0 ; default function result is NULL, X is high byte... stx tmp2 ; tmp2 is low-byte - stx ptr1 ; low-byte of source string is in Y, so clear real one... - + stx ptr1 ; low-byte of source string is in Y, so clear real one... + testChar: lda (ptr1),y ; get char beq finished ; jump if end of string diff --git a/libsrc/common/ungetc.s b/libsrc/common/ungetc.s index 386c450a8..88595068c 100644 --- a/libsrc/common/ungetc.s +++ b/libsrc/common/ungetc.s @@ -68,4 +68,4 @@ error: lda #EINVAL rts .endproc - + diff --git a/libsrc/common/vsprintf.s b/libsrc/common/vsprintf.s index eb47dae18..b4cb9c419 100644 --- a/libsrc/common/vsprintf.s +++ b/libsrc/common/vsprintf.s @@ -30,7 +30,7 @@ _vsprintf: ldy #2 jsr staxysp -; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will +; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will ; cleanup the C stack jmp vsnprintf diff --git a/libsrc/conio/cputs.s b/libsrc/conio/cputs.s index ef7c65462..41191a0b0 100644 --- a/libsrc/conio/cputs.s +++ b/libsrc/conio/cputs.s @@ -8,7 +8,7 @@ .export _cputsxy, _cputs .import gotoxy, _cputc .importzp ptr1, tmp1 - + _cputsxy: sta ptr1 ; Save s for later stx ptr1+1 diff --git a/libsrc/conio/scrsize.s b/libsrc/conio/scrsize.s index 014b6f08b..834c14820 100644 --- a/libsrc/conio/scrsize.s +++ b/libsrc/conio/scrsize.s @@ -10,7 +10,7 @@ .import screensize .importzp ptr1, ptr2 - .macpack cpu + .macpack cpu .proc _screensize @@ -29,7 +29,7 @@ sta (ptr2),y txa sta (ptr1),y -.endif +.endif rts .endproc diff --git a/libsrc/creativision/_scrsize.s b/libsrc/creativision/_scrsize.s index 9e4ce53c7..b1b05efea 100644 --- a/libsrc/creativision/_scrsize.s +++ b/libsrc/creativision/_scrsize.s @@ -3,13 +3,13 @@ ;* .export screensize - + .include "creativision.inc" - + .proc screensize ldx #SCREEN_COLS ldy #SCREEN_ROWS rts - + .endproc diff --git a/libsrc/creativision/boxchars.inc b/libsrc/creativision/boxchars.inc index 45484a5d2..5fbb3409d 100644 --- a/libsrc/creativision/boxchars.inc +++ b/libsrc/creativision/boxchars.inc @@ -2,7 +2,7 @@ boxchars: ; Vertical Line - .byte $18 + .byte $18 .byte $18 .byte $18 .byte $18 @@ -29,7 +29,7 @@ boxchars: .byte $18 .byte $18 .byte $18 - .byte $18 + .byte $18 ; Top Right .byte $00 @@ -39,7 +39,7 @@ boxchars: .byte $18 .byte $18 .byte $18 - .byte $18 + .byte $18 ; Bottom Left .byte $18 @@ -49,7 +49,7 @@ boxchars: .byte $00 .byte $00 .byte $00 - .byte $00 + .byte $00 ; Bottom Right .byte $18 @@ -59,4 +59,4 @@ boxchars: .byte $00 .byte $00 .byte $00 - .byte $00 + .byte $00 diff --git a/libsrc/cx16/cpeeks.s b/libsrc/cx16/cpeeks.s index e69de29bb..281cbd75d 100644 --- a/libsrc/cx16/cpeeks.s +++ b/libsrc/cx16/cpeeks.s @@ -0,0 +1 @@ +; empty file to prevent cbm/cpeeks.s being pulled into the cx16 lib diff --git a/libsrc/dbg/asmtab.s b/libsrc/dbg/asmtab.s index 3d27aea1f..fdeedaa48 100644 --- a/libsrc/dbg/asmtab.s +++ b/libsrc/dbg/asmtab.s @@ -57,5 +57,5 @@ MnemoTab2: .byte $C4,$CA,$26,$48,$44,$44,$A2,$C8 - + diff --git a/libsrc/dbg/dbg.c b/libsrc/dbg/dbg.c index 27f2086eb..832ed0a20 100644 --- a/libsrc/dbg/dbg.c +++ b/libsrc/dbg/dbg.c @@ -1579,12 +1579,12 @@ void DbgEntry (void) case 'q': /* Quit program */ clrscr (); - + /* Exit intentionally with error because one may - ** say that DbgEntry is always abnormal. + ** say that DbgEntry is always abnormal. */ exit (EXIT_FAILURE); - + } } } diff --git a/libsrc/dbg/dbgdasm.s b/libsrc/dbg/dbgdasm.s index 9899c0add..cd1287a8a 100644 --- a/libsrc/dbg/dbgdasm.s +++ b/libsrc/dbg/dbgdasm.s @@ -77,7 +77,7 @@ disassret: inx ; Adjust for opcode byte txa ldx #$00 ; Clear high byte - rts + rts ; ------------------------------------------------------------------------- ; Helper functions diff --git a/libsrc/dbg/dbgsupp.s b/libsrc/dbg/dbgsupp.s index 07ab9e25a..b1f122013 100644 --- a/libsrc/dbg/dbgsupp.s +++ b/libsrc/dbg/dbgsupp.s @@ -58,7 +58,7 @@ DbgBreak: .res 256 DbgStack: -; Swap space for the the C temporaries +; Swap space for the C temporaries CTemp: _DbgCS: .res 2 ; sp diff --git a/libsrc/em/em_load.s b/libsrc/em/em_load.s index 1e4a364e2..39abbc8a5 100644 --- a/libsrc/em/em_load.s +++ b/libsrc/em/em_load.s @@ -29,7 +29,7 @@ ctrl: .addr _read .res 2 ; MODULE .res 2 ; MODULE_SIZE .res 2 ; MODULE_ID - + ;---------------------------------------------------------------------------- ; Code diff --git a/libsrc/gamate/cputc.s b/libsrc/gamate/cputc.s index 84742cb9d..a5d591d1e 100644 --- a/libsrc/gamate/cputc.s +++ b/libsrc/gamate/cputc.s @@ -89,16 +89,17 @@ putchar: adc #>(fontdata-$f8) sta ptr3+1 - lda CHARCOLOR - and #1 - beq @skip_plane1 - lda #LCD_XPOS_PLANE1 clc adc CURS_X sta LCD_X - ldy #$f8 + ldy #$F8 + + lda CHARCOLOR + lsr + bcc @delete1 + @copylp1: lda (ptr3),y eor RVS @@ -106,11 +107,16 @@ putchar: iny bne @copylp1 -@skip_plane1: + beq @skip_delete1 - lda CHARCOLOR - and #2 - beq @skip_plane2 +@delete1: + lda #$00 +@del1: + sta LCD_DATA + iny + bne @del1 + +@skip_delete1: lda #LCD_XPOS_PLANE2 clc @@ -121,7 +127,12 @@ putchar: lda _plotlo,x sta LCD_Y - ldy #$f8 + ldy #$F8 + + lda CHARCOLOR + and #2 + beq @delete2 + @copylp2: lda (ptr3),y eor RVS @@ -129,7 +140,16 @@ putchar: iny bne @copylp2 -@skip_plane2: + beq @skip_delete2 + +@delete2: + lda #$00 +@del2: + sta LCD_DATA + iny + bne @del2 + +@skip_delete2: pla tax ldy CURS_X diff --git a/libsrc/geos-apple/disk/exitturbo.s b/libsrc/geos-apple/disk/exitturbo.s index 7098a56c4..14164d2e9 100644 --- a/libsrc/geos-apple/disk/exitturbo.s +++ b/libsrc/geos-apple/disk/exitturbo.s @@ -9,5 +9,5 @@ .import return0 _ExitTurbo = return0 - - + + diff --git a/libsrc/geos-cbm/disk/changediskdevice.s b/libsrc/geos-cbm/disk/changediskdevice.s index c3035deee..dd9c91609 100644 --- a/libsrc/geos-cbm/disk/changediskdevice.s +++ b/libsrc/geos-cbm/disk/changediskdevice.s @@ -9,7 +9,7 @@ .import setoserror .include "jumptab.inc" - + _ChangeDiskDevice: jsr ChangeDiskDevice jmp setoserror diff --git a/libsrc/geos-cbm/disk/chkdkgeos.s b/libsrc/geos-cbm/disk/chkdkgeos.s index c2b4821a4..a091916d7 100644 --- a/libsrc/geos-cbm/disk/chkdkgeos.s +++ b/libsrc/geos-cbm/disk/chkdkgeos.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _ChkDkGEOS: jsr ChkDkGEOS jsr setoserror diff --git a/libsrc/geos-cbm/disk/dio_cts.s b/libsrc/geos-cbm/disk/dio_cts.s index 043e1f8d8..478181b69 100644 --- a/libsrc/geos-cbm/disk/dio_cts.s +++ b/libsrc/geos-cbm/disk/dio_cts.s @@ -20,21 +20,21 @@ _dio_phys_to_log: sta ptr1 stx ptr1+1 ; pointer to result - + jsr popax sta ptr2 stx ptr2+1 ; pointer to input structure - + jsr popax sta ptr3 stx ptr3+1 ; pointer to handle - + ldy #sst_flag lda (ptr3),y and #128 beq _inv_hand ; handle not open or invalid - - + + ldy #diopp_head lda (ptr2),y bne _inv_data ; there is only head 0 @@ -66,7 +66,7 @@ _dio_phys_to_log: beq dio_cts1571 cmp #DRV_1581 beq dio_cts1581 - + lda #INCOMPATIBLE ; unsupported device ldx #0 beq ret @@ -78,10 +78,10 @@ dio_ctsend: dey lda tmp1 sta (ptr1),y - + ldx #0 txa -ret: +ret: sta __oserror rts ; return success diff --git a/libsrc/geos-cbm/disk/dio_openclose.s b/libsrc/geos-cbm/disk/dio_openclose.s index 72e3e32e9..327503017 100644 --- a/libsrc/geos-cbm/disk/dio_openclose.s +++ b/libsrc/geos-cbm/disk/dio_openclose.s @@ -45,7 +45,7 @@ _dio_open: asl a ; make index from drive id asl a tax - + lda #0 sta sectsizetab+sst_sectsize,x lda #128 @@ -54,7 +54,7 @@ _dio_open: sta sectsizetab+sst_sectsize+1,x tya sta sectsizetab+sst_driveno,x - + stx tmp1 lda #<sectsizetab clc diff --git a/libsrc/geos-cbm/disk/dio_stc.s b/libsrc/geos-cbm/disk/dio_stc.s index 7398edb63..469df93ca 100644 --- a/libsrc/geos-cbm/disk/dio_stc.s +++ b/libsrc/geos-cbm/disk/dio_stc.s @@ -20,15 +20,15 @@ _dio_log_to_phys: ; check device type sta ptr1 stx ptr1+1 ; pointer to result (struct dio_phys_pos) - + jsr popax sta ptr2 stx ptr2+1 ; pointer to input structure (pointer to int) - + jsr popax sta ptr3 stx ptr3+1 ; pointer to handle - + ldy #sst_flag lda (ptr3),y and #128 @@ -42,18 +42,18 @@ _dio_log_to_phys: sta (ptr1),y ; track <256 ldy #diopp_sector+1 sta (ptr1),y ; sector <256 - + ldy #0 lda (ptr2),y sta tmp1 - iny + iny lda (ptr2),y sta tmp2 ; get drive info ldy #sst_driveno lda (ptr3),y - tay + tay lda driveType,y and #%00001111 ; remove ramDisk flags cmp #DRV_1541 @@ -62,7 +62,7 @@ _dio_log_to_phys: beq dio_stc1571 cmp #DRV_1581 beq dio_stc1581 - + lda #INCOMPATIBLE ; unsupported device ldx #0 beq _ret @@ -74,10 +74,10 @@ dio_stcend: ldy #diopp_sector lda tmp2 sta (ptr1),y - + ldx #0 - txa -_ret: + txa +_ret: sta __oserror rts ; return success @@ -107,14 +107,14 @@ _nxt: bcc _found cpx #35 bne _loop41 beq _inv_data - -_found: + +_found: lda tmp1 - sec + sec sbc sectab_1541_l,x sta tmp2 -_fndend: - inx +_fndend: + inx stx tmp1 jmp dio_stcend @@ -128,9 +128,9 @@ dio_stc1571: lda tmp1 cmp #<683 _if71: bcc dio_stc1541 - + lda tmp1 - sec + sec sbc #<683 sta tmp1 lda tmp2 @@ -139,10 +139,10 @@ _if71: bcc dio_stc1541 jsr dio_stc1541 ; will fall through here tay bne _ret ; result beyond track 70 - + ldy #diopp_track lda (ptr1),y - clc + clc adc #35 sta (ptr1),y lda #0 @@ -153,26 +153,26 @@ _if71: bcc dio_stc1541 ; - the remainder is sector dio_stc1581: ldx #0 ; index=(track-1) -_loop81: +_loop81: lda tmp2 bne _sub81 lda tmp1 cmp #40 bcc _got81 _sub81: lda tmp1 - sec + sec sbc #40 sta tmp1 lda tmp2 sbc #0 sta tmp2 - inx + inx cpx #80 bne _loop81 beq _inv_data - + _got81: lda tmp1 sta tmp2 - inx + inx stx tmp1 jmp dio_stcend diff --git a/libsrc/geos-cbm/disk/enterturbo.s b/libsrc/geos-cbm/disk/enterturbo.s index 777822bae..31864e32f 100644 --- a/libsrc/geos-cbm/disk/enterturbo.s +++ b/libsrc/geos-cbm/disk/enterturbo.s @@ -8,5 +8,5 @@ .export _EnterTurbo .include "jumptab.inc" - + _EnterTurbo = EnterTurbo diff --git a/libsrc/geos-cbm/disk/exitturbo.s b/libsrc/geos-cbm/disk/exitturbo.s index ab894aeff..5a37b4682 100644 --- a/libsrc/geos-cbm/disk/exitturbo.s +++ b/libsrc/geos-cbm/disk/exitturbo.s @@ -8,5 +8,5 @@ .export _ExitTurbo .include "jumptab.inc" - + _ExitTurbo = ExitTurbo diff --git a/libsrc/geos-cbm/disk/findbambit.s b/libsrc/geos-cbm/disk/findbambit.s index 3bb566f4d..3a6ffab21 100644 --- a/libsrc/geos-cbm/disk/findbambit.s +++ b/libsrc/geos-cbm/disk/findbambit.s @@ -12,7 +12,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _FindBAMBit: jsr gettrse sta r6L diff --git a/libsrc/geos-cbm/disk/newdisk.s b/libsrc/geos-cbm/disk/newdisk.s index 30c7283ae..99e39604f 100644 --- a/libsrc/geos-cbm/disk/newdisk.s +++ b/libsrc/geos-cbm/disk/newdisk.s @@ -9,7 +9,7 @@ .import setoserror .include "jumptab.inc" - + _NewDisk: jsr NewDisk jmp setoserror diff --git a/libsrc/geos-cbm/disk/purgeturbo.s b/libsrc/geos-cbm/disk/purgeturbo.s index f0a293423..26b61a4fd 100644 --- a/libsrc/geos-cbm/disk/purgeturbo.s +++ b/libsrc/geos-cbm/disk/purgeturbo.s @@ -8,5 +8,5 @@ .export _PurgeTurbo .include "jumptab.inc" - + _PurgeTurbo = PurgeTurbo diff --git a/libsrc/geos-cbm/disk/readblock.s b/libsrc/geos-cbm/disk/readblock.s index 977860d91..d9a25f254 100644 --- a/libsrc/geos-cbm/disk/readblock.s +++ b/libsrc/geos-cbm/disk/readblock.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _ReadBlock: sta r4L stx r4H diff --git a/libsrc/geos-cbm/disk/readbuff.s b/libsrc/geos-cbm/disk/readbuff.s index 149eae1b9..0c0c90108 100644 --- a/libsrc/geos-cbm/disk/readbuff.s +++ b/libsrc/geos-cbm/disk/readbuff.s @@ -11,7 +11,7 @@ .include "diskdrv.inc" .include "geossym.inc" - + _ReadBuff: jsr gettrse sta r1L diff --git a/libsrc/geos-cbm/disk/verwriteblock.s b/libsrc/geos-cbm/disk/verwriteblock.s index 74243f13f..bb4eabdda 100644 --- a/libsrc/geos-cbm/disk/verwriteblock.s +++ b/libsrc/geos-cbm/disk/verwriteblock.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _VerWriteBlock: sta r4L stx r4H diff --git a/libsrc/geos-cbm/disk/writeblock.s b/libsrc/geos-cbm/disk/writeblock.s index c5a3b3f7a..7b257e79c 100644 --- a/libsrc/geos-cbm/disk/writeblock.s +++ b/libsrc/geos-cbm/disk/writeblock.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _WriteBlock: sta r4L stx r4H diff --git a/libsrc/geos-cbm/disk/writebuff.s b/libsrc/geos-cbm/disk/writebuff.s index 34e7b137b..52194ebb1 100644 --- a/libsrc/geos-cbm/disk/writebuff.s +++ b/libsrc/geos-cbm/disk/writebuff.s @@ -11,7 +11,7 @@ .include "diskdrv.inc" .include "geossym.inc" - + _WriteBuff: jsr gettrse sta r1L diff --git a/libsrc/geos-cbm/emd/geos-vdc.s b/libsrc/geos-cbm/emd/geos-vdc.s index 791d2a0a8..27316e1a0 100644 --- a/libsrc/geos-cbm/emd/geos-vdc.s +++ b/libsrc/geos-cbm/emd/geos-vdc.s @@ -82,54 +82,54 @@ INSTALL: pha lda #$35 sta $01 - + ldx #VDC_CSET ; determine size of RAM... jsr vdcgetreg sta tmp1 ora #%00010000 jsr vdcputreg ; turn on 64k - + jsr settestadr1 ; save original value of test byte jsr vdcgetbyte sta tmp2 - + lda #$55 ; write $55 here ldy #ptr1 jsr test64k ; read it here and there lda #$aa ; write $aa here ldy #ptr2 jsr test64k ; read it here and there - + jsr settestadr1 lda tmp2 jsr vdcputbyte ; restore original value of test byte - + lda ptr1 ; do bytes match? cmp ptr1+1 bne @have64k lda ptr2 cmp ptr2+1 bne @have64k - + ldx #VDC_CSET lda tmp1 jsr vdcputreg ; restore 16/64k flag jmp @endok ; and leave default values for 16k - -@have64k: + +@have64k: lda #<256 ldx #>256 sta pagecount stx pagecount+1 -@endok: +@endok: pla sta $01 plp lda #<EM_ERR_OK ldx #>EM_ERR_OK - rts - -test64k: + rts + +test64k: sta tmp1 sty ptr3 lda #0 @@ -186,14 +186,14 @@ MAP: sta curpage sta ptr1+1 ldy #0 sty ptr1 - + lda #<window sta ptr2 lda #>window sta ptr2+1 - + jsr transferin - + lda #<window ldx #>window rts @@ -299,7 +299,7 @@ COPYFROM: bne @L1 ; Copy the remainder of the page - + @L2: ldy #EM_COPY::COUNT lda (ptr3),y ; Get bytes in last page beq @L4 @@ -391,9 +391,9 @@ vdcgetreg: @L0: bit VDC_ADDR_REG bpl @L0 lda VDC_DATA_REG - rts + rts -vdcputbyte: +vdcputbyte: ldx #VDC_DATA vdcputreg: stx VDC_ADDR_REG diff --git a/libsrc/geos-cbm/file/followchain.s b/libsrc/geos-cbm/file/followchain.s index df20bcaac..9b882d59a 100644 --- a/libsrc/geos-cbm/file/followchain.s +++ b/libsrc/geos-cbm/file/followchain.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _FollowChain: sta r3L stx r3H diff --git a/libsrc/geos-cbm/graph/setnewmode.s b/libsrc/geos-cbm/graph/setnewmode.s index 1d63cf78e..56fc123f7 100644 --- a/libsrc/geos-cbm/graph/setnewmode.s +++ b/libsrc/geos-cbm/graph/setnewmode.s @@ -9,7 +9,7 @@ .include "jumptab.inc" .include "geossym.inc" - + _SetNewMode: lda graphMode eor #$80 diff --git a/libsrc/geos-cbm/system/initdoneio.s b/libsrc/geos-cbm/system/initdoneio.s index b5e51524a..4b8762bad 100644 --- a/libsrc/geos-cbm/system/initdoneio.s +++ b/libsrc/geos-cbm/system/initdoneio.s @@ -11,5 +11,5 @@ .include "jumptab.inc" _InitForIO = InitForIO - -_DoneWithIO = DoneWithIO \ No newline at end of file + +_DoneWithIO = DoneWithIO diff --git a/libsrc/geos-cbm/system/setdevice.s b/libsrc/geos-cbm/system/setdevice.s index 37a162303..a67c10228 100644 --- a/libsrc/geos-cbm/system/setdevice.s +++ b/libsrc/geos-cbm/system/setdevice.s @@ -8,5 +8,5 @@ .export _SetDevice .include "jumptab.inc" - + _SetDevice = SetDevice diff --git a/libsrc/geos-cbm/system/tobasic.s b/libsrc/geos-cbm/system/tobasic.s index cb47da531..59bdc2936 100644 --- a/libsrc/geos-cbm/system/tobasic.s +++ b/libsrc/geos-cbm/system/tobasic.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_ToBASIC = ToBASIC \ No newline at end of file +_ToBASIC = ToBASIC diff --git a/libsrc/geos-cbm/tgi/geos-tgi.s b/libsrc/geos-cbm/tgi/geos-tgi.s index 08927e6c1..c04742fb6 100644 --- a/libsrc/geos-cbm/tgi/geos-tgi.s +++ b/libsrc/geos-cbm/tgi/geos-tgi.s @@ -93,7 +93,7 @@ Y2 = ptr4 SCRBASE: .res 1 ; High byte of screen base (64k VDC only) -ERROR: +ERROR: .res 1 ; Error code PALETTE: .res 2 ; The current palette @@ -199,9 +199,9 @@ INSTALL: @endok: lda #0 sta SCRBASE ; draw page 0 as default - rts + rts -test64k: +test64k: sta tmp1 sty ptr3 lda #0 diff --git a/libsrc/geos-common/common/zerobss.s b/libsrc/geos-common/common/zerobss.s index 48fc5a89a..85d3e03eb 100644 --- a/libsrc/geos-common/common/zerobss.s +++ b/libsrc/geos-common/common/zerobss.s @@ -7,7 +7,7 @@ .export zerobss .import __BSS_RUN__, __BSS_SIZE__ - + .include "jumptab.inc" .include "geossym.inc" diff --git a/libsrc/geos-common/conio/_scrsize.s b/libsrc/geos-common/conio/_scrsize.s index 494182b9d..ffb17dec6 100644 --- a/libsrc/geos-common/conio/_scrsize.s +++ b/libsrc/geos-common/conio/_scrsize.s @@ -11,7 +11,7 @@ .importzp cursor_r, cursor_c .import _cursor .constructor initscrsize - + .include "geossym.inc" .segment "ONCE" @@ -38,7 +38,7 @@ L1: lda #40 ; 40 columns (more or less) .code -screensize: +screensize: ldx xsize ldy ysize rts diff --git a/libsrc/geos-common/conio/cputc.s b/libsrc/geos-common/conio/cputc.s index 014c2ed0b..af4194312 100644 --- a/libsrc/geos-common/conio/cputc.s +++ b/libsrc/geos-common/conio/cputc.s @@ -19,7 +19,7 @@ ; ESC_GRAPHICS, ESC_RULER, GOTOX, GOTOY, GOTOXY, NEWCARDSET, all 1..8 ; ; note that there are conflicts between control characters and keyboard: -; HOME = KEY_ENTER, KEY_HOME = REV_ON, +; HOME = KEY_ENTER, KEY_HOME = REV_ON, ; UPLINE = ?, KEY_UPARROW = GOTOY, ... .export _cputcxy, _cputc diff --git a/libsrc/geos-common/conio/cvline.s b/libsrc/geos-common/conio/cvline.s index c12b8764b..9aa3d3eee 100644 --- a/libsrc/geos-common/conio/cvline.s +++ b/libsrc/geos-common/conio/cvline.s @@ -18,7 +18,7 @@ _cvlinexy: jsr gotoxy ; Call this one, will pop params pla ; Restore the length -_cvline: +_cvline: cmp #0 ; Is the length zero? beq L9 ; Jump if done tax diff --git a/libsrc/geos-common/disk/blkalloc.s b/libsrc/geos-common/disk/blkalloc.s index 6bfcb312c..bace80098 100644 --- a/libsrc/geos-common/disk/blkalloc.s +++ b/libsrc/geos-common/disk/blkalloc.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _BlkAlloc: sta r2L stx r2H diff --git a/libsrc/geos-common/disk/calcblksfree.s b/libsrc/geos-common/disk/calcblksfree.s index 5d7b98aba..7e1bb4f52 100644 --- a/libsrc/geos-common/disk/calcblksfree.s +++ b/libsrc/geos-common/disk/calcblksfree.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _CalcBlksFree: lda #<curDirHead ldx #>curDirHead diff --git a/libsrc/geos-common/disk/freeblock.s b/libsrc/geos-common/disk/freeblock.s index cd8b08d2f..da9a83f86 100644 --- a/libsrc/geos-common/disk/freeblock.s +++ b/libsrc/geos-common/disk/freeblock.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _FreeBlock: jsr gettrse sta r6L diff --git a/libsrc/geos-common/disk/getblock.s b/libsrc/geos-common/disk/getblock.s index cef7ece6f..bb1690827 100644 --- a/libsrc/geos-common/disk/getblock.s +++ b/libsrc/geos-common/disk/getblock.s @@ -12,7 +12,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _GetBlock: sta r4L stx r4H diff --git a/libsrc/geos-common/disk/getptrcurdknm.s b/libsrc/geos-common/disk/getptrcurdknm.s index 7a99225ef..d92e5d91e 100644 --- a/libsrc/geos-common/disk/getptrcurdknm.s +++ b/libsrc/geos-common/disk/getptrcurdknm.s @@ -12,8 +12,8 @@ .include "jumptab.inc" .include "geossym.inc" - -_GetPtrCurDkNm: + +_GetPtrCurDkNm: sta ptr3 stx ptr3+1 ldx #ptr4 diff --git a/libsrc/geos-common/disk/nxtblkalloc.s b/libsrc/geos-common/disk/nxtblkalloc.s index 7427f3de0..560eb0945 100644 --- a/libsrc/geos-common/disk/nxtblkalloc.s +++ b/libsrc/geos-common/disk/nxtblkalloc.s @@ -13,7 +13,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _NxtBlkAlloc: sta r2L stx r2H diff --git a/libsrc/geos-common/disk/opendisk.s b/libsrc/geos-common/disk/opendisk.s index 66bd24d30..9de5fb1d7 100644 --- a/libsrc/geos-common/disk/opendisk.s +++ b/libsrc/geos-common/disk/opendisk.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "diskdrv.inc" - + _OpenDisk: jsr OpenDisk jmp setoserror diff --git a/libsrc/geos-common/disk/putblock.s b/libsrc/geos-common/disk/putblock.s index df1af9f19..4c17274e1 100644 --- a/libsrc/geos-common/disk/putblock.s +++ b/libsrc/geos-common/disk/putblock.s @@ -12,7 +12,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _PutBlock: sta r4L stx r4H diff --git a/libsrc/geos-common/disk/putdirhead.s b/libsrc/geos-common/disk/putdirhead.s index 411b64307..afd7f9b39 100644 --- a/libsrc/geos-common/disk/putdirhead.s +++ b/libsrc/geos-common/disk/putdirhead.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "diskdrv.inc" - + _PutDirHead: jsr PutDirHead jmp setoserror diff --git a/libsrc/geos-common/disk/setnextfree.s b/libsrc/geos-common/disk/setnextfree.s index 410532cea..b24f16f6f 100644 --- a/libsrc/geos-common/disk/setnextfree.s +++ b/libsrc/geos-common/disk/setnextfree.s @@ -12,7 +12,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _SetNextFree: jsr gettrse sta r3L diff --git a/libsrc/geos-common/dlgbox/rstrfrmdialogue.s b/libsrc/geos-common/dlgbox/rstrfrmdialogue.s index efee17465..9119770a0 100644 --- a/libsrc/geos-common/dlgbox/rstrfrmdialogue.s +++ b/libsrc/geos-common/dlgbox/rstrfrmdialogue.s @@ -8,5 +8,5 @@ .export _RstrFrmDialogue .include "jumptab.inc" - + _RstrFrmDialogue = RstrFrmDialogue diff --git a/libsrc/geos-common/drivers/fio_module.s b/libsrc/geos-common/drivers/fio_module.s index 937ef292e..1314fc4c5 100644 --- a/libsrc/geos-common/drivers/fio_module.s +++ b/libsrc/geos-common/drivers/fio_module.s @@ -38,21 +38,21 @@ _open: jsr popax ; Get flags sta tmp1 jsr popptr1 ; Get name - + lda filedesc ; is there a file already open? bne @alreadyopen - + lda tmp1 ; check open mode and #(O_RDWR | O_CREAT) cmp #O_RDONLY ; only O_RDONLY is valid bne @badmode - + lda ptr1 ldx ptr1+1 jsr _FindFile ; try to find the file tax bne @oserror - + lda dirEntryBuf + OFF_DE_TR_SC ; tr&se for ReadByte (r1) sta f_track lda dirEntryBuf + OFF_DE_TR_SC + 1 diff --git a/libsrc/geos-common/drivers/geos-stdmou.s b/libsrc/geos-common/drivers/geos-stdmou.s index 7e544ba82..88bbc7df9 100644 --- a/libsrc/geos-common/drivers/geos-stdmou.s +++ b/libsrc/geos-common/drivers/geos-stdmou.s @@ -5,7 +5,7 @@ ; ; Driver for GEOS standard input device interface ; - + .export _mouse_init, _mouse_done .export _mouse_hide, _mouse_show .export _mouse_box diff --git a/libsrc/geos-common/file/appendrecord.s b/libsrc/geos-common/file/appendrecord.s index 2a7864a13..1ec1e8869 100644 --- a/libsrc/geos-common/file/appendrecord.s +++ b/libsrc/geos-common/file/appendrecord.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "diskdrv.inc" - + _AppendRecord: jsr AppendRecord diff --git a/libsrc/geos-common/file/closerecordfile.s b/libsrc/geos-common/file/closerecordfile.s index ee0778d7b..1c8b19b01 100644 --- a/libsrc/geos-common/file/closerecordfile.s +++ b/libsrc/geos-common/file/closerecordfile.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "diskdrv.inc" - + _CloseRecordFile: jsr CloseRecordFile jmp setoserror diff --git a/libsrc/geos-common/file/deletefile.s b/libsrc/geos-common/file/deletefile.s index 730569e55..b9d994142 100644 --- a/libsrc/geos-common/file/deletefile.s +++ b/libsrc/geos-common/file/deletefile.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _DeleteFile: sta r0L stx r0H diff --git a/libsrc/geos-common/file/deleterecord.s b/libsrc/geos-common/file/deleterecord.s index 7ffe5d739..fac73f665 100644 --- a/libsrc/geos-common/file/deleterecord.s +++ b/libsrc/geos-common/file/deleterecord.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _DeleteRecord: jsr DeleteRecord jmp setoserror diff --git a/libsrc/geos-common/file/findfile.s b/libsrc/geos-common/file/findfile.s index 0f58e99e6..285e8d650 100644 --- a/libsrc/geos-common/file/findfile.s +++ b/libsrc/geos-common/file/findfile.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _FindFile: sta r6L stx r6H diff --git a/libsrc/geos-common/file/freefile.s b/libsrc/geos-common/file/freefile.s index 791f3f31c..03a8b9d88 100644 --- a/libsrc/geos-common/file/freefile.s +++ b/libsrc/geos-common/file/freefile.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _FreeFile: sta r9L stx r9H diff --git a/libsrc/geos-common/file/getfhdrinfo.s b/libsrc/geos-common/file/getfhdrinfo.s index a9a843e74..1503b1cf1 100644 --- a/libsrc/geos-common/file/getfhdrinfo.s +++ b/libsrc/geos-common/file/getfhdrinfo.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _GetFHdrInfo: sta r9L stx r9H diff --git a/libsrc/geos-common/file/getfile.s b/libsrc/geos-common/file/getfile.s index 9c8011542..24f87e859 100644 --- a/libsrc/geos-common/file/getfile.s +++ b/libsrc/geos-common/file/getfile.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _GetFile: sta r3L stx r3H diff --git a/libsrc/geos-common/file/openrecordfile.s b/libsrc/geos-common/file/openrecordfile.s index cdab3dd6c..cba5d7c08 100644 --- a/libsrc/geos-common/file/openrecordfile.s +++ b/libsrc/geos-common/file/openrecordfile.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _OpenRecordFile: sta r0L stx r0H diff --git a/libsrc/geos-common/file/pointrecord.s b/libsrc/geos-common/file/pointrecord.s index 82b88c4c6..29294737d 100644 --- a/libsrc/geos-common/file/pointrecord.s +++ b/libsrc/geos-common/file/pointrecord.s @@ -10,7 +10,7 @@ .include "jumptab.inc" .include "diskdrv.inc" - + _PointRecord: jsr PointRecord jmp setoserror diff --git a/libsrc/geos-common/file/readfile.s b/libsrc/geos-common/file/readfile.s index 3b43cffd4..d8b941cde 100644 --- a/libsrc/geos-common/file/readfile.s +++ b/libsrc/geos-common/file/readfile.s @@ -12,7 +12,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _ReadFile: sta r2L stx r2H diff --git a/libsrc/geos-common/file/readrecord.s b/libsrc/geos-common/file/readrecord.s index dd464e0b1..be155c718 100644 --- a/libsrc/geos-common/file/readrecord.s +++ b/libsrc/geos-common/file/readrecord.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _ReadRecord: sta r2L stx r2H diff --git a/libsrc/geos-common/file/writerecord.s b/libsrc/geos-common/file/writerecord.s index e0d4c86d4..33b5fef31 100644 --- a/libsrc/geos-common/file/writerecord.s +++ b/libsrc/geos-common/file/writerecord.s @@ -11,7 +11,7 @@ .include "jumptab.inc" .include "diskdrv.inc" .include "geossym.inc" - + _WriteRecord: sta r2L stx r2H diff --git a/libsrc/geos-common/geosmac.inc b/libsrc/geos-common/geosmac.inc index 5ce20ff7f..6398b7a0b 100644 --- a/libsrc/geos-common/geosmac.inc +++ b/libsrc/geos-common/geosmac.inc @@ -136,7 +136,7 @@ Skip: ;------------------------------------------------------------------------- .macro CmpW source, dest -.local Skip +.local Skip CmpB source+1, dest+1 bne Skip CmpB source+0, dest+0 @@ -203,7 +203,7 @@ Skip: .macro rmb bitNumber, dest pha - lda #(1 << bitNumber) ^ $ff + lda #(1 << bitNumber) ^ $ff and dest sta dest pla diff --git a/libsrc/geos-common/graph/bitotherclip.s b/libsrc/geos-common/graph/bitotherclip.s index ef849f6d7..020139da8 100644 --- a/libsrc/geos-common/graph/bitotherclip.s +++ b/libsrc/geos-common/graph/bitotherclip.s @@ -3,7 +3,7 @@ ; ; 21.12.99 -; void BitOtherClip (void *proc1, void* proc2, char skipl, char skipr, int skipy, +; void BitOtherClip (void *proc1, void* proc2, char skipl, char skipr, int skipy, ; struct iconpic *myGfx); ; both proc1, proc2 should be: char __fastcall something (void); diff --git a/libsrc/geos-common/graph/framerectangle.s b/libsrc/geos-common/graph/framerectangle.s index c5f9de04c..eb3ea8df6 100644 --- a/libsrc/geos-common/graph/framerectangle.s +++ b/libsrc/geos-common/graph/framerectangle.s @@ -8,5 +8,5 @@ .export _FrameRectangle .include "jumptab.inc" - + _FrameRectangle = FrameRectangle diff --git a/libsrc/geos-common/graph/imprintrectangle.s b/libsrc/geos-common/graph/imprintrectangle.s index fc327e9d3..08b28690d 100644 --- a/libsrc/geos-common/graph/imprintrectangle.s +++ b/libsrc/geos-common/graph/imprintrectangle.s @@ -4,10 +4,10 @@ ; 21.12.99 ; void ImprintRectangle (void); - + .export _ImprintRectangle .include "jumptab.inc" - + _ImprintRectangle = ImprintRectangle diff --git a/libsrc/geos-common/graph/invertline.s b/libsrc/geos-common/graph/invertline.s index baa4a6e5a..72fb87afb 100644 --- a/libsrc/geos-common/graph/invertline.s +++ b/libsrc/geos-common/graph/invertline.s @@ -9,7 +9,7 @@ .export _InvertLine .include "jumptab.inc" - + _InvertLine: jsr HLineRegs jmp InvertLine diff --git a/libsrc/geos-common/graph/invertrectangle.s b/libsrc/geos-common/graph/invertrectangle.s index 084187255..52750a8e9 100644 --- a/libsrc/geos-common/graph/invertrectangle.s +++ b/libsrc/geos-common/graph/invertrectangle.s @@ -6,7 +6,7 @@ ; void InvertRectangle (void); .export _InvertRectangle - + .include "jumptab.inc" _InvertRectangle = InvertRectangle diff --git a/libsrc/geos-common/graph/recoverline.s b/libsrc/geos-common/graph/recoverline.s index edc366114..8214242d3 100644 --- a/libsrc/geos-common/graph/recoverline.s +++ b/libsrc/geos-common/graph/recoverline.s @@ -7,7 +7,7 @@ .import HLineRegs .export _RecoverLine - + .include "jumptab.inc" _RecoverLine: diff --git a/libsrc/geos-common/graph/recoverrectangle.s b/libsrc/geos-common/graph/recoverrectangle.s index 009ca81eb..2e494fcbe 100644 --- a/libsrc/geos-common/graph/recoverrectangle.s +++ b/libsrc/geos-common/graph/recoverrectangle.s @@ -4,10 +4,10 @@ ; 29.10.99 ; void RecoverRectangle (void); - + .export _RecoverRectangle .include "jumptab.inc" - + _RecoverRectangle = RecoverRectangle diff --git a/libsrc/geos-common/graph/rectangle.s b/libsrc/geos-common/graph/rectangle.s index a9351c47e..6dc283024 100644 --- a/libsrc/geos-common/graph/rectangle.s +++ b/libsrc/geos-common/graph/rectangle.s @@ -6,7 +6,7 @@ ; void Rectangle (void); .export _Rectangle - + .include "jumptab.inc" _Rectangle = Rectangle diff --git a/libsrc/geos-common/graph/testpoint.s b/libsrc/geos-common/graph/testpoint.s index f2dfb7b5d..ad1dd3fee 100644 --- a/libsrc/geos-common/graph/testpoint.s +++ b/libsrc/geos-common/graph/testpoint.s @@ -10,7 +10,7 @@ .export _TestPoint .include "jumptab.inc" - + _TestPoint: jsr PointRegs jsr TestPoint diff --git a/libsrc/geos-common/graph/verticalline.s b/libsrc/geos-common/graph/verticalline.s index 01fb0b725..1ec89a9d7 100644 --- a/libsrc/geos-common/graph/verticalline.s +++ b/libsrc/geos-common/graph/verticalline.s @@ -5,12 +5,12 @@ ; void VerticalLine (char pattern, char ystart, char yend, int x); - .import popa + .import popa .export _VerticalLine .include "jumptab.inc" .include "geossym.inc" - + _VerticalLine: stx r4H sta r4L diff --git a/libsrc/geos-common/memory/crc.s b/libsrc/geos-common/memory/crc.s index 9ec2feb0c..94ab98f34 100644 --- a/libsrc/geos-common/memory/crc.s +++ b/libsrc/geos-common/memory/crc.s @@ -17,4 +17,3 @@ _CRC: lda r2L ldx r2H rts - \ No newline at end of file diff --git a/libsrc/geos-common/menuicon/doicons.s b/libsrc/geos-common/menuicon/doicons.s index 5ddf06d01..b0456e67f 100644 --- a/libsrc/geos-common/menuicon/doicons.s +++ b/libsrc/geos-common/menuicon/doicons.s @@ -13,4 +13,4 @@ _DoIcons: sta r0L stx r0H - jmp DoIcons \ No newline at end of file + jmp DoIcons diff --git a/libsrc/geos-common/menuicon/domenu.s b/libsrc/geos-common/menuicon/domenu.s index 1624a3852..43a2b5a0c 100644 --- a/libsrc/geos-common/menuicon/domenu.s +++ b/libsrc/geos-common/menuicon/domenu.s @@ -14,4 +14,4 @@ _DoMenu: sta r0L stx r0H lda #0 - jmp DoMenu \ No newline at end of file + jmp DoMenu diff --git a/libsrc/geos-common/menuicon/dopreviousmenu.s b/libsrc/geos-common/menuicon/dopreviousmenu.s index 5ac19b57a..1a92e1fe1 100644 --- a/libsrc/geos-common/menuicon/dopreviousmenu.s +++ b/libsrc/geos-common/menuicon/dopreviousmenu.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_DoPreviousMenu = DoPreviousMenu \ No newline at end of file +_DoPreviousMenu = DoPreviousMenu diff --git a/libsrc/geos-common/menuicon/gotofirstmenu.s b/libsrc/geos-common/menuicon/gotofirstmenu.s index b5f2306db..a8d00b132 100644 --- a/libsrc/geos-common/menuicon/gotofirstmenu.s +++ b/libsrc/geos-common/menuicon/gotofirstmenu.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_GotoFirstMenu = GotoFirstMenu \ No newline at end of file +_GotoFirstMenu = GotoFirstMenu diff --git a/libsrc/geos-common/menuicon/recoverallmenus.s b/libsrc/geos-common/menuicon/recoverallmenus.s index 03a8368bf..0420e88be 100644 --- a/libsrc/geos-common/menuicon/recoverallmenus.s +++ b/libsrc/geos-common/menuicon/recoverallmenus.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_RecoverAllMenus = RecoverAllMenus \ No newline at end of file +_RecoverAllMenus = RecoverAllMenus diff --git a/libsrc/geos-common/menuicon/recovermenu.s b/libsrc/geos-common/menuicon/recovermenu.s index 638d03d16..a8a6870c7 100644 --- a/libsrc/geos-common/menuicon/recovermenu.s +++ b/libsrc/geos-common/menuicon/recovermenu.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_RecoverMenu = RecoverMenu \ No newline at end of file +_RecoverMenu = RecoverMenu diff --git a/libsrc/geos-common/menuicon/redomenu.s b/libsrc/geos-common/menuicon/redomenu.s index 44d62e807..818102f8b 100644 --- a/libsrc/geos-common/menuicon/redomenu.s +++ b/libsrc/geos-common/menuicon/redomenu.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_ReDoMenu = ReDoMenu \ No newline at end of file +_ReDoMenu = ReDoMenu diff --git a/libsrc/geos-common/mousesprite/clearmousemode.s b/libsrc/geos-common/mousesprite/clearmousemode.s index 01e659567..635a0fcd4 100644 --- a/libsrc/geos-common/mousesprite/clearmousemode.s +++ b/libsrc/geos-common/mousesprite/clearmousemode.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_ClearMouseMode = ClearMouseMode \ No newline at end of file +_ClearMouseMode = ClearMouseMode diff --git a/libsrc/geos-common/mousesprite/disablsprite.s b/libsrc/geos-common/mousesprite/disablsprite.s index 95d298094..e6c769e29 100644 --- a/libsrc/geos-common/mousesprite/disablsprite.s +++ b/libsrc/geos-common/mousesprite/disablsprite.s @@ -12,4 +12,4 @@ _DisablSprite: sta r3L - jmp DisablSprite \ No newline at end of file + jmp DisablSprite diff --git a/libsrc/geos-common/mousesprite/drawsprite.s b/libsrc/geos-common/mousesprite/drawsprite.s index 0f4d611c0..90382c63c 100644 --- a/libsrc/geos-common/mousesprite/drawsprite.s +++ b/libsrc/geos-common/mousesprite/drawsprite.s @@ -16,4 +16,4 @@ _DrawSprite: stx r4H jsr popa sta r3L - jmp DrawSprite \ No newline at end of file + jmp DrawSprite diff --git a/libsrc/geos-common/mousesprite/enablsprite.s b/libsrc/geos-common/mousesprite/enablsprite.s index a271d2cdb..404a7cb05 100644 --- a/libsrc/geos-common/mousesprite/enablsprite.s +++ b/libsrc/geos-common/mousesprite/enablsprite.s @@ -12,4 +12,4 @@ _EnablSprite: sta r3L - jmp EnablSprite \ No newline at end of file + jmp EnablSprite diff --git a/libsrc/geos-common/mousesprite/inittextprompt.s b/libsrc/geos-common/mousesprite/inittextprompt.s index 2fc5e58fc..e0c4cc1cd 100644 --- a/libsrc/geos-common/mousesprite/inittextprompt.s +++ b/libsrc/geos-common/mousesprite/inittextprompt.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_InitTextPrompt = InitTextPrompt \ No newline at end of file +_InitTextPrompt = InitTextPrompt diff --git a/libsrc/geos-common/mousesprite/ismseinregion.s b/libsrc/geos-common/mousesprite/ismseinregion.s index 0617490c5..da14c9fe8 100644 --- a/libsrc/geos-common/mousesprite/ismseinregion.s +++ b/libsrc/geos-common/mousesprite/ismseinregion.s @@ -7,7 +7,7 @@ .import _InitDrawWindow .export _IsMseInRegion - + .include "jumptab.inc" _IsMseInRegion: diff --git a/libsrc/geos-common/mousesprite/mouseoff.s b/libsrc/geos-common/mousesprite/mouseoff.s index a918bb612..b48d30807 100644 --- a/libsrc/geos-common/mousesprite/mouseoff.s +++ b/libsrc/geos-common/mousesprite/mouseoff.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_MouseOff = MouseOff \ No newline at end of file +_MouseOff = MouseOff diff --git a/libsrc/geos-common/mousesprite/mouseup.s b/libsrc/geos-common/mousesprite/mouseup.s index 45b4e83c2..8f7b4e0f6 100644 --- a/libsrc/geos-common/mousesprite/mouseup.s +++ b/libsrc/geos-common/mousesprite/mouseup.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_MouseUp = MouseUp \ No newline at end of file +_MouseUp = MouseUp diff --git a/libsrc/geos-common/mousesprite/possprite.s b/libsrc/geos-common/mousesprite/possprite.s index 24e8bd14c..5543cb3c6 100644 --- a/libsrc/geos-common/mousesprite/possprite.s +++ b/libsrc/geos-common/mousesprite/possprite.s @@ -26,4 +26,4 @@ _PosSprite: sta r5L jsr popa sta r3L - jmp PosSprite \ No newline at end of file + jmp PosSprite diff --git a/libsrc/geos-common/mousesprite/startmousemode.s b/libsrc/geos-common/mousesprite/startmousemode.s index 06a547714..26d969744 100644 --- a/libsrc/geos-common/mousesprite/startmousemode.s +++ b/libsrc/geos-common/mousesprite/startmousemode.s @@ -11,4 +11,4 @@ _StartMouseMode: clc - jmp StartMouseMode \ No newline at end of file + jmp StartMouseMode diff --git a/libsrc/geos-common/process/processblock.s b/libsrc/geos-common/process/processblock.s index 84ead5993..17f07f28c 100644 --- a/libsrc/geos-common/process/processblock.s +++ b/libsrc/geos-common/process/processblock.s @@ -12,11 +12,11 @@ .export _UnblockProcess .include "jumptab.inc" - + _BlockProcess: tax jmp BlockProcess - + _UnblockProcess: tax jmp UnblockProcess diff --git a/libsrc/geos-common/process/processfreeze.s b/libsrc/geos-common/process/processfreeze.s index bda914bdc..e77bec2d7 100644 --- a/libsrc/geos-common/process/processfreeze.s +++ b/libsrc/geos-common/process/processfreeze.s @@ -10,11 +10,11 @@ .export _UnfreezeProcess .include "jumptab.inc" - + _FreezeProcess: tax jmp FreezeProcess - + _UnfreezeProcess: tax jmp UnfreezeProcess diff --git a/libsrc/geos-common/process/processinitrestartenable.s b/libsrc/geos-common/process/processinitrestartenable.s index 800c2dc5f..73f030d56 100644 --- a/libsrc/geos-common/process/processinitrestartenable.s +++ b/libsrc/geos-common/process/processinitrestartenable.s @@ -20,11 +20,11 @@ _InitProcesses: stx r0H jsr popa jmp InitProcesses - + _RestartProcess: tax jmp RestartProcess - + _EnableProcess: tax jmp EnableProcess diff --git a/libsrc/geos-common/system/callroutine.s b/libsrc/geos-common/system/callroutine.s index 54de4cac7..3213d507e 100644 --- a/libsrc/geos-common/system/callroutine.s +++ b/libsrc/geos-common/system/callroutine.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_CallRoutine = CallRoutine \ No newline at end of file +_CallRoutine = CallRoutine diff --git a/libsrc/geos-common/system/firstinit.s b/libsrc/geos-common/system/firstinit.s index c0695ee47..617ecf4d6 100644 --- a/libsrc/geos-common/system/firstinit.s +++ b/libsrc/geos-common/system/firstinit.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_FirstInit = FirstInit \ No newline at end of file +_FirstInit = FirstInit diff --git a/libsrc/geos-common/system/panic.s b/libsrc/geos-common/system/panic.s index 9ea916023..d34b74a5a 100644 --- a/libsrc/geos-common/system/panic.s +++ b/libsrc/geos-common/system/panic.s @@ -9,4 +9,4 @@ .include "jumptab.inc" -_Panic = Panic \ No newline at end of file +_Panic = Panic diff --git a/libsrc/joystick/joy_load.s b/libsrc/joystick/joy_load.s index 7115f5d07..97ba7a0cd 100644 --- a/libsrc/joystick/joy_load.s +++ b/libsrc/joystick/joy_load.s @@ -87,7 +87,7 @@ ctrl: .addr _read ; Check the driver signature, install the driver. c is already on stack and ; will get removed by joy_install(). -; Res = joy_install (ctrl.module); +; Res = joy_install (ctrl.module); lda ctrl + MOD_CTRL::MODULE ldx ctrl + MOD_CTRL::MODULE+1 diff --git a/libsrc/lynx/bllhdr.s b/libsrc/lynx/bllhdr.s index 07ed06ffb..c34d7b53b 100644 --- a/libsrc/lynx/bllhdr.s +++ b/libsrc/lynx/bllhdr.s @@ -6,7 +6,7 @@ .import __BSS_LOAD__ .import __MAIN_START__ .export __BLLHDR__: absolute = 1 - + ; ------------------------------------------------------------------------ ; BLL header (BLL header) diff --git a/libsrc/lynx/bootldr.s b/libsrc/lynx/bootldr.s index 64569e6ee..ddc24faed 100644 --- a/libsrc/lynx/bootldr.s +++ b/libsrc/lynx/bootldr.s @@ -18,44 +18,60 @@ ; The idea is to make the smalles possible encrypted loader as decryption ; is very slow. The minimum size is 49 bytes plus a zero byte. ;********************************** -; EXE = $fb68 +; EXE = $fb68 ; -; .org $0200 +; .org $0200 ; -; ; 1. force Mikey to be in memory -; stz MAPCTL +; ; 1. force Mikey to be in memory +; 9C F9 FF stz MAPCTL ; -; ; 3. set ComLynx to open collector -; lda #4 ; a = 00000100 -; sta SERCTL ; set the ComLynx to open collector +; ; 2. clear palette +; A0 1F ldy #31 +; A9 00 lda #0 +; 99 A0 FD nextc: sta GCOLMAP, y +; 88 dey +; 10 FA bpl nextc ; -; ; 4. make sure the ROM is powered on -; lda #8 ; a = 00001000 -; sta IODAT ; set the ROM power to on +; ; 3. set ComLynx to open collector +; A9 04 lda #4 ; a = 00000100 +; 8D 8C FD sta SERCTL ; set the ComLynx to open collector ; -; ; 5. read in secondary exe + 8 bytes from the cart and store it in $f000 -; ldx #0 ; x = 0 -; ldy #$97 ; y = secondary loader size (151 bytes) -;rloop1: lda RCART0 ; read a byte from the cart -; sta EXE,X ; EXE[X] = a -; inx ; x++ -; dey ; y-- -; bne rloop1 ; loops until y wraps +; ; 4. set AUDIN to output +; A9 1A lda #$1a ; audin = out, rest = out, +; ; noexp = in, cart addr = out, ext pwd = in +; 8D 8A FD sta IODIR ; -; ; 6. jump to secondary loader -; jmp EXE ; run the secondary loader +; ; 5. set AUDIN to LOW +; A9 0B lda #$0B ; Set AUDIN low +; 85 1A sta $1a ; Save local copy to ZP +; 8D 8B FD sta IODAT ; -; .reloc +; ; 6. read in secondary exe + 8 bytes from the cart +; ; and store it in $f000 +; A2 00 ldx #0 ; x = 0 +; A0 97 ldy #$97 ; y = secondary loader size (151 bytes) +; AD B2 FC rloop1: lda RCART0 ; read a byte from the cart +; 9D 68 FB sta EXE,X ; EXE[X] = a +; E8 inx ; x++ +; 88 dey ; y-- +; D0 F6 bne rloop1 ; loops until y wraps +; +; ; 7. jump to secondary loader +; 4C 68 FB jmp EXE +; 00 00 00 00 ; spares +; 00 ; End of encrypted header mark +; +; .reloc ;********************************** ; After compilation, encryption and obfuscation it turns into this. ;********************************** - .byte $ff, $81, $ca, $33, $be, $80, $a2, $c4 - .byte $6d, $98, $fe, $8d, $bc, $66, $c0, $7a - .byte $09, $50, $23, $28, $18, $c8, $06, $70 - .byte $58, $4f, $1b, $e1, $c7, $90, $08, $cd - .byte $1a, $6e, $5a, $45, $32, $d7, $6d, $c6 - .byte $8a, $e5, $d8, $5c, $a0, $e8, $4f, $7a - .byte $5f, $73, $8d, $22 + .byte $ff, $b6, $bb, $82, $d5, $9f, $48, $cf + .byte $23, $37, $8e, $07, $38, $f5, $b6, $30 + .byte $d6, $2f, $12, $29, $9f, $43, $5b, $2e + .byte $f5, $66, $5c, $db, $93, $1a, $78, $55 + .byte $5e, $c9, $0d, $72, $1b, $e9, $d8, $4d + .byte $2f, $e4, $95, $c0, $4f, $7f, $1b, $66 + .byte $8b, $a7, $fc, $21 ;********************************** ; Now we have the secondary loader @@ -139,7 +155,7 @@ secreadbyte0: bne exit ;********************************** -; Select a block +; Select a block ;********************************** seclynxblock: pha diff --git a/libsrc/lynx/cgetc.s b/libsrc/lynx/cgetc.s index 362371ec3..d940b2b94 100644 --- a/libsrc/lynx/cgetc.s +++ b/libsrc/lynx/cgetc.s @@ -19,7 +19,7 @@ ; and Opt1 + Opt2 pressed '3'. ; So the keyboard returns '1', '2', '3', 'P', 'R', 'F' or '?'. -_cgetc: +_cgetc: jsr _kbhit ; Check for char available beq _cgetc ora KBSTL diff --git a/libsrc/lynx/eeprom.s b/libsrc/lynx/eeprom.s index 978220cfd..fb0247e90 100644 --- a/libsrc/lynx/eeprom.s +++ b/libsrc/lynx/eeprom.s @@ -252,4 +252,4 @@ EEloop4: rts - + diff --git a/libsrc/lynx/eeprom46.s b/libsrc/lynx/eeprom46.s index 55d9037c0..2b2277e45 100644 --- a/libsrc/lynx/eeprom46.s +++ b/libsrc/lynx/eeprom46.s @@ -4,7 +4,7 @@ ; ; created : 11.05.95 ; last modified : -; +; ; 16.02.96 leaner (thanks to Harry) ; 12.03.96 test for busy after write and erase (well, Harry ;)) ) ; 22.08.97 ported to ra65 for use with cc65 diff --git a/libsrc/lynx/eeprom66.s b/libsrc/lynx/eeprom66.s index 680db8166..6511cf8af 100644 --- a/libsrc/lynx/eeprom66.s +++ b/libsrc/lynx/eeprom66.s @@ -4,7 +4,7 @@ ; ; created : 11.05.95 ; last modified : -; +; ; 16.02.96 leaner (thanks to Harry) ; 12.03.96 test for busy after write and erase (well, Harry ;)) ) ; 22.08.97 ported to ra65 for use with cc65 diff --git a/libsrc/lynx/eeprom86.s b/libsrc/lynx/eeprom86.s index f753b73c3..73b342fae 100644 --- a/libsrc/lynx/eeprom86.s +++ b/libsrc/lynx/eeprom86.s @@ -4,7 +4,7 @@ ; ; created : 11.05.95 ; last modified : -; +; ; 16.02.96 leaner (thanks to Harry) ; 12.03.96 test for busy after write and erase (well, Harry ;)) ) ; 22.08.97 ported to ra65 for use with cc65 diff --git a/libsrc/lynx/exec.s b/libsrc/lynx/exec.s index c0a630a72..307475f1d 100644 --- a/libsrc/lynx/exec.s +++ b/libsrc/lynx/exec.s @@ -6,7 +6,7 @@ ; ; lynx_exec is often used in compilation carts when you run small demos ; created with various (non-cc65) compilers. -; +; ; void lynx_exec(int fileno) ; .importzp _FileDestAddr diff --git a/libsrc/lynx/kbhit.s b/libsrc/lynx/kbhit.s index 90d9061cd..d5b3d1cde 100644 --- a/libsrc/lynx/kbhit.s +++ b/libsrc/lynx/kbhit.s @@ -30,7 +30,7 @@ KBNPR: .byte 0 .code _kbhit: lda KBEDG - bne L1 + bne L1 lda $FCB0 ; Read the Opt buttons and #$0c sta KBTMP diff --git a/libsrc/lynx/lynx-cart.s b/libsrc/lynx/lynx-cart.s index 86e907348..94edff677 100644 --- a/libsrc/lynx/lynx-cart.s +++ b/libsrc/lynx/lynx-cart.s @@ -6,7 +6,7 @@ ; ; Ported to cc65 (http://www.cc65.org) by ; Shawn Jefferson, June 2004 -; +; ; This version by Karri Kaksonen, December 2010 ; ; Helper stuff for the cartridge file functions. This version can deal @@ -16,7 +16,7 @@ .include "lynx.inc" .include "extzp.inc" .export lynxskip0, lynxread0 - .export lynxblock + .export lynxblock .import __BLOCKSIZE__ .code @@ -60,7 +60,7 @@ readbyte0: bne exit ;********************************** -; Select a block +; Select a block ;********************************** lynxblock: pha diff --git a/libsrc/lynx/tgi/lynx-160-102-16.s b/libsrc/lynx/tgi/lynx-160-102-16.s index 903d8f25e..c35b6a5aa 100644 --- a/libsrc/lynx/tgi/lynx-160-102-16.s +++ b/libsrc/lynx/tgi/lynx-160-102-16.s @@ -113,7 +113,8 @@ text_bitmap: .res 8*(1+20+1)+1 .rodata -DEFPALETTE: .byte >$011 +DEFPALETTE: .byte >$223 + .byte >$011 .byte >$34d .byte >$9af .byte >$9b8 @@ -124,11 +125,11 @@ DEFPALETTE: .byte >$011 .byte >$d5f .byte >$c53 .byte >$822 - .byte >$223 .byte >$484 .byte >$8e5 .byte >$cf5 .byte >$fff + .byte <$223 .byte <$011 .byte <$34d .byte <$9af @@ -140,7 +141,6 @@ DEFPALETTE: .byte >$011 .byte <$d5f .byte <$c53 .byte <$822 - .byte <$223 .byte <$484 .byte <$8e5 .byte <$cf5 @@ -162,6 +162,7 @@ INSTALL: lda #1 sta TEXTMAGX sta TEXTMAGY + sta DRAWINDEX stz BGINDEX stz DRAWPAGE stz SWAPREQUEST @@ -418,7 +419,7 @@ cls_sprite: .word 0 .word $a000 ; 160 .word $6600 ; 102 - .byte $00 + .byte $11 .code CLEAR: lda #<cls_sprite @@ -844,11 +845,6 @@ OUTTEXT: lda TEXTMAGY sta text_sy+1 - lda BGINDEX - beq @L1 ; Choose opaque black sprite? - lda #$04 ; No, choose normal sprite -@L1: - sta text_sprite lda DRAWINDEX ; Set color asl asl @@ -956,7 +952,7 @@ OUTTEXT: text_coll: .byte 0 text_sprite: - .byte $00,$90,$20 + .byte $04,$90,$20 .addr 0, text_bitmap text_x: .word 0 diff --git a/libsrc/lynx/tgi_colors.s b/libsrc/lynx/tgi_colors.s index c7aefb417..ebc8c2889 100644 --- a/libsrc/lynx/tgi_colors.s +++ b/libsrc/lynx/tgi_colors.s @@ -4,5 +4,5 @@ .include "tgi-kernel.inc" - .export tgi_color_black:zp = $00 + .export tgi_color_black:zp = $01 .export tgi_color_white:zp = $0F diff --git a/libsrc/mouse/mouse_load.s b/libsrc/mouse/mouse_load.s index 347250843..a3a3f284d 100644 --- a/libsrc/mouse/mouse_load.s +++ b/libsrc/mouse/mouse_load.s @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 2006-06-05 ; ; unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c, diff --git a/libsrc/mouse/mouse_move.s b/libsrc/mouse/mouse_move.s index b25716b37..4d809109c 100644 --- a/libsrc/mouse/mouse_move.s +++ b/libsrc/mouse/mouse_move.s @@ -10,7 +10,7 @@ ; .import incsp2 - .import ptr1: zp + .import ptr1: zp .include "mouse-kernel.inc" diff --git a/libsrc/nes/cclear.s b/libsrc/nes/cclear.s index 7a2413826..93f5c7c9a 100644 --- a/libsrc/nes/cclear.s +++ b/libsrc/nes/cclear.s @@ -17,7 +17,7 @@ _cclearxy: _cclear: cmp #0 ; Is the length zero? beq L9 ; Jump if done - sta tmp1 + sta tmp1 L1: lda #$20 ; Blank - screen code jsr cputdirect ; Direct output dec tmp1 diff --git a/libsrc/nes/chline.s b/libsrc/nes/chline.s index d68a77df9..fff229575 100644 --- a/libsrc/nes/chline.s +++ b/libsrc/nes/chline.s @@ -10,7 +10,7 @@ .importzp tmp1 .include "nes.inc" - + _chlinexy: pha ; Save the length jsr gotoxy ; Call this one, will pop params diff --git a/libsrc/nes/gotoy.s b/libsrc/nes/gotoy.s index cfd913f2e..a36e77964 100644 --- a/libsrc/nes/gotoy.s +++ b/libsrc/nes/gotoy.s @@ -19,4 +19,4 @@ .endproc - + diff --git a/libsrc/nes/ppubuf.s b/libsrc/nes/ppubuf.s index 3708b93c1..f08fc1a71 100644 --- a/libsrc/nes/ppubuf.s +++ b/libsrc/nes/ppubuf.s @@ -101,7 +101,7 @@ @end: stx ringread sty ringcount - rts + rts .endproc diff --git a/libsrc/nes/sysuname.s b/libsrc/nes/sysuname.s index 2606d1a60..fcab503e1 100644 --- a/libsrc/nes/sysuname.s +++ b/libsrc/nes/sysuname.s @@ -35,5 +35,5 @@ utsdata: ; machine .asciiz "NES" - + diff --git a/libsrc/osic1p/cclear.s b/libsrc/osic1p/cclear.s index f7e9b2984..e399f14a9 100644 --- a/libsrc/osic1p/cclear.s +++ b/libsrc/osic1p/cclear.s @@ -20,7 +20,7 @@ _cclearxy: _cclear: cmp #0 ; Is the length zero? beq L9 ; Jump if done - sta tmp1 + sta tmp1 L1: lda #' ' jsr cputdirect ; Direct output dec tmp1 diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc index 9399d7eee..ee2e52174 100644 --- a/libsrc/osic1p/osiscreen.inc +++ b/libsrc/osic1p/osiscreen.inc @@ -3,7 +3,7 @@ ; .include "extzp.inc" - + .linecont + ; @@ -13,7 +13,7 @@ ; Macro implementation of internal screensize ; function for given width and height in ; characters - + .export screensize .proc screensize @@ -34,11 +34,11 @@ lda #<ScrBase ; Fill whole video RAM with blanks by calling ldx #>ScrBase ; memset appropriately jsr pushax - + lda #' ' ldx #$00 jsr pushax - + lda #<ScrRamSize ldx #>ScrRamSize jsr _memset @@ -46,7 +46,7 @@ lda #$00 ; Cursor in upper left corner sta CURS_X sta CURS_Y - + jmp plot ; Set the cursor position .endproc @@ -112,12 +112,12 @@ newline: lda #<(ScrBase + ScrFirstChar) ldx #>(ScrBase + ScrFirstChar) jsr pushax - + ; Scroll source address lda #<(ScrBase + ScrFirstChar + ScrollDist) ldx #>(ScrBase + ScrFirstChar + ScrollDist) jsr pushax - + ; Number of characters to move lda #<ScrollLength ldx #>ScrollLength @@ -129,7 +129,7 @@ newline: sta ptr1 lda #>(ScrBase + ScrFirstChar + ScrollLength) sta ptr1+1 - + ldy #ScrWidth ; Fill last line with blanks lda #' ' clrln: sta (ptr1),y @@ -150,7 +150,7 @@ putchar: ldy CURS_X sta (SCREEN_PTR),y ; Set char rts - + .endmacro .macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ @@ -167,12 +167,13 @@ ScrTabLo: .repeat ScrHeight, I .byte <(ScrBase + ScrFirstChar + I * ScrollDist) .endrep - + ScrTabHi: .repeat ScrHeight, I .byte >(ScrBase + ScrFirstChar + I * ScrollDist) .endrep + .code osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ @@ -180,4 +181,4 @@ osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ osi_screensize ScrWidth, ScrHeight osi_clrscr ScrBase, ScrRamSize -.endmacro \ No newline at end of file +.endmacro diff --git a/libsrc/pce/cclear.s b/libsrc/pce/cclear.s index 14b9d0e8b..e6277eed0 100644 --- a/libsrc/pce/cclear.s +++ b/libsrc/pce/cclear.s @@ -17,7 +17,7 @@ _cclearxy: _cclear: cmp #0 ; Is the length zero? beq L9 ; Jump if done - sta tmp1 + sta tmp1 L1: lda #$20 ; Blank - screen code jsr cputdirect ; Direct output dec tmp1 diff --git a/libsrc/plus4/randomize.s b/libsrc/plus4/randomize.s index 2a7f6a44b..796ad118b 100644 --- a/libsrc/plus4/randomize.s +++ b/libsrc/plus4/randomize.s @@ -11,7 +11,7 @@ .include "plus4.inc" -__randomize: +__randomize: ldx TED_VLINELO ; Use TED rasterline as high byte lda TIME+2 ; Use 60HZ clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index e644671c0..a4658cc13 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -33,13 +33,13 @@ hiadd: txa ; (19) inc sp+1 ; (-1+5) done: tya ; (36) -.else +.else ldy #0 ; (4) adc (sp),y ; (9) lo byte iny ; (11) sta tmp1 ; (14) save it - txa ; (16) + txa ; (16) adc (sp),y ; (21) hi byte tax ; (23) clc ; (25) diff --git a/libsrc/runtime/aslax1.s b/libsrc/runtime/aslax1.s index 14f0be3cc..97ac71c45 100644 --- a/libsrc/runtime/aslax1.s +++ b/libsrc/runtime/aslax1.s @@ -6,7 +6,7 @@ .export aslax1, shlax1 .importzp tmp1 - + aslax1: shlax1: stx tmp1 asl A diff --git a/libsrc/runtime/decsp1.s b/libsrc/runtime/decsp1.s index 5aa7fa204..3c673664a 100644 --- a/libsrc/runtime/decsp1.s +++ b/libsrc/runtime/decsp1.s @@ -20,4 +20,4 @@ - + diff --git a/libsrc/runtime/incsp1.s b/libsrc/runtime/incsp1.s index 43c92dc82..2272e200f 100644 --- a/libsrc/runtime/incsp1.s +++ b/libsrc/runtime/incsp1.s @@ -19,4 +19,4 @@ - + diff --git a/libsrc/runtime/incsp3.s b/libsrc/runtime/incsp3.s index 29067a55e..f54b13920 100644 --- a/libsrc/runtime/incsp3.s +++ b/libsrc/runtime/incsp3.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/incsp4.s b/libsrc/runtime/incsp4.s index 51e9229bb..736438fce 100644 --- a/libsrc/runtime/incsp4.s +++ b/libsrc/runtime/incsp4.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/incsp5.s b/libsrc/runtime/incsp5.s index 164c62524..55cf780d4 100644 --- a/libsrc/runtime/incsp5.s +++ b/libsrc/runtime/incsp5.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/incsp6.s b/libsrc/runtime/incsp6.s index 1a393840e..94c536e7c 100644 --- a/libsrc/runtime/incsp6.s +++ b/libsrc/runtime/incsp6.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/incsp7.s b/libsrc/runtime/incsp7.s index 8a5838137..be8784ecb 100644 --- a/libsrc/runtime/incsp7.s +++ b/libsrc/runtime/incsp7.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/land.s b/libsrc/runtime/land.s index 6ea4e5bcb..8e21ebb60 100644 --- a/libsrc/runtime/land.s +++ b/libsrc/runtime/land.s @@ -10,7 +10,7 @@ .importzp sp, sreg, tmp1 .macpack cpu - + tosand0ax: .if (.cpu .bitand ::CPU_ISET_65SC02) stz sreg @@ -19,7 +19,7 @@ tosand0ax: ldy #$00 sty sreg sty sreg+1 -.endif +.endif tosandeax: .if (.cpu .bitand ::CPU_ISET_65SC02) @@ -29,7 +29,7 @@ tosandeax: ldy #0 and (sp),y ; byte 0 iny -.endif +.endif sta tmp1 txa and (sp),y ; byte 1 diff --git a/libsrc/runtime/ldauisp.s b/libsrc/runtime/ldauisp.s index 1afcf2487..54f4d1bd1 100644 --- a/libsrc/runtime/ldauisp.s +++ b/libsrc/runtime/ldauisp.s @@ -21,4 +21,4 @@ ldauiysp: lda (ptr1),y rts - + diff --git a/libsrc/runtime/leave.s b/libsrc/runtime/leave.s index 4a9ff7994..95dcdec9d 100644 --- a/libsrc/runtime/leave.s +++ b/libsrc/runtime/leave.s @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 06.08.1998 ; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; diff --git a/libsrc/runtime/leq.s b/libsrc/runtime/leq.s index 44316aa08..ac9894b53 100644 --- a/libsrc/runtime/leq.s +++ b/libsrc/runtime/leq.s @@ -7,7 +7,7 @@ .export toseqeax .import toslcmp, booleq -toseqeax: +toseqeax: jsr toslcmp ; Set flags jmp booleq ; Convert to boolean diff --git a/libsrc/runtime/lmod.s b/libsrc/runtime/lmod.s index caeb0c4f6..b8e796dea 100644 --- a/libsrc/runtime/lmod.s +++ b/libsrc/runtime/lmod.s @@ -23,7 +23,7 @@ tosmod0ax: sty sreg+1 .endif -tosmodeax: +tosmodeax: jsr poplsargs ; Get arguments from stack, adjust sign jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4) diff --git a/libsrc/runtime/lmul.s b/libsrc/runtime/lmul.s index d3c34637c..90d5f1e97 100644 --- a/libsrc/runtime/lmul.s +++ b/libsrc/runtime/lmul.s @@ -17,10 +17,10 @@ tosumul0ax: stz sreg stz sreg+1 .else - ldy #$00 + ldy #$00 sty sreg sty sreg+1 -.endif +.endif tosmuleax: tosumuleax: @@ -29,7 +29,7 @@ mul32: sta ptr1 .if (.cpu .bitand ::CPU_ISET_65SC02) lda (sp) ldy #1 -.else +.else ldy #0 lda (sp),y iny diff --git a/libsrc/runtime/lor.s b/libsrc/runtime/lor.s index 94ab3c890..f2204b981 100644 --- a/libsrc/runtime/lor.s +++ b/libsrc/runtime/lor.s @@ -8,7 +8,7 @@ .export tosor0ax, tosoreax .import addysp1 .importzp sp, sreg, tmp1 - + .macpack cpu tosor0ax: @@ -19,7 +19,7 @@ tosor0ax: ldy #$00 sty sreg sty sreg+1 -.endif +.endif tosoreax: .if (.cpu .bitand ::CPU_ISET_65SC02) @@ -29,7 +29,7 @@ tosoreax: ldy #0 ora (sp),y ; byte 0 iny -.endif +.endif sta tmp1 txa ora (sp),y ; byte 1 diff --git a/libsrc/runtime/lpop.s b/libsrc/runtime/lpop.s index ffff5ffc1..a90ea5fcb 100644 --- a/libsrc/runtime/lpop.s +++ b/libsrc/runtime/lpop.s @@ -22,7 +22,7 @@ popeax: ldy #3 tax .if (.cpu .bitand ::CPU_ISET_65SC02) lda (sp) -.else +.else dey lda (sp),y .endif diff --git a/libsrc/runtime/lpush.s b/libsrc/runtime/lpush.s index 4fed77f05..0bc67b523 100644 --- a/libsrc/runtime/lpush.s +++ b/libsrc/runtime/lpush.s @@ -41,9 +41,9 @@ pusheax: pla .if (.cpu .bitand ::CPU_ISET_65SC02) sta (sp) -.else +.else dey sta (sp),y -.endif +.endif rts diff --git a/libsrc/runtime/lrsub.s b/libsrc/runtime/lrsub.s index 928164f40..5e8d0b543 100644 --- a/libsrc/runtime/lrsub.s +++ b/libsrc/runtime/lrsub.s @@ -29,7 +29,7 @@ tosrsubeax: .if (.cpu .bitand ::CPU_ISET_65SC02) sbc (sp) ldy #1 -.else +.else ldy #0 sbc (sp),y ; byte 0 iny diff --git a/libsrc/runtime/lsub.s b/libsrc/runtime/lsub.s index 6f80491ca..4c50ded14 100644 --- a/libsrc/runtime/lsub.s +++ b/libsrc/runtime/lsub.s @@ -21,7 +21,7 @@ tossub0ax: ldy #$00 sty sreg sty sreg+1 -.endif +.endif tossubeax: sec diff --git a/libsrc/runtime/lsubeq.s b/libsrc/runtime/lsubeq.s index 5e3d25783..b16ab18e1 100644 --- a/libsrc/runtime/lsubeq.s +++ b/libsrc/runtime/lsubeq.s @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 07.04.2000 ; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; @@ -22,19 +22,19 @@ lsubeqa: stx sreg+1 lsubeq: sty ptr1+1 ; Store high byte of address - + sec eor #$FF .if (.cpu .bitand ::CPU_ISET_65SC02) adc (ptr1) ; Subtract byte 0 sta (ptr1) - ldy #$01 ; Address byte 1 + ldy #$01 ; Address byte 1 .else ldy #$00 ; Address low byte adc (ptr1),y ; Subtract byte 0 sta (ptr1),y - iny ; Address byte 1 - .endif + iny ; Address byte 1 + .endif pha ; Save byte 0 of result for later txa eor #$FF diff --git a/libsrc/runtime/ltest.s b/libsrc/runtime/ltest.s index 6027b8dd4..d0caf2197 100644 --- a/libsrc/runtime/ltest.s +++ b/libsrc/runtime/ltest.s @@ -17,6 +17,6 @@ utsteax: beq L9 tya ldy #1 ; Force NE -L9: rts +L9: rts diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index 8a3126d72..e2e27371e 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -21,7 +21,7 @@ tosudiv0ax: sty sreg+1 .endif -tosudiveax: +tosudiveax: jsr getlop ; Get the paramameters jsr udiv32 ; Do the division lda ptr1 ; Result is in ptr1:sreg diff --git a/libsrc/runtime/lumod.s b/libsrc/runtime/lumod.s index 241801a90..09909c0c9 100644 --- a/libsrc/runtime/lumod.s +++ b/libsrc/runtime/lumod.s @@ -11,7 +11,7 @@ .macpack cpu -tosumod0ax: +tosumod0ax: .if (.cpu .bitand ::CPU_ISET_65SC02) stz sreg stz sreg+1 diff --git a/libsrc/runtime/lxor.s b/libsrc/runtime/lxor.s index 4ec9a4129..a92a59959 100644 --- a/libsrc/runtime/lxor.s +++ b/libsrc/runtime/lxor.s @@ -25,7 +25,7 @@ tosxoreax: .if (.cpu .bitand ::CPU_ISET_65SC02) eor (sp) ; byte 0 ldy #1 -.else +.else ldy #0 eor (sp),y ; byte 0 iny diff --git a/libsrc/runtime/mul.s b/libsrc/runtime/mul.s index 087e639fc..68cdea0c6 100644 --- a/libsrc/runtime/mul.s +++ b/libsrc/runtime/mul.s @@ -23,7 +23,7 @@ tosumulax: ; Do ptr4:ptr4+1 * ptr1:ptr1+1 --> AX - tya ; A = 0 + tya ; A = 0 ldy ptr1+1 ; check if lhs is 8 bit only beq @L4 ; -> we can do 8x16 after swap sta tmp1 @@ -36,7 +36,7 @@ tosumulax: clc adc ptr1 tax - lda ptr1+1 ; Hi byte of left op + lda ptr1+1 ; Hi byte of left op adc tmp1 sta tmp1 txa diff --git a/libsrc/runtime/mulax3.s b/libsrc/runtime/mulax3.s index 513ba723e..342379605 100644 --- a/libsrc/runtime/mulax3.s +++ b/libsrc/runtime/mulax3.s @@ -7,7 +7,7 @@ .export mulax3 .importzp ptr1 - + .proc mulax3 sta ptr1 diff --git a/libsrc/runtime/or.s b/libsrc/runtime/or.s index 1c2c4125e..735f30f61 100644 --- a/libsrc/runtime/or.s +++ b/libsrc/runtime/or.s @@ -21,7 +21,7 @@ tosorax: ldy #0 ora (sp),y iny -.endif +.endif sta tmp1 txa ora (sp),y diff --git a/libsrc/runtime/pushaff.s b/libsrc/runtime/pushaff.s index 08d988bb2..ae2142b0e 100644 --- a/libsrc/runtime/pushaff.s +++ b/libsrc/runtime/pushaff.s @@ -17,4 +17,4 @@ .endproc - + diff --git a/libsrc/runtime/pushax.s b/libsrc/runtime/pushax.s index cba313c2f..ac181b994 100644 --- a/libsrc/runtime/pushax.s +++ b/libsrc/runtime/pushax.s @@ -30,6 +30,6 @@ pusha0: ldx #0 pla ; (31) dey ; (33) sta (sp),y ; (38) - rts ; (44) + rts ; (44) .endproc diff --git a/libsrc/runtime/return0.s b/libsrc/runtime/return0.s index c061e013c..331f3334f 100644 --- a/libsrc/runtime/return0.s +++ b/libsrc/runtime/return0.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/return1.s b/libsrc/runtime/return1.s index 76153f3e1..e39cdf74e 100644 --- a/libsrc/runtime/return1.s +++ b/libsrc/runtime/return1.s @@ -17,4 +17,4 @@ - + diff --git a/libsrc/runtime/swap.s b/libsrc/runtime/swap.s index d4a74df5f..5358e08d3 100644 --- a/libsrc/runtime/swap.s +++ b/libsrc/runtime/swap.s @@ -23,13 +23,13 @@ swapstk: tay lda ptr4 sta (sp) - tya -.else + tya +.else dey lda (sp),y pha lda ptr4 sta (sp),y pla -.endif +.endif rts ; whew! diff --git a/libsrc/runtime/umod.s b/libsrc/runtime/umod.s index 5788d569e..205df59d7 100644 --- a/libsrc/runtime/umod.s +++ b/libsrc/runtime/umod.s @@ -25,4 +25,4 @@ tosumodax: ldx sreg+1 rts - + diff --git a/libsrc/runtime/umul16x16r32.s b/libsrc/runtime/umul16x16r32.s index cd2dae351..cfcf82d9e 100644 --- a/libsrc/runtime/umul16x16r32.s +++ b/libsrc/runtime/umul16x16r32.s @@ -12,7 +12,7 @@ ;--------------------------------------------------------------------------- ; 16x16 => 32 unsigned multiplication routine. Because the overhead for a -; 16x16 => 16 unsigned multiplication routine is small, we will tag it with +; 16x16 => 16 unsigned multiplication routine is small, we will tag it with ; the matching labels, as well. ; ; routine LHS RHS result result also in diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index c041664da..5f6a71144 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -48,6 +48,6 @@ putch: ldy #$00 ; Put char into return buffer done: lda ptr3 ldx ptr3+1 - rts ; Return count + rts ; Return count .endproc diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s index dbe738468..008902e58 100644 --- a/libsrc/sym1/write.s +++ b/libsrc/sym1/write.s @@ -13,7 +13,7 @@ .proc _write - sta ptr3 + sta ptr3 stx ptr3+1 ; Count in ptr3 inx stx ptr2+1 ; Increment and store in ptr2 diff --git a/libsrc/telestrat/cclear.s b/libsrc/telestrat/cclear.s index b9fce4708..804381e89 100644 --- a/libsrc/telestrat/cclear.s +++ b/libsrc/telestrat/cclear.s @@ -6,9 +6,9 @@ ; .export _cclearxy, _cclear - .import update_adscr, display_conio + .import update_adscr, display_conio - .importzp tmp1 + .importzp tmp1 .import popax .include "telestrat.inc" diff --git a/libsrc/telestrat/chline.s b/libsrc/telestrat/chline.s index 91f3bdc9f..cd7628eca 100644 --- a/libsrc/telestrat/chline.s +++ b/libsrc/telestrat/chline.s @@ -4,7 +4,7 @@ ; .export _chlinexy, _chline - + .import rvs, display_conio, update_adscr .import popax @@ -22,7 +22,7 @@ _chlinexy: _chline: tax ; Is the length zero? beq @L9 ; Jump if done -@L1: +@L1: lda #'-' ; Horizontal line screen code ora rvs diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s index c02c26647..749e40b8f 100644 --- a/libsrc/telestrat/clrscr.s +++ b/libsrc/telestrat/clrscr.s @@ -4,7 +4,7 @@ .export _clrscr .import OLD_CHARCOLOR, OLD_BGCOLOR, BGCOLOR, CHARCOLOR - + .include "telestrat.inc" .proc _clrscr @@ -35,13 +35,13 @@ ldx #$00 stx SCRY stx SCRX - + stx OLD_BGCOLOR ; Black stx BGCOLOR - + ldx #$07 ; White stx OLD_CHARCOLOR stx CHARCOLOR - + rts .endproc diff --git a/libsrc/telestrat/cputc.s b/libsrc/telestrat/cputc.s index 16b13f8cd..13714b32d 100644 --- a/libsrc/telestrat/cputc.s +++ b/libsrc/telestrat/cputc.s @@ -6,7 +6,7 @@ .export _cputc, _cputcxy, cputdirect, display_conio .export CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR - + .import update_adscr .import popax @@ -19,13 +19,13 @@ _cputcxy: sta SCRY ; Store Y stx SCRX ; Store X jsr update_adscr - pla + pla _cputc: cmp #$0D bne @not_CR ldy #$00 - sty SCRX + sty SCRX rts @not_CR: cmp #$0A @@ -80,10 +80,10 @@ do_not_change_color: sty SCRX inc SCRY - + jmp update_adscr - -@no_inc: + +@no_inc: sty SCRX rts .endproc diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index ea7ed5623..c0907a623 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -19,12 +19,12 @@ gotoxy: jsr popa ; Get Y ; In telemon, there is a position for the prompt, and another for the cursor. sta SCRY - + jsr popa sta SCRX -; Update adress video ram position when SCRY is modified (update_adscr) +; Update address video ram position when SCRY is modified (update_adscr) ; Fall through .endproc @@ -48,6 +48,6 @@ skip: sta ADSCR dey bne loop -out: +out: rts .endproc diff --git a/libsrc/telestrat/joy/telestrat.s b/libsrc/telestrat/joy/telestrat.s index e4a6d94f2..0f5d28651 100644 --- a/libsrc/telestrat/joy/telestrat.s +++ b/libsrc/telestrat/joy/telestrat.s @@ -52,7 +52,7 @@ INSTALL: lda #%11000000 sta VIA2::DDRB 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. lda #<JOY_ERR_OK ldx #>JOY_ERR_OK @@ -83,7 +83,7 @@ COUNT: ; PB7 and PB6 select right or left port ; When PB7 and PB6 are high, it controls two CA3083 (2 NPN transistors array) bases. ; In that case, PB0 to PB4 are set to high (it means no action are pressed) -; When the user press something then bit will be set to 0. +; When the user press something then bit will be set to 0. ; Bit 0 is right ; Bit 1 is left ; Bit 2 is fire @@ -94,18 +94,18 @@ READ: lda VIA2::PRB and #%01111111 - ora #%01000000 + ora #%01000000 sta VIA2::PRB ; then read lda VIA2::PRB eor #%01011111 - + rts -right: +right: lda VIA2::PRB and #%10111111 ora #%10000000 - sta VIA2::PRB + sta VIA2::PRB ; then read lda VIA2::PRB diff --git a/libsrc/telestrat/orixhdr.s b/libsrc/telestrat/orixhdr.s index 58e93efbb..78d6c945a 100644 --- a/libsrc/telestrat/orixhdr.s +++ b/libsrc/telestrat/orixhdr.s @@ -24,7 +24,7 @@ .byte $01 ; Version of the header .byte $00,%00000000 ; 6502 only .byte $00,$00 ; Type of language - .byte $00,$00 ; OS version + .byte $00,$00 ; OS version .byte $00 ; Reserved .byte $00 ; Auto or not diff --git a/libsrc/telestrat/sound.s b/libsrc/telestrat/sound.s index 3718debd4..2a786a452 100644 --- a/libsrc/telestrat/sound.s +++ b/libsrc/telestrat/sound.s @@ -33,7 +33,7 @@ sound_bip_keyboard: rts .endproc -.proc _zap +.proc _zap BRK_TELEMON XZAP rts .endproc diff --git a/libsrc/telestrat/syschdir.s b/libsrc/telestrat/syschdir.s index 09763bdbb..6257880b8 100644 --- a/libsrc/telestrat/syschdir.s +++ b/libsrc/telestrat/syschdir.s @@ -11,7 +11,7 @@ .include "telestrat.inc" .include "zeropage.inc" - + __syschdir: ; Throw away all parameters except the name @@ -24,9 +24,9 @@ __syschdir: stx tmp1 ldy tmp1 - + ; Call telemon primitive - + BRK_TELEMON(XPUTCWD) jmp initcwd ; Update cwd diff --git a/libsrc/telestrat/sysmkdir.s b/libsrc/telestrat/sysmkdir.s index 26d97c4b0..259be8d7c 100644 --- a/libsrc/telestrat/sysmkdir.s +++ b/libsrc/telestrat/sysmkdir.s @@ -9,7 +9,7 @@ .include "telestrat.inc" .include "zeropage.inc" - + __sysmkdir: ; Throw away all parameters except the name @@ -19,11 +19,11 @@ __sysmkdir: ; Get name jsr popax - + ; Call telemon primitive - + BRK_TELEMON(XMKDIR) - + rts diff --git a/libsrc/telestrat/tgi/telestrat-228-200-3.s b/libsrc/telestrat/tgi/telestrat-228-200-3.s index 34af597eb..402e04e7e 100644 --- a/libsrc/telestrat/tgi/telestrat-228-200-3.s +++ b/libsrc/telestrat/tgi/telestrat-228-200-3.s @@ -107,7 +107,7 @@ INIT: ; Switch into graphics mode. BRK_TELEMON(XHIRES) - + ; Done, reset the error code. lda #TGI_ERR_OK @@ -255,18 +255,18 @@ GETDEFPALETTE: SETPIXEL: lda #$80 - + SETPIXELSETMODE: sta HRSFB lda X1 sta HRS1 lda Y1 sta HRS2 - - + + BRK_TELEMON(XCURSE) - + rts ; ------------------------------------------------------------------------ @@ -291,7 +291,7 @@ LINE: sta HRS1 lda Y1 sta HRS2 - + lda X2 sta HRS3 lda Y2 @@ -300,14 +300,14 @@ LINE: lda X1+1 sta HRS1+1 - lda Y1+1 + lda Y1+1 sta HRS2+1 lda X2+1 sta HRS3+1 - - lda Y2+1 - sta HRS4+1 + + lda Y2+1 + sta HRS4+1 lda #$FF sta HRSPAT @@ -315,12 +315,12 @@ LINE: BRK_TELEMON(XDRAWA) rts - - + + CIRCLE: ; not done yet rts - + ; ------------------------------------------------------------------------ ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4, using the current drawing color. @@ -364,11 +364,11 @@ OUTTEXT: ; put hires cursor in X & Y lda #$00 jsr SETPIXELSETMODE - - + + ; count the length of the string ldy #$00 -loop: +loop: lda (ptr3),y beq out iny @@ -376,10 +376,10 @@ loop: out: ; XSCHAR routine from telemon needs to have the length of the string in X register ; copy Y register to X register. It could be optimized in 65C02 with TYX - tya + tya tax - - lda ptr3 ; XSCHAR needs in A and Y the adress of the string - ldy ptr3+1 + + lda ptr3 ; XSCHAR needs in A and Y the address of the string + ldy ptr3+1 BRK_TELEMON(XSCHAR) rts diff --git a/libsrc/telestrat/tgi/telestrat-240-200-2.s b/libsrc/telestrat/tgi/telestrat-240-200-2.s index 345f80e0e..d619fc6f1 100644 --- a/libsrc/telestrat/tgi/telestrat-240-200-2.s +++ b/libsrc/telestrat/tgi/telestrat-240-200-2.s @@ -124,7 +124,7 @@ INIT: ; Switch into graphics mode BRK_TELEMON(XHIRES) - + ; Done, reset the error code lda #TGI_ERR_OK @@ -247,17 +247,17 @@ GETDEFPALETTE: ; SETPIXEL: - lda #$80 ; curset on -SETPIXELSETMODE: + lda #$80 ; curset on +SETPIXELSETMODE: sta HRSFB - + lda X1 sta HRS1 lda Y1 sta HRS2 - - - + + + BRK_TELEMON(XCURSE) rts @@ -289,19 +289,19 @@ LINE: sta HRS3 lda Y2 sta HRS4 - + lda X1+1 sta HRS1+1 - lda Y1+1 + lda Y1+1 sta HRS2+1 lda X2+1 sta HRS3+1 - - lda Y2+1 - sta HRS4+1 + + lda Y2+1 + sta HRS4+1 lda #$FF sta HRSPAT @@ -309,11 +309,11 @@ LINE: BRK_TELEMON(XDRAWA) rts - -CIRCLE: + +CIRCLE: ; not done yet - rts - + rts + ; ------------------------------------------------------------------------ ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color. @@ -357,11 +357,11 @@ OUTTEXT: ; put hires cursor in X & Y lda #$00 jsr SETPIXELSETMODE - - + + ; count the length of the string ldy #$00 -loop: +loop: lda (ptr3),y beq out iny @@ -369,10 +369,10 @@ loop: out: ; XSCHAR routine from telemon needs to have the length of the string in X register ; copy Y register to X register. It could be optimized in 65C02 with TYX - tya + tya tax - - lda ptr3 ; XSCHAR needs in A and Y the adress of the string - ldy ptr3+1 + + lda ptr3 ; XSCHAR needs in A and Y the address of the string + ldy ptr3+1 BRK_TELEMON(XSCHAR) rts diff --git a/libsrc/tgi/tgi_clippedline.s b/libsrc/tgi/tgi_clippedline.s index b32b819ec..b0f1dd456 100644 --- a/libsrc/tgi/tgi_clippedline.s +++ b/libsrc/tgi/tgi_clippedline.s @@ -159,7 +159,7 @@ tgi_clip_sign: .res 1 ;---------------------------------------------------------------------------- -; Multiplicate value in y/a by dy, then divide by dx. +; Multiply value in y/a by dy, then divide by dx. ; .code @@ -176,7 +176,7 @@ tgi_clip_sign: .res 1 lda tgi_clip_dy ldx tgi_clip_dy+1 ; rhs - jsr umul16x16r32 ; Multiplicate + jsr umul16x16r32 ; Multiply ; Move the result of the multiplication into ptr1:ptr2 @@ -199,7 +199,7 @@ done: bit tmp1 ;---------------------------------------------------------------------------- -; Multiplicate value in y/a by dx, then divide by dy. +; Multiply value in y/a by dx, then divide by dy. ; .code @@ -216,7 +216,7 @@ done: bit tmp1 lda tgi_clip_dx ldx tgi_clip_dx+1 ; rhs - jsr umul16x16r32 ; Multiplicate + jsr umul16x16r32 ; Multiply ; Move the result of the multiplication into ptr1:ptr2 diff --git a/libsrc/tgi/tgi_gettextheight.s b/libsrc/tgi/tgi_gettextheight.s index 38df6a69a..bd05386c1 100644 --- a/libsrc/tgi/tgi_gettextheight.s +++ b/libsrc/tgi/tgi_gettextheight.s @@ -15,7 +15,7 @@ ; */ ; -.proc _tgi_gettextheight +.proc _tgi_gettextheight ldy _tgi_font bne @L2 ; Jump if vector font diff --git a/libsrc/tgi/tgi_imulround.s b/libsrc/tgi/tgi_imulround.s index 238c69fc8..7b7f25b78 100644 --- a/libsrc/tgi/tgi_imulround.s +++ b/libsrc/tgi/tgi_imulround.s @@ -1,7 +1,7 @@ ; ; Ullrich von Bassewitz, 2009-11-05 ; -; Helper function for graphics functions: Multiply two values, one being +; Helper function for graphics functions: Multiply two values, one being ; an 8.8 fixed point one, and return the rounded and scaled result. ; ; The module has two entry points: One is C callable and expects the @@ -33,7 +33,7 @@ _tgi_imulround: ; ASM callable entry point tgi_imulround: -; Multiplicate +; Multiply jsr imul16x16r32 @@ -60,4 +60,4 @@ tgi_imulround: tya rts - + diff --git a/libsrc/tgi/tgi_lineto.s b/libsrc/tgi/tgi_lineto.s index abe4b3f96..6934bfe2c 100644 --- a/libsrc/tgi/tgi_lineto.s +++ b/libsrc/tgi/tgi_lineto.s @@ -17,7 +17,7 @@ @L1: lda _tgi_curx,y sta tgi_clip_x1,y dey - bpl @L1 + bpl @L1 pla jsr tgi_linepop ; Pop x2/y2 jmp tgi_clippedline ; Call the line clipper diff --git a/libsrc/tgi/tgi_outtext.s b/libsrc/tgi/tgi_outtext.s index 079cea3af..e0a3c6d25 100644 --- a/libsrc/tgi/tgi_outtext.s +++ b/libsrc/tgi/tgi_outtext.s @@ -125,7 +125,7 @@ VectorFont: jsr MoveCursor ; Move the graphics cursor ; Next char in string - + inc text bne @L1 inc text+1 diff --git a/libsrc/tgi/tgi_vectorchar.s b/libsrc/tgi/tgi_vectorchar.s index bd4cc84c4..3e5e6a3dc 100644 --- a/libsrc/tgi/tgi_vectorchar.s +++ b/libsrc/tgi/tgi_vectorchar.s @@ -79,9 +79,9 @@ GetProcessedCoord: jsr GetOp -; Multiplicate with the scale factor. +; Multiply with the scale factor. - jmp tgi_imulround ; Multiplicate, round and scale + jmp tgi_imulround ; Multiply, round and scale ;---------------------------------------------------------------------------- ; Add the base coordinate with offset in Y to the value in A/X @@ -133,7 +133,7 @@ GetProcessedCoord: .code .proc _tgi_vectorchar -; Multiplicate the char value by two and save into Y +; Multiply the char value by two and save into Y asl a tay diff --git a/libsrc/tgi/tgidrv_line.inc b/libsrc/tgi/tgidrv_line.inc index e904b5117..5fd6b229e 100644 --- a/libsrc/tgi/tgidrv_line.inc +++ b/libsrc/tgi/tgidrv_line.inc @@ -269,7 +269,7 @@ abs: ; A/Y := abs (A/Y) cpy #$00 bpl :+ - + ; A/Y := neg (A/Y) neg: clc eor #$FF diff --git a/samples/Makefile b/samples/Makefile index 5c44d1947..9732cfac7 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -154,7 +154,7 @@ endif # Lists of subdirectories # disasm depends on cpp -DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate supervision sym1 cbm +DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 cbm # -------------------------------------------------------------------------- # Lists of executables @@ -199,7 +199,8 @@ EXELIST_atmos = \ ascii \ hello \ mandelbrot \ - sieve + sieve \ + tgidemo EXELIST_bbc = \ notavailable @@ -311,7 +312,7 @@ EXELIST_sim65c02 = $(EXELIST_sim6502) EXELIST_supervision = \ notavailable - + EXELIST_sym1 = \ notavailable @@ -321,7 +322,7 @@ EXELIST_telestrat = \ hello \ mandelbrot \ sieve \ -# tgidemo + tgidemo EXELIST_vic20 = \ ascii \ diff --git a/samples/atari2600/Makefile b/samples/atari2600/Makefile index a02ec9e80..bd2ebc41a 100644 --- a/samples/atari2600/Makefile +++ b/samples/atari2600/Makefile @@ -31,7 +31,7 @@ else CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65) -endif +endif EXELIST_atari2600 = \ hello diff --git a/samples/cbm/Makefile b/samples/cbm/Makefile index 989710932..03387a061 100644 --- a/samples/cbm/Makefile +++ b/samples/cbm/Makefile @@ -31,7 +31,7 @@ else CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65) -endif +endif ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),) ifdef CC65_HOME diff --git a/samples/geos/Makefile b/samples/geos/Makefile index 04de0aaa3..1fc49a873 100644 --- a/samples/geos/Makefile +++ b/samples/geos/Makefile @@ -44,7 +44,7 @@ else CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65) -endif +endif DIRLIST = grc diff --git a/samples/geos/dialog.c b/samples/geos/dialog.c index 27199a493..c3231e855 100644 --- a/samples/geos/dialog.c +++ b/samples/geos/dialog.c @@ -1,4 +1,4 @@ -/* Note: +/* Note: ** This is just a sample piece of code that shows how to use some structs - ** it may not even run. */ @@ -28,5 +28,5 @@ static const dlgBoxStr myDialog = { void main (void) { - DoDlgBox (&myDialog); + DoDlgBox (&myDialog); } diff --git a/samples/geos/filesel.c b/samples/geos/filesel.c index c0a591eb9..fcca258bb 100644 --- a/samples/geos/filesel.c +++ b/samples/geos/filesel.c @@ -1,11 +1,11 @@ /* GEOSLib example - + using DlgBoxFileSelect - + Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl> - + 26.12.1999 */ diff --git a/samples/geos/geosconio.c b/samples/geos/geosconio.c index 963fa06a0..55acac38e 100644 --- a/samples/geos/geosconio.c +++ b/samples/geos/geosconio.c @@ -9,16 +9,16 @@ void main(void) char ch; DlgBoxOk("Now the screen will be", "cleared."); - + clrscr(); - + DlgBoxOk("Now a character will be", "written at 20,20"); - + gotoxy(20, 20); cputc('A'); DlgBoxOk("Now a string will be", "written at 0,1"); - + cputsxy(0, 1, CBOLDON "Just" COUTLINEON "a " CITALICON "string." CPLAINTEXT ); DlgBoxOk("Write text and finish it", "with a dot."); @@ -31,7 +31,7 @@ void main(void) cursor(0); DlgBoxOk("Seems that it is all for conio.", "Let's test mouse routines."); - + mouse_init(1); cputsxy(0, 2, CBOLDON "Now you can't see mouse (press any key)" CPLAINTEXT); mouse_hide(); diff --git a/samples/geos/geosver.c b/samples/geos/geosver.c index 3d68798a2..fa8351e0d 100644 --- a/samples/geos/geosver.c +++ b/samples/geos/geosver.c @@ -57,6 +57,6 @@ void main (void) } Sleep(10*50); - + return; } diff --git a/samples/geos/grc/Makefile b/samples/geos/grc/Makefile index 9dd9ebc5e..ef30a6e03 100644 --- a/samples/geos/grc/Makefile +++ b/samples/geos/grc/Makefile @@ -53,7 +53,7 @@ test.s: test.grc $(GRC) -s test.s test.grc vlir.cvt: vlir.grc vlir0.s vlir1.s vlir2.s -# using seperate calls here for demonstration purposes: +# using separate calls here for demonstration purposes: $(GRC) -t $(SYS) -s vlir.s vlir.grc $(AS) -t $(SYS) vlir.s $(AS) -t $(SYS) vlir0.s @@ -63,7 +63,7 @@ vlir.cvt: vlir.grc vlir0.s vlir1.s vlir2.s # you can also do the above in one command: # $(CL) -t $(SYS) -o vlir.cvt vlir.grc vlir0.s vlir1.s vlir2.s - + clean: @$(DEL) test.s test.h 2>$(NULLDEV) @$(DEL) vlir.s vlir.cvt vlir.c vlir.h 2>$(NULLDEV) diff --git a/samples/geos/hello1.c b/samples/geos/hello1.c index 8dc13d5b4..bd51dd1b9 100644 --- a/samples/geos/hello1.c +++ b/samples/geos/hello1.c @@ -1,11 +1,11 @@ /* GEOSLib example - + Hello, world example - with DBox - + Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl> - + 26.12.1999 */ @@ -18,7 +18,7 @@ void main (void) DlgBoxOk(CBOLDON "Hello, world" CPLAINTEXT, "This is written in C!"); - + // Normal apps exit from main into system's mainloop, and app finish // when user selects it from icons or menu, but here we want to exit // immediately. diff --git a/samples/geos/hello2.c b/samples/geos/hello2.c index 3f148b0b8..ae93fa1a4 100644 --- a/samples/geos/hello2.c +++ b/samples/geos/hello2.c @@ -1,11 +1,11 @@ /* GEOSLib example - + Hello, world example - using graphic functions - + Maciej 'YTM/Alliance' Witkowiak <ytm@friko.onet.pl> - + 26.12.1999 */ @@ -25,18 +25,18 @@ void main (void) SetPattern(0); InitDrawWindow(&wholeScreen); Rectangle(); - + // Now some texts PutString(COUTLINEON "This is compiled using cc65!" CPLAINTEXT, 20, 10); PutString(CBOLDON "This is bold", 30, 10); PutString(CULINEON "and this is bold and underline!", 40, 10); PutString(CPLAINTEXT "This is plain text", 50, 10); - + // Wait for 5 secs... // Note that this is multitasking sleep, and if there are any icons/menus onscreen, // they would be usable, in this case you have only pointer usable Sleep(5*50); - + // Normal apps exit from main into system's mainloop, and app finish // when user selects it from icons or menu, but here we want to exit // immediately. diff --git a/samples/geos/overlay-demo.c b/samples/geos/overlay-demo.c index a37f6bdcb..73ab0e3c0 100644 --- a/samples/geos/overlay-demo.c +++ b/samples/geos/overlay-demo.c @@ -33,7 +33,7 @@ void foo(void) { /* Functions resident in an overlay can access all program variables and ** constants at any time without any precautions because those are never - ** placed in overlays. The string constant "One" is an example for such + ** placed in overlays. The string constant "One" is an example for such ** a constant resident in the main program. */ show("One"); diff --git a/samples/geos/rmvprot.c b/samples/geos/rmvprot.c index 4f8798f98..152f6cf0f 100644 --- a/samples/geos/rmvprot.c +++ b/samples/geos/rmvprot.c @@ -1,12 +1,12 @@ /* GEOSLib example - + This small application removes GEOS disk write protection tag. e.g. boot disk is always protected after boot-up - + Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl> - + 21.03.2000 */ @@ -60,7 +60,7 @@ void main(void) { // Here we clear the screen. Not really needed anyway... GraphicsString(&clearScreen); - + // Get the name of current disk to show it in dialog box GetPtrCurDkNm(diskName); diff --git a/samples/lynx/Makefile b/samples/lynx/Makefile new file mode 100644 index 000000000..b4ef64af0 --- /dev/null +++ b/samples/lynx/Makefile @@ -0,0 +1,59 @@ + +# Run 'make SYS=<target>'; or, set a SYS env. +# var. to build for another target system. +SYS ?= lynx + +# Just the usual way to find out if we're +# using cmd.exe to execute make rules. +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + NULLDEV = nul: + DEL = -del /f +else + NULLDEV = /dev/null + DEL = $(RM) +endif + +ifdef CC65_HOME + AS = $(CC65_HOME)/bin/ca65 + CC = $(CC65_HOME)/bin/cc65 + CL = $(CC65_HOME)/bin/cl65 + LD = $(CC65_HOME)/bin/ld65 +else + AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65) + CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) + CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) + LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) +endif + +EXELIST_lynx = \ + hello.lnx \ + mandelbrot.lnx \ + tgidemo.lnx + +.PHONY: samples clean + +ifneq ($(EXELIST_$(SYS)),) +samples: $(EXELIST_$(SYS)) +else +samples: +# recipe used to skip systems that will not work with any program in this dir +ifeq ($(MAKELEVEL),0) + @echo "info: Lynx tests not available for" $(SYS) +else +# Suppress the "nothing to be done for 'samples' message. + @echo "" > $(NULLDEV) +endif +endif + +.SUFFIXES: +.SUFFIXES: .c .lnx + +%.lnx : %.c + $(CL) -t $(SYS) -Oris -m $*.map -o $@ $< + +clean: + @$(DEL) *.o *.map *.lnx 2>$(NULLDEV) diff --git a/samples/lynx/hello.c b/samples/lynx/hello.c new file mode 100644 index 000000000..5e6832514 --- /dev/null +++ b/samples/lynx/hello.c @@ -0,0 +1,43 @@ +/* Atari Lynx version of samples/hello.c, using TGI instead of conio */ + +#include <tgi.h> + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + +static const char Text[] = "Hello world!"; + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + +void main (void) +{ + unsigned int XMax, YMax; + + tgi_install (tgi_static_stddrv); + tgi_init (); + + /* Set screen color. */ + tgi_setcolor (TGI_COLOR_WHITE); + + /* Clear the screen. */ + tgi_clear(); + + /* Ask for the screen size. */ + XMax = tgi_getmaxx (); + YMax = tgi_getmaxy (); + + /* Draw a frame around the screen. */ + tgi_line (0, 0, XMax, 0); + tgi_lineto (XMax, YMax); + tgi_lineto (0, YMax); + tgi_lineto (0, 0); + + /* Write the greeting in the middle of the screen. */ + tgi_outtextxy ((tgi_getxres () - tgi_gettextwidth (Text)) / 2, + (tgi_getyres () - tgi_gettextheight (Text)) / 2, Text); +} diff --git a/samples/lynx/mandelbrot.c b/samples/lynx/mandelbrot.c new file mode 100644 index 000000000..ce49fbf7a --- /dev/null +++ b/samples/lynx/mandelbrot.c @@ -0,0 +1,86 @@ +/*****************************************************************************\ +** mandelbrot sample program for Atari Lynx ** +** ** +** (w) 2002 by groepaz/hitmen, TGI support by Stefan Haubenthal ** +\*****************************************************************************/ + + + +#include <stdlib.h> +#include <tgi.h> + + + +/* Graphics definitions */ +#define SCREEN_X (tgi_getxres()) +#define SCREEN_Y (tgi_getyres()) +#define MAXCOL (tgi_getcolorcount()) + +#define maxiterations 32 +#define fpshift (10) +#define tofp(_x) ((_x)<<fpshift) +#define fromfp(_x) ((_x)>>fpshift) +#define fpabs(_x) (abs(_x)) + +#define mulfp(_a,_b) ((((signed long)_a)*(_b))>>fpshift) +#define divfp(_a,_b) ((((signed long)_a)<<fpshift)/(_b)) + +/* Use static local variables for speed */ +#pragma static-locals (1); + + + +static void mandelbrot (signed short x1, signed short y1, signed short x2, + signed short y2) +{ + /* */ + register signed short r, r1, i; + register signed short xs, ys, xx, yy; + register signed short x, y; + register unsigned char count; + register unsigned char maxcol = MAXCOL; + + /* Calc stepwidth */ + xs = ((x2 - x1) / (SCREEN_X)); + ys = ((y2 - y1) / (SCREEN_Y)); + + yy = y1; + for (y = 0; y < (SCREEN_Y); y++) { + yy += ys; + xx = x1; + for (x = 0; x < (SCREEN_X); x++) { + xx += xs; + /* Do iterations */ + r = 0; + i = 0; + for (count = 0; (count < maxiterations) && + (fpabs (r) < tofp (2)) && (fpabs (i) < tofp (2)); + ++count) { + r1 = (mulfp (r, r) - mulfp (i, i)) + xx; + /* i = (mulfp(mulfp(r,i),tofp(2)))+yy; */ + i = (((signed long) r * i) >> (fpshift - 1)) + yy; + r = r1; + } + if (count == maxiterations) { + tgi_setcolor (0); + } else { + tgi_setcolor (count % maxcol); + } + /* Set pixel */ + tgi_setpixel (x, y); + } + } +} + +void main (void) +{ + /* Install the graphics driver */ + tgi_install (tgi_static_stddrv); + + /* Initialize graphics */ + tgi_init (); + tgi_clear (); + + /* Calc mandelbrot set */ + mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2)); +} diff --git a/samples/lynx/tgidemo.c b/samples/lynx/tgidemo.c new file mode 100644 index 000000000..e92a078dc --- /dev/null +++ b/samples/lynx/tgidemo.c @@ -0,0 +1,179 @@ +/* Tgidemo modified for the Atari Lynx. +** +** Press any of the Lynx's option buttons to go to the next screen. +*/ + +#include <cc65.h> +#include <conio.h> +#include <tgi.h> +#include <time.h> + + +#define COLOR_BACK TGI_COLOR_BLACK +#define COLOR_FORE TGI_COLOR_WHITE + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Driver stuff */ +static unsigned MaxX; +static unsigned MaxY; +static unsigned AspectRatio; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +/* The Lynx draws too fast. This function delays +** the drawing so that we can watch it. +*/ +static void wait (unsigned char ticks) +{ + clock_t T = clock () + ticks; + + while (clock () < T) {} +} + + + +static void DoCircles (void) +{ + unsigned char I; + unsigned char Color = COLOR_BACK; + const unsigned X = MaxX / 2; + const unsigned Y = MaxY / 2; + const unsigned Limit = (X < Y) ? Y : X; + + tgi_setcolor (COLOR_FORE); + tgi_clear (); + + tgi_line (0, 0, MaxX, MaxY); + tgi_line (0, MaxY, MaxX, 0); + while (!kbhit ()) { + Color = (Color == COLOR_FORE) ? COLOR_BACK : COLOR_FORE; + tgi_setcolor (Color); + for (I = 10; I <= Limit; I += 10) { + tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio)); + wait (9); + } + } + + cgetc (); +} + + + +static void DoCheckerboard (void) +{ + unsigned X, Y; + unsigned char Color = COLOR_BACK; + + tgi_clear (); + + while (1) { + for (Y = 0; Y <= MaxY - 2; Y += 10) { + for (X = 0; X <= MaxX; X += 10) { + Color = (Color == COLOR_FORE) ? COLOR_BACK : COLOR_FORE; + tgi_setcolor (Color); + tgi_bar (X, Y, X+9, Y+9); + if (kbhit ()) { + cgetc (); + return; + } + wait (1); + } + Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE; + } + Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE; + } +} + + + +static void DoDiagram (void) +{ + int XOrigin, YOrigin; + int Amp; + int X, Y; + unsigned I; + + tgi_setcolor (COLOR_FORE); + tgi_clear (); + + /* Determine zero and amplitude */ + YOrigin = MaxY / 2; + XOrigin = 10; + Amp = (MaxY - 19) / 2; + + /* Y axis */ + tgi_line (XOrigin, 10, XOrigin, MaxY-10); + tgi_line (XOrigin-2, 12, XOrigin, 10); + tgi_lineto (XOrigin+2, 12); + + /* X axis */ + tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin); + tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin); + tgi_lineto (MaxX-12, YOrigin+2); + + /* Sine */ + tgi_gotoxy (XOrigin, YOrigin); + for (I = 0; I <= 360; ++I) { + /* Calculate the next points */ + X = (int)(((long)(MaxX - 19) * I) / 360); + Y = (int)(((long)Amp * -_sin (I)) / 256); + + /* Draw the line */ + tgi_lineto (XOrigin + X, YOrigin + Y); + } + + cgetc (); +} + + + +static void DoLines (void) +{ + unsigned X; + const unsigned Min = (MaxX < MaxY) ? MaxX : MaxY; + + tgi_setcolor (COLOR_FORE); + tgi_clear (); + + for (X = 0; X <= Min; X += 10) { + tgi_line (0, 0, Min, X); + tgi_line (0, 0, X, Min); + tgi_line (Min, Min, 0, Min-X); + tgi_line (Min, Min, Min-X, 0); + wait (9); + } + + cgetc (); +} + + + +void main (void) +{ + /* Install the driver */ + tgi_install (tgi_static_stddrv); + tgi_init (); + + /* Get stuff from the driver */ + MaxX = tgi_getmaxx (); + MaxY = tgi_getmaxy (); + AspectRatio = tgi_getaspectratio (); + + /* Do graphics stuff */ + DoCircles (); + DoCheckerboard (); + DoDiagram (); + DoLines (); +} diff --git a/samples/multidemo.c b/samples/multidemo.c index 396d7344a..02bb6fcac 100644 --- a/samples/multidemo.c +++ b/samples/multidemo.c @@ -237,7 +237,7 @@ void main (void) /* The linker makes sure that the call to foo() ends up at the right mem ** addr. However it's up to user to make sure that the - right - overlay - ** is actually loaded before making the the call. + ** is actually loaded before making the call. */ foo (); } diff --git a/samples/overlaydemo.c b/samples/overlaydemo.c index 7553f3d0e..dde6b70ab 100644 --- a/samples/overlaydemo.c +++ b/samples/overlaydemo.c @@ -112,7 +112,7 @@ void main (void) /* The linker makes sure that the call to foo() ends up at the right mem ** addr. However it's up to user to make sure that the - right - overlay - ** is actually loaded before making the the call. + ** is actually loaded before making the call. */ foo (); } diff --git a/samples/readme.txt b/samples/readme.txt index 506cd5d43..1a5b1c9ff 100644 --- a/samples/readme.txt +++ b/samples/readme.txt @@ -128,7 +128,7 @@ Platforms: Runs on all platforms that have TGI support: ============================================================================= -Platform specific samples follow: +Platform-specific samples follow: atari 2600: ----------- @@ -198,6 +198,27 @@ Name: nachtm Description: Plays "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart. ----------------------------------------------------------------------------- +lynx: +----- + +These programs are adapted for the Atari Lynx because its library has no conio +output or stdio. + +Name: hello +Description: A nice "Hello world" type program that uses the TGI graphics + library for output. + +Name: mandelbrot +Description: A mandelbrot demo using integer arithmetic. The demo was + written by groepaz, and converted to cc65 using TGI graphics + by Stefan Haubenthal. + +Name: tgidemo +Description: Shows some of the graphics capabilities of the "Tiny Graphics + Interface". + +----------------------------------------------------------------------------- + sym1: ----- diff --git a/samples/supervision/Makefile b/samples/supervision/Makefile index 5829b3f01..097329384 100644 --- a/samples/supervision/Makefile +++ b/samples/supervision/Makefile @@ -31,7 +31,7 @@ else CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65) -endif +endif EXELIST_supervision = \ hello diff --git a/samples/sym1/Makefile b/samples/sym1/Makefile index 14da90ad3..281b5bcd0 100644 --- a/samples/sym1/Makefile +++ b/samples/sym1/Makefile @@ -32,7 +32,7 @@ else endif EXELIST_sym1 = \ - symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin + symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin symExtendedMemory.bin ifneq ($(EXELIST_$(SYS)),) samples: $(EXELIST_$(SYS)) @@ -64,9 +64,14 @@ symIO.bin: symIO.c symNotepad.bin: symNotepad.c $(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c +symExtendedMemory.bin: symExtendedMemory.c + $(CL) -t sym1 -C sym1-32k.cfg -O -o symExtendedMemory.bin symExtendedMemory.c + + clean: @$(DEL) symHello.bin 2>$(NULLDEV) @$(DEL) symTiny.bin 2>$(NULLDEV) @$(DEL) symDisplay.bin 2>$(NULLDEV) @$(DEL) symIO.bin 2>$(NULLDEV) @$(DEL) symNotepad.bin 2>$(NULLDEV) + @$(DEL) symExtendedMemory.bin 2>$(NULLDEV) diff --git a/samples/sym1/symDisplay.c b/samples/sym1/symDisplay.c index dce39f6b9..43d18f911 100644 --- a/samples/sym1/symDisplay.c +++ b/samples/sym1/symDisplay.c @@ -14,7 +14,7 @@ int main (void) { int flashes = 255; int displayable = 1; int e = 0; - int r = 0; + int r = 0; int d = 0; int i = 0; int l = 0; @@ -40,7 +40,7 @@ int main (void) { puts ("\n\nHow many times (0 for forever) to repeat?"); c = getchar(); if ( (c >= '0') && (c <= '9') ) {// between 1 and 9 loops allowed - z = 1; // a number was pressed + z = 1; // a number was pressed t = c - '0'; // convert char to int puts ("\n\nLook at the front panel.\n"); } diff --git a/samples/sym1/symExtendedMemory.c b/samples/sym1/symExtendedMemory.c new file mode 100644 index 000000000..897276e6f --- /dev/null +++ b/samples/sym1/symExtendedMemory.c @@ -0,0 +1,101 @@ +// -------------------------------------------------------------------------- +// Sym-1 Extended Memory +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- +// +// Note: This program examines memory above the monitor ROM (8000-8FFF) to +// Determine what, if any, memory is available. It then adds whatever +// 4K segments it finds to the heap. +// +// Memory Segment Remark +// 0x9000 Usually available +// 0xA000 System I/O, always unavailable +// 0xB000 Used by RAE, but normally available +// 0xC000 Used by BASIC, normally unavailable +// 0xD000 Used by BASIC, normally unavailable +// 0xE000 Used by RAE, but normally available +// 0xF000 Normally available, but only to FF7F +// +// -------------------------------------------------------------------------- + +#include <sym1.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define STD_MEM 0x7FFF // Last address of standard memory +#define SEGMENT 0x9000 // First 4K segment of extended memory +#define SEG_END 0x0FFF // Last location of segment +#define BLOCK_SIZE 0x1000 // Size of segment +#define TOP_END 0x0F7F // Last location of memory +#define TOP_SIZE 0x0F80 // Size of top segment +#define UNAVAILABLE 0xA000 // System I/O area + +int main (void) { + int error = 0; + unsigned heap_size = 0x0000; + char* segment = (char*) SEGMENT; + + printf ( "Analyzing memory.\n\n" ); + + heap_size = _heapmemavail(); + + printf ( "Main memory has %u bytes available.\n", heap_size ); + + if ( heap_size > STD_MEM ) { + printf ( "Extended memory already installed.\n" ); + } else { + + while ( (int) segment < 0xEFFF ) { // Iterate through 4K memory blocks + if( (int) segment != UNAVAILABLE ) { + segment[0] = 0x00; // Check beginning of segment + if ( segment[0] != 0x00 ) + error = 1; + segment[0] = 0xFF; + if ( segment[0] != 0xFF ) + error = 1; + segment[SEG_END] = 0x00; // Check end of segment + if ( segment[SEG_END] != 0x00 ) + error = 1; + segment[SEG_END] = 0xFF; + if ( segment[SEG_END] != 0xFF ) + error = 1; + if ( ! error ) { // If memory found, add to the heap + printf ( "Memory found at location %p, ", segment ); + _heapadd ( segment, BLOCK_SIZE ); + heap_size = _heapmemavail(); + printf( "so the system now has %u bytes available.\n", heap_size ); + } else { + error = 0; + } + } + segment += 0x1000; // Increment to next segment + } + + segment[0] = 0x00; // Check beginning of top memory segment + if ( segment[0] != 0x00 ) + error = 1; + segment[0] = 0xFF; + if ( segment[0] != 0xFF ) + error = 1; + segment[TOP_END] = 0x00; // Check end of usable memory + if ( segment[TOP_END] != 0x00 ) + error = 1; + segment[TOP_END] = 0xFF; + if ( segment[TOP_END] != 0xFF ) + error = 1; + if ( ! error ) { // If memory found, add to the heap + printf ( "Memory found at location %p, ", segment ); + _heapadd ( segment, TOP_SIZE ); + heap_size = _heapmemavail(); + printf( "so the system now has %u bytes available.\n", heap_size ); + } + } + + puts ("\nEnjoy your day!\n"); + + return 0; +} diff --git a/samples/sym1/symIO.c b/samples/sym1/symIO.c index 50fefc303..bb46dc3df 100644 --- a/samples/sym1/symIO.c +++ b/samples/sym1/symIO.c @@ -52,7 +52,7 @@ int main (void) { ior3b = VIA3.prb; puts ("================== Digital I/O Status =================="); - puts (" Port1A Port1B Port2A Port2B Port3A Port3B" ); + puts (" Port1A Port1B Port2A Port2B Port3A Port3B" ); printf ("DDR %02X %02X %02X %02X %02X %02X\n\r",ddr1a,ddr1b,ddr2a,ddr2b,ddr3a,ddr3b); printf ("IOR %02X %02X %02X %02X %02X %02X\n\r",ior1a,ior1b,ior2a,ior2b,ior3a,ior3b); puts ("========================================================\n"); @@ -75,7 +75,7 @@ int main (void) { cmd[strlen(cmd)-1] = '\0'; if ( strncasecmp(cmd, "quit", 4) == 0 ) { - going = 0; + going = 0; } else if ( strncasecmp(cmd, "help", 4) == 0 ) { instr = 1; diff --git a/samples/sym1/symNotepad.c b/samples/sym1/symNotepad.c index 1d0541ab6..6fb6db902 100644 --- a/samples/sym1/symNotepad.c +++ b/samples/sym1/symNotepad.c @@ -68,7 +68,7 @@ int main (void) { } else { memset ( tapio, 0, TAPIO_MAX_SIZE ); - } + } while ( running ) { @@ -138,21 +138,21 @@ int main (void) { } else { - for ( l = 0; l <= heap_size; l++ ) { - buffer[l] = tapio[l]; - } + for ( l = 0; l <= heap_size; l++ ) { + buffer[l] = tapio[l]; + } - p = strlen ( buffer ); + p = strlen ( buffer ); - putchar ( '\r' ); - for ( l = 0; l < 25; l++ ) { - putchar ( '\n' ); - } - puts ("===================== Sym-1 Notepad ====================\n"); + putchar ( '\r' ); + for ( l = 0; l < 25; l++ ) { + putchar ( '\n' ); + } + puts ("===================== Sym-1 Notepad ====================\n"); - for ( l = 0; l <= p; l++ ) { - putchar ( buffer[l] ); - } + for ( l = 0; l <= p; l++ ) { + putchar ( buffer[l] ); + } } } else if ( c == 0x03 ) { // Clear diff --git a/samples/tgidemo.c b/samples/tgidemo.c index b431cfb98..f193a1b83 100644 --- a/samples/tgidemo.c +++ b/samples/tgidemo.c @@ -68,7 +68,7 @@ static void DoWarning (void) static void DoCircles (void) { - static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_ORANGE }; + static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLUE }; unsigned char I; unsigned char Color = COLOR_BACK; const unsigned X = MaxX / 2; diff --git a/samples/tutorial/Makefile b/samples/tutorial/Makefile index 67dd84003..eb8627c29 100644 --- a/samples/tutorial/Makefile +++ b/samples/tutorial/Makefile @@ -29,7 +29,7 @@ else CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) -endif +endif EXELIST_atari2600 = \ notavailable diff --git a/src/Makefile b/src/Makefile index 87f1e8236..c8028204b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -119,6 +119,7 @@ endif # CMD_EXE zip: @cd .. && zip cc65 bin/* + @echo 'https://github.com/cc65/cc65/commits/'$(word 2,$(BUILD_ID))|zip -zq ../cc65 define OBJS_template diff --git a/src/ar65/del.h b/src/ar65/del.h index 6100fe60a..dd45d0ec5 100644 --- a/src/ar65/del.h +++ b/src/ar65/del.h @@ -49,6 +49,6 @@ void DelObjFiles (int argc, char* argv []); -/* End of del.h */ +/* End of del.h */ #endif diff --git a/src/ca65/anonname.c b/src/ca65/anonname.c index 90b73fcab..fca20c8cd 100644 --- a/src/ca65/anonname.c +++ b/src/ca65/anonname.c @@ -72,7 +72,7 @@ StrBuf* AnonName (StrBuf* Buf, const char* Spec) int IsAnonName (const StrBuf* Name) /* Check if the given symbol name is that of an anonymous symbol */ -{ +{ if (SB_GetLen (Name) < sizeof (AnonTag) - 1) { /* Too short */ return 0; diff --git a/src/ca65/anonname.h b/src/ca65/anonname.h index 142cd9f87..7d5671c68 100644 --- a/src/ca65/anonname.h +++ b/src/ca65/anonname.h @@ -58,7 +58,7 @@ StrBuf* AnonName (StrBuf* Buf, const char* Spec); int IsAnonName (const StrBuf* Name); /* Check if the given symbol name is that of an anonymous symbol */ - + /* End of anonname.h */ diff --git a/src/ca65/easw16.c b/src/ca65/easw16.c index 578a25734..081828991 100644 --- a/src/ca65/easw16.c +++ b/src/ca65/easw16.c @@ -147,4 +147,4 @@ void GetSweet16EA (EffAddr* A) } - + diff --git a/src/ca65/easw16.h b/src/ca65/easw16.h index b8b06d466..03a48c437 100644 --- a/src/ca65/easw16.h +++ b/src/ca65/easw16.h @@ -65,4 +65,4 @@ void GetSweet16EA (EffAddr* A); - + diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 74133d533..812b6e90c 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -1708,7 +1708,7 @@ ExprNode* GenLiteralExpr (long Val) ExprNode* GenLiteral0 (void) -/* Return an expression tree that encodes the the number zero */ +/* Return an expression tree that encodes the number zero */ { return GenLiteralExpr (0); } diff --git a/src/ca65/expr.h b/src/ca65/expr.h index 16dffd901..b18fabb01 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -81,7 +81,7 @@ ExprNode* GenLiteralExpr (long Val); /* Return an expression tree that encodes the given literal value */ ExprNode* GenLiteral0 (void); -/* Return an expression tree that encodes the the number zero */ +/* Return an expression tree that encodes the number zero */ ExprNode* GenSymExpr (struct SymEntry* Sym); /* Return an expression node that encodes the given symbol */ diff --git a/src/ca65/instr.c b/src/ca65/instr.c index faeff2026..834edfb5f 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -303,9 +303,9 @@ static const struct { } }; -/* Instruction table for the 6502 with DTV extra opcodes (DTV) and +/* Instruction table for the 6502 with DTV extra opcodes (DTV) and ** those illegal instructions (X) which are supported by DTV. -** Note: illegals opcodes which contain more subinstructions +** Note: illegals opcodes which contain more subinstructions ** (ASO, DCM, LSE, LXA, SBX and SHS) are not enlisted. */ static const struct { @@ -1207,9 +1207,9 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A) } else { ED.AddrSize = DataAddrSize; /* If the default address size of the data segment is unequal - ** to zero page addressing, but zero page addressing is - ** allowed by the instruction, mark all symbols in the - ** expression tree. This mark will be checked at end of + ** to zero page addressing, but zero page addressing is + ** allowed by the instruction, mark all symbols in the + ** expression tree. This mark will be checked at end of ** assembly, and a warning is issued, if a zero page symbol ** was guessed wrong here. */ diff --git a/src/ca65/instr.h b/src/ca65/instr.h index 0a1a5e13d..fe18d2110 100644 --- a/src/ca65/instr.h +++ b/src/ca65/instr.h @@ -101,7 +101,7 @@ /* Bitmask for all FAR operations */ #define AM65_ALL_FAR (AM65_ABS_LONG | AM65_ABS_LONG_X) - + /* Bitmask for all immediate operations */ #define AM65_ALL_IMM (AM65_IMM_ACCU | AM65_IMM_INDEX | AM65_IMM_IMPLICIT | AM65_IMM_IMPLICIT_WORD) diff --git a/src/ca65/istack.c b/src/ca65/istack.c index 8cda7dd2f..7a95e7e8c 100644 --- a/src/ca65/istack.c +++ b/src/ca65/istack.c @@ -81,7 +81,7 @@ void PushInput (int (*Func) (void*), void* Data, const char* Desc) /* Check for a stack overflow */ if (ICount > ISTACK_MAX) { Fatal ("Maximum input stack nesting exceeded"); - } + } /* Create a new stack element */ E = xmalloc (sizeof (*E)); diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c index e6707dac4..4f29a29d2 100644 --- a/src/ca65/lineinfo.c +++ b/src/ca65/lineinfo.c @@ -429,7 +429,7 @@ void ReleaseFullLineInfo (Collection* LineInfos) /* Walk over all entries */ for (I = 0; I < CollCount (LineInfos); ++I) { - /* Release the the line info */ + /* Release the line info */ ReleaseLineInfo (CollAt (LineInfos, I)); } diff --git a/src/ca65/macro.c b/src/ca65/macro.c index d6c807035..0bdc89b5b 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -637,7 +637,7 @@ void MacUndef (const StrBuf* Name, unsigned char Style) static int MacExpand (void* Data) -/* If we're currently expanding a macro, set the the scanner token and +/* If we're currently expanding a macro, set the scanner token and ** attribute to the next value and return true. If we are not expanding ** a macro, return false. */ diff --git a/src/ca65/macro.h b/src/ca65/macro.h index bb7b817a8..7f4335706 100644 --- a/src/ca65/macro.h +++ b/src/ca65/macro.h @@ -62,7 +62,7 @@ struct StrBuf; struct Macro; typedef struct Macro Macro; - + /*****************************************************************************/ /* Code */ diff --git a/src/ca65/main.c b/src/ca65/main.c index 0eaf4ba6b..b1ef3a3db 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -212,6 +212,10 @@ static void SetSys (const char* Sys) NewSymbol ("__ATARI5200__", 1); break; + case TGT_ATARI7800: + NewSymbol ("__ATARI7800__", 1); + break; + case TGT_ATARI: NewSymbol ("__ATARI__", 1); break; diff --git a/src/ca65/options.c b/src/ca65/options.c index c71296a57..84d7148be 100644 --- a/src/ca65/options.c +++ b/src/ca65/options.c @@ -182,4 +182,4 @@ void WriteOptions (void) - + diff --git a/src/ca65/span.c b/src/ca65/span.c index a4faea121..5ab3fc955 100644 --- a/src/ca65/span.c +++ b/src/ca65/span.c @@ -204,7 +204,7 @@ static Span* MergeSpan (Span* S) void SetSpanType (Span* S, const StrBuf* Type) /* Set the generic type of the span to Type */ -{ +{ /* Ignore the call if we won't generate debug infos */ if (DbgSyms) { S->Type = GetStrBufId (Type); @@ -354,7 +354,7 @@ static int CollectSpans (void* Entry, void* Data) return 0; } - + void WriteSpans (void) /* Write all spans to the object file */ diff --git a/src/ca65/studyexpr.c b/src/ca65/studyexpr.c index 6d8734c9e..2a345a07c 100644 --- a/src/ca65/studyexpr.c +++ b/src/ca65/studyexpr.c @@ -711,7 +711,7 @@ static void StudyMul (ExprNode* Expr, ExprDesc* D) */ if (ED_IsConst (D) && ED_IsValid (&Right)) { - /* Multiplicate both, result goes into Right */ + /* Multiply both, result goes into Right */ ED_Mul (&Right, D); /* Move result into D */ @@ -719,7 +719,7 @@ static void StudyMul (ExprNode* Expr, ExprDesc* D) } else if (ED_IsConst (&Right) && ED_IsValid (D)) { - /* Multiplicate both */ + /* Multiply both */ ED_Mul (D, &Right); } else { diff --git a/src/ca65/studyexpr.h b/src/ca65/studyexpr.h index 389bce5a3..a81f6c9c8 100644 --- a/src/ca65/studyexpr.h +++ b/src/ca65/studyexpr.h @@ -36,7 +36,7 @@ #ifndef STUDYEXPR_H #define STUDYEXPR_H - + /* common */ #include "exprdefs.h" diff --git a/src/ca65/symbol.c b/src/ca65/symbol.c index 3b06fd1a2..f1c259082 100644 --- a/src/ca65/symbol.c +++ b/src/ca65/symbol.c @@ -187,7 +187,7 @@ SymEntry* ParseScopedSymName (SymFindAction Action) ** may not expect NULL to be returned if Action contains SYM_ALLOC_NEW, ** create a new symbol. */ - if (Action & SYM_ALLOC_NEW) { + if (Action & SYM_ALLOC_NEW) { Sym = NewSymEntry (&Ident, SF_NONE); } else { Sym = 0; diff --git a/src/ca65/ulabel.c b/src/ca65/ulabel.c index 9712f4942..1127c3743 100644 --- a/src/ca65/ulabel.c +++ b/src/ca65/ulabel.c @@ -160,7 +160,7 @@ void ULabDef (void) */ ULabel* L = CollAtUnchecked (&ULabList, ULabDefCount); CHECK (L->Val == 0); - L->Val = GenCurrentPC (); + L->Val = GenCurrentPC (); ReleaseFullLineInfo (&L->LineInfos); GetFullLineInfo (&L->LineInfos); } else { @@ -200,7 +200,7 @@ ExprNode* ULabResolve (unsigned Index) void ULabDone (void) -/* Run through all unnamed labels, check for anomalies and errors and do +/* Run through all unnamed labels, check for anomalies and errors and do ** necessary cleanups. */ { diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 14500296d..5cddc1862 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -93,6 +93,7 @@ <ClInclude Include="cc65\hexval.h" /> <ClInclude Include="cc65\ident.h" /> <ClInclude Include="cc65\incpath.h" /> + <ClInclude Include="cc65\initdata.h" /> <ClInclude Include="cc65\input.h" /> <ClInclude Include="cc65\lineinfo.h" /> <ClInclude Include="cc65\litpool.h" /> @@ -170,6 +171,7 @@ <ClCompile Include="cc65\hexval.c" /> <ClCompile Include="cc65\ident.c" /> <ClCompile Include="cc65\incpath.c" /> + <ClCompile Include="cc65\initdata.c" /> <ClCompile Include="cc65\input.c" /> <ClCompile Include="cc65\lineinfo.c" /> <ClCompile Include="cc65\litpool.c" /> diff --git a/src/cc65/assignment.c b/src/cc65/assignment.c index 05a6d9a96..e6d1e4526 100644 --- a/src/cc65/assignment.c +++ b/src/cc65/assignment.c @@ -156,19 +156,8 @@ void DoIncDecBitField (ExprDesc* Expr, long Val, unsigned KeepResult) unsigned ChunkFlags; const Type* ChunkType; - /* If the bit-field fits within one byte, do the following operations - ** with bytes. - */ - if ((Expr->Type->A.B.Width - 1U) / CHAR_BITS == - (Expr->Type->A.B.Offs + Expr->Type->A.B.Width - 1U) / CHAR_BITS) { - ChunkType = GetUnderlyingType (Expr->Type); - } else { - /* We use the declarartion integer type as the chunk type. - ** Note: A bit-field will not occupy bits located in bytes more than - ** that of its declaration type in cc65. So this is OK. - */ - ChunkType = Expr->Type + 1; - } + /* Determine the type to operate on the whole byte chunk containing the bit-field */ + ChunkType = GetBitFieldChunkType (Expr->Type); /* Determine code generator flags */ Flags = TypeOf (Expr->Type) | CF_FORCECHAR; @@ -254,19 +243,8 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op ED_Init (&Expr2); Expr2.Flags |= Expr->Flags & E_MASK_KEEP_SUBEXPR; - /* If the bit-field fits within one byte, do the following operations - ** with bytes. - */ - if ((Expr->Type->A.B.Width - 1U) / CHAR_BITS == - (Expr->Type->A.B.Offs + Expr->Type->A.B.Width - 1U) / CHAR_BITS) { - ChunkType = GetUnderlyingType (Expr->Type); - } else { - /* We use the declarartion integer type as the chunk type. - ** Note: A bit-field will not occupy bits located in bytes more than - ** that of its declaration type in cc65. So this is OK. - */ - ChunkType = Expr->Type + 1; - } + /* Determine the type to operate on the whole byte chunk containing the bit-field */ + ChunkType = GetBitFieldChunkType (Expr->Type); /* Determine code generator flags */ Flags = TypeOf (Expr->Type) | CF_FORCECHAR; @@ -620,8 +598,8 @@ void OpAssign (const GenDesc* Gen, ExprDesc* Expr, const char* Op) if (IsClassStruct (ltype)) { /* Copy the struct or union by value */ CopyStruct (Expr, &Expr2); - } else if (IsTypeBitField (ltype)) { - /* Special care is needed for bit-field 'op=' */ + } else if (IsTypeFragBitField (ltype)) { + /* Special care is needed for bit-fields if they don't fit in full bytes */ OpAssignBitField (Gen, Expr, Op); } else { /* Normal straight 'op=' */ diff --git a/src/cc65/casenode.c b/src/cc65/casenode.c index f5e751f08..e7da64995 100644 --- a/src/cc65/casenode.c +++ b/src/cc65/casenode.c @@ -95,7 +95,7 @@ void FreeCaseNodeColl (Collection* Nodes) int SearchCaseNode (const Collection* Nodes, unsigned char Key, int* Index) /* Search for a node in the given collection. If the node has been found, ** set Index to the index of the node and return true. If the node was not -** found, set Index the the insertion position of the node and return +** found, set Index the insertion position of the node and return ** false. */ { diff --git a/src/cc65/casenode.h b/src/cc65/casenode.h index aef546f19..df80e62fd 100644 --- a/src/cc65/casenode.h +++ b/src/cc65/casenode.h @@ -116,7 +116,7 @@ void FreeCaseNodeColl (Collection* Nodes); int SearchCaseNode (const Collection* Nodes, unsigned char Key, int* Index); /* Search for a node in the given collection. If the node has been found, ** set Index to the index of the node and return true. If the node was not -** found, set Index the the insertion position of the node and return +** found, set Index to the insertion position of the node and return ** false. */ diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index 0a1b917db..62118d80c 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -1781,7 +1781,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) if (RegValIsKnown (In->RegX)) { Out->RegX = (In->RegX ^ 0xFF); } - } else if (strncmp (E->Arg, "asrax", 5) == 0 || + } else if (strncmp (E->Arg, "asrax", 5) == 0 || strncmp (E->Arg, "shrax", 5) == 0) { if (RegValIsKnown (In->RegX)) { if (In->RegX == 0x00 || In->RegX == 0xFF) { diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index cf10314b9..c79863d0e 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -33,6 +33,7 @@ +#include <inttypes.h> #include <limits.h> #include <stdio.h> #include <string.h> @@ -42,7 +43,7 @@ #include "addrsize.h" #include "check.h" #include "cpu.h" -#include "inttypes.h" +#include "shift.h" #include "strbuf.h" #include "xmalloc.h" #include "xsprintf.h" @@ -689,7 +690,7 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes) -void g_getimmed (unsigned Flags, unsigned long Val, long Offs) +void g_getimmed (unsigned Flags, uintptr_t Val, long Offs) /* Load a constant into the primary register */ { unsigned char B1, B2, B3, B4; @@ -1409,7 +1410,7 @@ static unsigned g_intpromotion (unsigned flags) unsigned g_typeadjust (unsigned lhs, unsigned rhs) /* Adjust the integer operands before doing a binary operation. lhs is a flags ** value, that corresponds to the value on TOS, rhs corresponds to the value -** in (e)ax. The return value is the the flags value for the resulting type. +** in (e)ax. The return value is the flags value for the resulting type. */ { /* Get the type spec from the flags */ @@ -4394,7 +4395,7 @@ void g_res (unsigned n) -void g_defdata (unsigned flags, unsigned long val, long offs) +void g_defdata (unsigned flags, uintptr_t val, long offs) /* Define data with the size given in flags */ { if (flags & CF_CONST) { @@ -4403,15 +4404,15 @@ void g_defdata (unsigned flags, unsigned long val, long offs) switch (flags & CF_TYPEMASK) { case CF_CHAR: - AddDataLine ("\t.byte\t$%02lX", val & 0xFF); + AddDataLine ("\t.byte\t$%02"PRIXPTR, val & 0xFF); break; case CF_INT: - AddDataLine ("\t.word\t$%04lX", val & 0xFFFF); + AddDataLine ("\t.word\t$%04"PRIXPTR, val & 0xFFFF); break; case CF_LONG: - AddDataLine ("\t.dword\t$%08lX", val & 0xFFFFFFFF); + AddDataLine ("\t.dword\t$%08"PRIXPTR, val & 0xFFFFFFFF); break; default: @@ -4560,110 +4561,268 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size) void g_testbitfield (unsigned Flags, unsigned BitOffs, unsigned BitWidth) -/* Test bit-field in ax. */ +/* Test bit-field in primary. */ { - unsigned EndBit = BitOffs + BitWidth; + /* Since the end is inclusive and cannot be negative here, we subtract 1 from the sum */ + unsigned MSBit = BitOffs + BitWidth - 1U; + unsigned Bytes = MSBit / CHAR_BITS + 1U - BitOffs / CHAR_BITS; + unsigned HeadMask = (0xFF << (BitOffs % CHAR_BITS)) & 0xFF; + unsigned TailMask = ((1U << (MSBit % CHAR_BITS + 1U)) - 1U) & 0xFF; + unsigned UntestedBytes = ((1U << Bytes) - 1U) << (BitOffs / CHAR_BITS); + + /* We don't use these flags for now. Could CF_NOKEEP be potentially interesting? */ + Flags &= ~CF_STYPEMASK; /* If we need to do a test, then we avoid shifting (ASR only shifts one bit at a time, - ** so is slow) and just AND with the appropriate mask, then test the result of that. + ** so is slow) and just AND the head and tail bytes with the appropriate mask, then + ** OR the results with the rest bytes. */ - - /* Avoid overly large shift on host platform. */ - if (EndBit == sizeof (unsigned long) * CHAR_BIT) { - g_and (Flags | CF_CONST, (~0UL << BitOffs)); - } else { - g_and (Flags | CF_CONST, ((1UL << EndBit) - 1) & (~0UL << BitOffs)); + if (Bytes == 1) { + HeadMask = TailMask = HeadMask & TailMask; } - /* TODO: When long bit-fields are supported, an optimization to test only 3 bytes when - ** EndBit <= 24 is possible. - */ - g_test (Flags | CF_CONST); + /* Get the head byte */ + switch (BitOffs / CHAR_BITS) { + case 0: + if (HeadMask == 0xFF && Bytes == 1) { + AddCodeLine ("tax"); + UntestedBytes &= ~0x1; + } + break; + case 1: + if (HeadMask != 0xFF || TailMask == 0xFF) { + AddCodeLine ("txa"); + UntestedBytes &= ~0x2; + } + break; + case 2: + if (HeadMask != 0xFF || TailMask == 0xFF) { + AddCodeLine ("lda sreg"); + UntestedBytes &= ~0x4; + } + break; + case 3: + /* In this case we'd have HeadMask == TailMask and only 1 byte, but anyways... */ + if (HeadMask != 0xFF || TailMask == 0xFF) { + AddCodeLine ("lda sreg+1"); + UntestedBytes &= ~0x8; + } + break; + default: + break; + } + + /* Keep in mind that the head is NOT always "Byte 0" */ + if (HeadMask != 0xFF) { + AddCodeLine ("and #$%02X", HeadMask); + /* Abuse the "Byte 0" flag so that this head content will be saved by the routine */ + UntestedBytes |= 0x1; + } + + /* If there is only 1 byte to test, we have done with it */ + if (Bytes == 1) { + return; + } + + /* Handle the tail byte */ + if (TailMask != 0xFF) { + /* If we have to do any more masking operation, register A will be used for that, + ** and its current content in it must be saved. + */ + if (UntestedBytes & 0x1) { + AddCodeLine ("sta tmp1"); + } + + /* Test the tail byte */ + switch (MSBit / CHAR_BITS) { + case 1: + AddCodeLine ("txa"); + UntestedBytes &= ~0x2; + break; + case 2: + AddCodeLine ("lda sreg"); + UntestedBytes &= ~0x4; + break; + case 3: + AddCodeLine ("lda sreg+1"); + UntestedBytes &= ~0x8; + break; + default: + break; + } + AddCodeLine ("and #$%02X", TailMask); + + if (UntestedBytes & 0x1) { + AddCodeLine ("ora tmp1"); + } + } + + /* OR the rest bytes together, which could never need masking */ + if (UntestedBytes & 0x2) { + AddCodeLine ("stx tmp1"); + AddCodeLine ("ora tmp1"); + } + if (UntestedBytes & 0x4) { + AddCodeLine ("ora sreg"); + } + if (UntestedBytes & 0x8) { + AddCodeLine ("ora sreg+1"); + } } void g_extractbitfield (unsigned Flags, unsigned FullWidthFlags, int IsSigned, unsigned BitOffs, unsigned BitWidth) -/* Extract bits from bit-field in ax. */ +/* Extract bits from bit-field in primary. */ { unsigned EndBit = BitOffs + BitWidth; + unsigned long ZeroExtendMask = 0; /* Zero if we don't need to zero-extend. */ /* Shift right by the bit offset; no code is emitted if BitOffs is zero */ g_asr (Flags | CF_CONST, BitOffs); - /* Since we have now shifted down, we could do char ops when the width fits in a char, but we - ** also need to clear (or set) the high byte since we've been using CF_FORCECHAR up to now. - */ - unsigned Mask = (1U << BitWidth) - 1; - /* To zero-extend, we will and by the width if the field doesn't end on a char or ** int boundary. If it does end on a boundary, then zeros will have already been shifted in, ** but we need to clear the high byte for char. g_and emits no code if the mask is all ones. ** This is here so the signed and unsigned branches can use it. */ - unsigned ZeroExtendMask = 0; /* Zero if we don't need to zero-extend. */ if (EndBit == CHAR_BITS) { /* We need to clear the high byte, since CF_FORCECHAR was set. */ ZeroExtendMask = 0xFF; - } else if (EndBit != INT_BITS) { - ZeroExtendMask = (1U << BitWidth) - 1; + } else if (EndBit != INT_BITS && EndBit != LONG_BITS) { + ZeroExtendMask = shl_l (1UL, BitWidth) - 1UL; } /* Handle signed bit-fields. */ if (IsSigned) { - /* Save .A because the sign-bit test will destroy it. */ - AddCodeLine ("tay"); - - /* Check sign bit */ unsigned SignBitPos = BitWidth - 1U; unsigned SignBitByte = SignBitPos / CHAR_BITS; unsigned SignBitPosInByte = SignBitPos % CHAR_BITS; - unsigned SignBitMask = 1U << SignBitPosInByte; - /* Move the correct byte to .A. This can be only .X for now, - ** but more cases will be needed to support long. - */ - switch (SignBitByte) { - case 0: - break; - case 1: - AddCodeLine ("txa"); - break; - default: - FAIL ("Invalid Byte for sign bit"); - } - - /* Test the sign bit */ - AddCodeLine ("and #$%02X", SignBitMask); - unsigned ZeroExtendLabel = GetLocalLabel (); - AddCodeLine ("beq %s", LocalLabelName (ZeroExtendLabel)); - - /* Get back .A and sign-extend if required; operating on the full result needs - ** to sign-extend into the high byte, too. - */ - AddCodeLine ("tya"); - g_or (FullWidthFlags | CF_CONST, ~Mask); - - /* We can generate a branch, instead of a jump, here because we know - ** that only a few instructions will be put between here and where - ** DoneLabel will be defined. - */ - unsigned DoneLabel = GetLocalLabel (); - g_branch (DoneLabel); - - /* Get back .A, then zero-extend. We need to duplicate the TYA, rather than move it before - ** the branch to share with the other label, because TYA changes some condition codes. - */ - g_defcodelabel (ZeroExtendLabel); - AddCodeLine ("tya"); - - /* Zero the upper bits, the same as the unsigned path. */ if (ZeroExtendMask != 0) { - g_and (FullWidthFlags | CF_CONST, ZeroExtendMask); - } + /* The universal trick is: + ** x = bits & bit_mask + ** m = 1 << (bit_width - 1) + ** r = (x ^ m) - m + ** which works for long as well. + */ - g_defcodelabel (DoneLabel); + if (SignBitByte + 1U == sizeofarg (FullWidthFlags)) { + /* We can just sign-extend on the high byte if it is the only affected one */ + unsigned char SignBitMask = (1UL << SignBitPosInByte) & 0xFF; + unsigned char Mask = ((2UL << (SignBitPos % CHAR_BITS)) - 1UL) & 0xFF; + + /* Move the correct byte to .A */ + switch (SignBitByte) { + case 0: + break; + case 1: + AddCodeLine ("tay"); + AddCodeLine ("txa"); + break; + case 3: + AddCodeLine ("tay"); + AddCodeLine ("lda sreg+1"); + break; + default: + FAIL ("Invalid Byte for sign bit"); + } + + /* Use .A to do the ops on the correct byte */ + AddCodeLine ("and #$%02X", Mask); + AddCodeLine ("eor #$%02X", SignBitMask); + AddCodeLine ("sec"); + AddCodeLine ("sbc #$%02X", SignBitMask); + + /* Move the correct byte from .A */ + switch (SignBitByte) { + case 0: + break; + case 1: + AddCodeLine ("tax"); + AddCodeLine ("tya"); + break; + case 3: + AddCodeLine ("sta sreg+1"); + AddCodeLine ("tya"); + break; + default: + FAIL ("Invalid Byte for sign bit"); + } + } else { + unsigned long SignBitMask = 1UL << SignBitPos; + unsigned long Mask = (2UL << SignBitPos) - 1UL; + g_and (FullWidthFlags | CF_CONST, Mask); + g_xor (FullWidthFlags | CF_CONST, SignBitMask); + g_dec (FullWidthFlags | CF_CONST, SignBitMask); + } + } else { + unsigned char SignBitMask = (1UL << SignBitPosInByte) & 0xFF; + unsigned ZeroExtendLabel = GetLocalLabel (); + + /* Save .A because the sign-bit test will destroy it. */ + AddCodeLine ("tay"); + + /* Move the correct byte to .A */ + switch (SignBitByte) { + case 0: + break; + case 1: + AddCodeLine ("txa"); + break; + case 3: + AddCodeLine ("lda sreg+1"); + break; + default: + FAIL ("Invalid Byte for sign bit"); + } + + /* Test the sign bit */ + AddCodeLine ("and #$%02X", SignBitMask); + AddCodeLine ("beq %s", LocalLabelName (ZeroExtendLabel)); + + if (SignBitByte + 1U == sizeofarg (FullWidthFlags)) { + /* We can just sign-extend on the high byte if it is the only affected one */ + unsigned char Mask = ~((2UL << (SignBitPos % CHAR_BITS)) - 1UL) & 0xFF; + + /* Use .A to do the ops on the correct byte */ + switch (SignBitByte) { + case 0: + AddCodeLine ("tya"); + AddCodeLine ("ora #$%02X", Mask); + /* We could jump over the following tya instead, but that wouldn't be faster + ** than taking this extra tay and then the tya. + */ + AddCodeLine ("tay"); + break; + case 1: + AddCodeLine ("txa"); + AddCodeLine ("ora #$%02X", Mask); + AddCodeLine ("tax"); + break; + case 3: + AddCodeLine ("lda sreg+1"); + AddCodeLine ("ora #$%02X", Mask); + AddCodeLine ("sta sreg+1"); + break; + default: + FAIL ("Invalid Byte for sign bit"); + } + } else { + /* Since we are going to get back .A later anyways, we may just do the op on the + ** higher bytes with whatever content currently in it. + */ + unsigned long Mask = ~((2UL << SignBitPos) - 1UL); + g_or (FullWidthFlags | CF_CONST, Mask); + } + + /* Get back .A. We need to duplicate the TYA, rather than move it before + ** the branch to share with the other label, because TYA changes some condition codes. + */ + g_defcodelabel (ZeroExtendLabel); + AddCodeLine ("tya"); + } } else { /* Unsigned bit-field, needs only zero-extension. */ if (ZeroExtendMask != 0) { diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index d6d3d2370..cb62d78bd 100644 --- a/src/cc65/codegen.h +++ b/src/cc65/codegen.h @@ -37,10 +37,10 @@ #define CODEGEN_H +#include <inttypes.h> /* common */ #include "coll.h" -#include "inttypes.h" /* cc65 */ #include "segments.h" @@ -217,7 +217,7 @@ void g_reglong (unsigned Flags); unsigned g_typeadjust (unsigned lhs, unsigned rhs); /* Adjust the integer operands before doing a binary operation. lhs is a flags ** value, that corresponds to the value on TOS, rhs corresponds to the value -** in (e)ax. The return value is the the flags value for the resulting type. +** in (e)ax. The return value is the flags value for the resulting type. */ unsigned g_typecast (unsigned lhs, unsigned rhs); @@ -271,7 +271,7 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes); -void g_getimmed (unsigned Flags, unsigned long Val, long Offs); +void g_getimmed (unsigned Flags, uintptr_t Val, long Offs); /* Load a constant into the primary register */ void g_getstatic (unsigned Flags, uintptr_t Label, long Offs); @@ -461,7 +461,7 @@ void g_ge (unsigned flags, unsigned long val); void g_res (unsigned n); /* Reserve static storage, n bytes */ -void g_defdata (unsigned flags, unsigned long val, long offs); +void g_defdata (unsigned flags, uintptr_t val, long offs); /* Define data with the size given in flags */ void g_defbytes (const void* bytes, unsigned count); @@ -486,11 +486,11 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size); /*****************************************************************************/ void g_testbitfield (unsigned Flags, unsigned BitOffs, unsigned BitWidth); -/* Test bit-field in ax. */ +/* Test bit-field in primary. */ void g_extractbitfield (unsigned Flags, unsigned FullWidthFlags, int IsSigned, unsigned BitOffs, unsigned BitWidth); -/* Extract bits from bit-field in ax. */ +/* Extract bits from bit-field in primary. */ /*****************************************************************************/ /* Switch statement */ diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 94dfc3ffb..85c9bd5a4 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -56,6 +56,7 @@ #include "funcdesc.h" #include "function.h" #include "global.h" +#include "initdata.h" #include "input.h" #include "litpool.h" #include "macrotab.h" diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index fda23ae0a..92401a858 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -309,10 +309,10 @@ unsigned OptCmp1 (CodeSeg* S) /* Insert the ora instead */ X = NewCodeEntry (OP65_ORA, L[0]->AM, L[0]->Arg, 0, L[0]->LI); - CS_InsertEntry (S, X, I); + CS_InsertEntry (S, X, I+3); /* Remove all other instructions */ - CS_DelEntries (S, I+1, 3); + CS_DelEntries (S, I, 3); /* Remember, we had changes */ ++Changes; diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index e5d3f8d96..e43af238e 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -551,6 +551,24 @@ unsigned long GetIntegerTypeMax (const Type* Type) +static unsigned GetBitFieldMinimalTypeSize (unsigned BitWidth) +/* Return the size of the smallest integer type that may have BitWidth bits */ +{ + /* Since all integer types supported in cc65 for bit-fields have sizes that + ** are powers of 2, we can just use this bit-twiddling trick. + */ + unsigned V = (int)(BitWidth - 1U) / (int)CHAR_BITS; + V |= V >> 1; + V |= V >> 2; + V |= V >> 4; + V |= V >> 8; + V |= V >> 16; + + /* Return the result size */ + return V + 1U; +} + + static unsigned TypeOfBySize (unsigned Size) /* Get the code generator replacement type of the object by its size */ { @@ -591,8 +609,7 @@ const Type* GetUnderlyingType (const Type* Type) ** bit-field, instead of the type used in the declaration, the truly ** underlying of the bit-field. */ - unsigned Size = (int)(Type->A.B.Width - 1) / (int)CHAR_BITS + 1; - switch (Size) { + switch (GetBitFieldMinimalTypeSize (Type->A.B.Width)) { case SIZEOF_CHAR: Type = IsSignSigned (Type) ? type_schar : type_uchar; break; case SIZEOF_INT: Type = IsSignSigned (Type) ? type_int : type_uint; break; case SIZEOF_LONG: Type = IsSignSigned (Type) ? type_long : type_ulong; break; @@ -646,8 +663,7 @@ TypeCode GetUnderlyingTypeCode (const Type* Type) ** bit-field, instead of the type used in the declaration, the truly ** underlying of the bit-field. */ - unsigned Size = (int)(Type->A.B.Width - 1) / (int)CHAR_BITS + 1; - switch (Size) { + switch (GetBitFieldMinimalTypeSize (Type->A.B.Width)) { case SIZEOF_CHAR: Underlying = T_CHAR; break; case SIZEOF_INT: Underlying = T_INT; break; case SIZEOF_LONG: Underlying = T_LONG; break; @@ -663,6 +679,39 @@ TypeCode GetUnderlyingTypeCode (const Type* Type) +const Type* GetBitFieldChunkType (const Type* Type) +/* Get the type needed to operate on the byte chunk containing the bit-field */ +{ + unsigned ChunkSize; + if ((Type->A.B.Width - 1U) / CHAR_BITS == + (Type->A.B.Offs + Type->A.B.Width - 1U) / CHAR_BITS) { + /* T bit-field fits within its underlying type */ + return GetUnderlyingType (Type); + } + + ChunkSize = GetBitFieldMinimalTypeSize (Type->A.B.Offs + Type->A.B.Width); + if (ChunkSize < SizeOf (Type + 1)) { + /* The end of the bit-field is offset by some bits so that it requires + ** more bytes to be accessed as a whole than its underlying type does. + ** Note: In cc65 the bit offset is always less than CHAR_BITS. + */ + switch (ChunkSize) { + case SIZEOF_CHAR: return IsSignSigned (Type) ? type_schar : type_uchar; + case SIZEOF_INT: return IsSignSigned (Type) ? type_int : type_uint; + case SIZEOF_LONG: return IsSignSigned (Type) ? type_long : type_ulong; + default: return IsSignSigned (Type) ? type_int : type_uint; + } + } + + /* We can always use the declarartion integer type as the chunk type. + ** Note: A bit-field will not occupy bits located in bytes more than that + ** of its declaration type in cc65. So this is OK. + */ + return Type + 1; +} + + + unsigned SizeOf (const Type* T) /* Compute size of object represented by type array. */ { @@ -967,9 +1016,18 @@ const Type* IntPromotion (const Type* T) */ if (IsTypeBitField (T)) { - /* The standard rule is OK for now as we don't support bit-fields with widths > 16. + /* As we now support long bit-fields, we need modified rules for them: + ** - If an int can represent all values of the bit-field, the bit-field is converted + ** to an int; + ** - Otherwise, if an unsigned int can represent all values of the bit-field, the + ** bit-field is converted to an unsigned int; + ** - Otherwise, the bit-field will have its declared integer type. + ** These rules are borrowed from C++ and seem to be consistent with GCC/Clang's. */ - return T->A.B.Width >= INT_BITS && IsSignUnsigned (T) ? type_uint : type_int; + if (T->A.B.Width > INT_BITS) { + return IsSignUnsigned (T) ? type_ulong : type_long; + } + return T->A.B.Width == INT_BITS && IsSignUnsigned (T) ? type_uint : type_int; } else if (IsTypeChar (T)) { /* An integer can represent all values from either signed or unsigned char, so convert ** chars to int. @@ -1105,7 +1163,7 @@ Type* NewBitFieldType (const Type* T, unsigned BitOffs, unsigned BitWidth) /* The type specifier must be integeral */ CHECK (IsClassInt (T)); - + /* Allocate the new type string */ P = TypeAlloc (3); @@ -1127,6 +1185,15 @@ Type* NewBitFieldType (const Type* T, unsigned BitOffs, unsigned BitWidth) +int IsTypeFragBitField (const Type* T) +/* Return true if this is a bit-field that shares byte space with other fields */ +{ + return IsTypeBitField (T) && + (T->A.B.Offs != 0 || T->A.B.Width != CHAR_BITS * SizeOf (T)); +} + + + int IsClassObject (const Type* T) /* Return true if this is a fully described object type */ { diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index e36d7c82e..c60023944 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -313,6 +313,9 @@ TypeCode GetUnderlyingTypeCode (const Type* Type); ** Return TCode if it is not scalar. */ +const Type* GetBitFieldChunkType (const Type* Type); +/* Get the type needed to operate on the byte chunk containing the bit-field */ + unsigned SizeOf (const Type* T); /* Compute size of object represented by type array. */ @@ -556,6 +559,9 @@ INLINE int IsTypeBitField (const Type* T) # define IsTypeBitField(T) (IsTypeSignedBitField (T) || IsTypeUnsignedBitField (T)) #endif +int IsTypeFragBitField (const Type* T); +/* Return true if this is a bit-field that shares byte space with other fields */ + #if defined(HAVE_INLINE) INLINE int IsTypeStruct (const Type* T) /* Return true if this is a struct type */ diff --git a/src/cc65/declare.c b/src/cc65/declare.c index fa4c52818..7cc7444b6 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -66,22 +66,6 @@ -/*****************************************************************************/ -/* Data */ -/*****************************************************************************/ - - - -typedef struct StructInitData StructInitData; -struct StructInitData { - unsigned Size; /* Size of struct */ - unsigned Offs; /* Current offset in struct */ - unsigned BitVal; /* Summed up bit-field value */ - unsigned ValBits; /* Valid bits in Val */ -}; - - - /*****************************************************************************/ /* Forwards */ /*****************************************************************************/ @@ -92,9 +76,6 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers, int* SignednessSpecified); /* Parse a type specifier */ -static unsigned ParseInitInternal (Type* T, int* Braces, int AllowFlexibleMembers); -/* Parse initialization of variables. Return the number of data bytes. */ - /*****************************************************************************/ @@ -765,12 +746,10 @@ static int ParseFieldWidth (Declaration* D) D->Type[0].C = T_INT; } - /* TODO: This can be relaxed to be any integral type, but - ** ParseStructInit currently supports only up to int. - */ - if (SizeOf (D->Type) > SizeOf (type_uint)) { - /* Only int-sized or smaller types may be used for bit-fields, for now */ - Error ("cc65 currently supports only char-sized and int-sized bit-field types"); + /* We currently support integral types up to long */ + if (SizeOf (D->Type) > SizeOf (type_ulong)) { + /* Only long-sized or smaller types may be used for bit-fields, for now */ + Error ("cc65 currently supports only long-sized and smaller bit-field types"); /* Avoid a diagnostic storm */ D->Type[0].C = T_INT; @@ -2121,704 +2100,3 @@ void CheckEmptyDecl (const DeclSpec* D) Warning ("Useless declaration"); } } - - - -static void SkipInitializer (int BracesExpected) -/* Skip the remainder of an initializer in case of errors. Try to be somewhat -** smart so we don't have too many following errors. -*/ -{ - while (CurTok.Tok != TOK_CEOF && CurTok.Tok != TOK_SEMI && BracesExpected >= 0) { - switch (CurTok.Tok) { - case TOK_RCURLY: --BracesExpected; break; - case TOK_LCURLY: ++BracesExpected; break; - default: break; - } - if (BracesExpected >= 0) { - NextToken (); - } - } -} - - - -static unsigned OpeningCurlyBraces (unsigned BracesNeeded) -/* Accept any number of opening curly braces around an initialization, skip -** them and return the number. If the number of curly braces is less than -** BracesNeeded, issue a warning. -*/ -{ - unsigned BraceCount = 0; - while (CurTok.Tok == TOK_LCURLY) { - ++BraceCount; - NextToken (); - } - if (BraceCount < BracesNeeded) { - Error ("'{' expected"); - } - return BraceCount; -} - - - -static void ClosingCurlyBraces (unsigned BracesExpected) -/* Accept and skip the given number of closing curly braces together with -** an optional comma. Output an error messages, if the input does not contain -** the expected number of braces. -*/ -{ - while (BracesExpected) { - /* TODO: Skip all excess initializers until next closing curly brace */ - if (CurTok.Tok == TOK_RCURLY) { - NextToken (); - } else if (CurTok.Tok == TOK_COMMA && NextTok.Tok == TOK_RCURLY) { - NextToken (); - NextToken (); - } else { - Error ("'}' expected"); - return; - } - --BracesExpected; - } -} - - - -static void DefineData (ExprDesc* Expr) -/* Output a data definition for the given expression */ -{ - switch (ED_GetLoc (Expr)) { - - case E_LOC_NONE: - /* Immediate numeric value with no storage */ - g_defdata (CF_IMM | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); - break; - - case E_LOC_ABS: - /* Absolute numeric address */ - g_defdata (CF_ABSOLUTE | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); - break; - - case E_LOC_GLOBAL: - /* Global variable */ - g_defdata (CF_EXTERNAL, Expr->Name, Expr->IVal); - break; - - case E_LOC_STATIC: - /* Static variable */ - g_defdata (CF_STATIC, Expr->Name, Expr->IVal); - break; - - case E_LOC_LITERAL: - /* Literal in the literal pool */ - g_defdata (CF_LITERAL, Expr->Name, Expr->IVal); - break; - - case E_LOC_REGISTER: - /* Register variable. Taking the address is usually not - ** allowed. - */ - if (IS_Get (&AllowRegVarAddr) == 0) { - Error ("Cannot take the address of a register variable"); - } - g_defdata (CF_REGVAR, Expr->Name, Expr->IVal); - break; - - case E_LOC_CODE: - /* Code label location */ - g_defdata (CF_CODE, Expr->Name, Expr->IVal); - break; - - case E_LOC_STACK: - case E_LOC_PRIMARY: - case E_LOC_EXPR: - Error ("Non constant initializer"); - break; - - default: - Internal ("Unknown constant type: 0x%04X", ED_GetLoc (Expr)); - } -} - - - -static void DefineBitFieldData (StructInitData* SI) -/* Output bit field data */ -{ - /* Ignore if we have no data */ - if (SI->ValBits > 0) { - - /* Output the data */ - g_defdata (CF_CHAR | CF_UNSIGNED | CF_CONST, SI->BitVal, 0); - - /* Update the data from SI and account for the size */ - if (SI->ValBits >= CHAR_BITS) { - SI->BitVal >>= CHAR_BITS; - SI->ValBits -= CHAR_BITS; - } else { - SI->BitVal = 0; - SI->ValBits = 0; - } - SI->Offs += SIZEOF_CHAR; - } -} - - - -static void DefineStrData (Literal* Lit, unsigned Count) -{ - /* Translate into target charset */ - TranslateLiteral (Lit); - - /* Output the data */ - g_defbytes (GetLiteralStr (Lit), Count); -} - - - -static ExprDesc ParseScalarInitInternal (const Type* T) -/* Parse initializaton for scalar data types. This function will not output the -** data but return it in ED. -*/ -{ - /* Optional opening brace */ - unsigned BraceCount = OpeningCurlyBraces (0); - - /* We warn if an initializer for a scalar contains braces, because this is - ** quite unusual and often a sign for some problem in the input. - */ - if (BraceCount > 0) { - Warning ("Braces around scalar initializer"); - } - - /* Get the expression and convert it to the target type */ - ExprDesc ED = NoCodeConstExpr (hie1); - TypeConversion (&ED, T); - - /* Close eventually opening braces */ - ClosingCurlyBraces (BraceCount); - - return ED; -} - - - -static unsigned ParseScalarInit (const Type* T) -/* Parse initializaton for scalar data types. Return the number of data bytes. */ -{ - /* Parse initialization */ - ExprDesc ED = ParseScalarInitInternal (T); - - /* Output the data */ - DefineData (&ED); - - /* Do this anyways for safety */ - DoDeferred (SQP_KEEP_NONE, &ED); - - /* Done */ - return SizeOf (T); -} - - - -static unsigned ParsePointerInit (const Type* T) -/* Parse initializaton for pointer data types. Return the number of data bytes. */ -{ - /* Optional opening brace */ - unsigned BraceCount = OpeningCurlyBraces (0); - - /* Expression */ - ExprDesc ED = NoCodeConstExpr (hie1); - TypeConversion (&ED, T); - - /* Output the data */ - DefineData (&ED); - - /* Do this anyways for safety */ - DoDeferred (SQP_KEEP_NONE, &ED); - - /* Close eventually opening braces */ - ClosingCurlyBraces (BraceCount); - - /* Done */ - return SIZEOF_PTR; -} - - - -static unsigned ParseArrayInit (Type* T, int* Braces, int AllowFlexibleMembers) -/* Parse initializaton for arrays. Return the number of data bytes. */ -{ - int Count; - int HasCurly = 0; - - /* Get the array data */ - Type* ElementType = IndirectModifiable (T); - unsigned ElementSize = SizeOf (ElementType); - long ElementCount = GetElementCount (T); - - /* Special handling for a character array initialized by a literal */ - if (IsClassChar (ElementType) && - (CurTok.Tok == TOK_SCONST || CurTok.Tok == TOK_WCSCONST || - (CurTok.Tok == TOK_LCURLY && - (NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) { - - /* Char array initialized by string constant */ - int NeedParen; - - /* If we initializer is enclosed in brackets, remember this fact and - ** skip the opening bracket. - */ - NeedParen = (CurTok.Tok == TOK_LCURLY); - if (NeedParen) { - NextToken (); - } - - /* If the array is one too small for the string literal, omit the - ** trailing zero. - */ - Count = GetLiteralSize (CurTok.SVal); - if (ElementCount != UNSPECIFIED && - ElementCount != FLEXIBLE && - Count == ElementCount + 1) { - /* Omit the trailing zero */ - --Count; - } - - /* Output the data */ - DefineStrData (CurTok.SVal, Count); - - /* Skip the string */ - NextToken (); - - /* If the initializer was enclosed in curly braces, we need a closing - ** one. - */ - if (NeedParen) { - ConsumeRCurly (); - } - - } else { - - /* Arrays can be initialized without a pair of curly braces */ - if (*Braces == 0 || CurTok.Tok == TOK_LCURLY) { - /* Consume the opening curly brace */ - HasCurly = ConsumeLCurly (); - *Braces += HasCurly; - } - - /* Initialize the array members */ - Count = 0; - while (CurTok.Tok != TOK_RCURLY) { - /* Flexible array members may not be initialized within - ** an array (because the size of each element may differ - ** otherwise). - */ - ParseInitInternal (ElementType, Braces, 0); - ++Count; - if (CurTok.Tok != TOK_COMMA) - break; - NextToken (); - } - - if (HasCurly) { - /* Closing curly braces */ - ConsumeRCurly (); - } - } - - /* Size of 'void' elements are determined after initialization */ - if (ElementSize == 0) { - ElementSize = SizeOf (ElementType); - } - - if (ElementCount == UNSPECIFIED) { - /* Number of elements determined by initializer */ - SetElementCount (T, Count); - ElementCount = Count; - } else if (ElementCount == FLEXIBLE) { - if (AllowFlexibleMembers) { - /* In non ANSI mode, allow initialization of flexible array - ** members. - */ - ElementCount = Count; - } else { - /* Forbid */ - Error ("Initializing flexible array member is forbidden"); - ElementCount = Count; - } - } else if (Count < ElementCount) { - g_zerobytes ((ElementCount - Count) * ElementSize); - } else if (Count > ElementCount && HasCurly) { - Error ("Excess elements in array initializer"); - } - return ElementCount * ElementSize; -} - - - -static unsigned ParseStructInit (Type* T, int* Braces, int AllowFlexibleMembers) -/* Parse initialization of a struct or union. Return the number of data bytes. */ -{ - SymEntry* Sym; - SymTable* Tab; - StructInitData SI; - int HasCurly = 0; - int SkipComma = 0; - - - /* Fields can be initialized without a pair of curly braces */ - if (*Braces == 0 || CurTok.Tok == TOK_LCURLY) { - /* Consume the opening curly brace */ - HasCurly = ConsumeLCurly (); - *Braces += HasCurly; - } - - /* Get a pointer to the struct entry from the type */ - Sym = GetESUSymEntry (T); - - /* Get the size of the struct from the symbol table entry */ - SI.Size = Sym->V.S.Size; - - /* Check if this struct definition has a field table. If it doesn't, it - ** is an incomplete definition. - */ - Tab = Sym->V.S.SymTab; - if (Tab == 0) { - Error ("Cannot initialize variables with incomplete type"); - /* Try error recovery */ - SkipInitializer (HasCurly); - /* Nothing initialized */ - return 0; - } - - /* Get a pointer to the list of symbols */ - Sym = Tab->SymHead; - - /* Initialize fields */ - SI.Offs = 0; - SI.BitVal = 0; - SI.ValBits = 0; - while (CurTok.Tok != TOK_RCURLY) { - - /* Check for excess elements */ - if (Sym == 0) { - /* Is there just one trailing comma before a closing curly? */ - if (NextTok.Tok == TOK_RCURLY && CurTok.Tok == TOK_COMMA) { - /* Skip comma and exit scope */ - NextToken (); - break; - } - - if (HasCurly) { - Error ("Excess elements in %s initializer", GetBasicTypeName (T)); - SkipInitializer (HasCurly); - } - return SI.Offs; - } - - /* Check for special members that don't consume the initializer */ - if ((Sym->Flags & SC_ALIAS) == SC_ALIAS) { - /* Just skip */ - goto NextMember; - } - - /* This may be an anonymous bit-field, in which case it doesn't - ** have an initializer. - */ - if (SymIsBitField (Sym) && (IsAnonName (Sym->Name))) { - /* Account for the data and output it if we have at least a full - ** word. We may have more if there was storage unit overlap, for - ** example two consecutive 10 bit fields. These will be packed - ** into 3 bytes. - */ - SI.ValBits += Sym->Type->A.B.Width; - /* TODO: Generalize this so any type can be used. */ - CHECK (SI.ValBits <= CHAR_BITS + INT_BITS - 2); - while (SI.ValBits >= CHAR_BITS) { - DefineBitFieldData (&SI); - } - /* Avoid consuming the comma if any */ - goto NextMember; - } - - /* Skip comma this round */ - if (SkipComma) { - NextToken (); - SkipComma = 0; - } - - if (SymIsBitField (Sym)) { - - /* Parse initialization of one field. Bit-fields need a special - ** handling. - */ - ExprDesc ED; - ED_Init (&ED); - unsigned Val; - unsigned Shift; - - /* Calculate the bitmask from the bit-field data */ - unsigned Mask = (1U << Sym->Type->A.B.Width) - 1U; - - /* Safety ... */ - CHECK (Sym->V.Offs * CHAR_BITS + Sym->Type->A.B.Offs == - SI.Offs * CHAR_BITS + SI.ValBits); - - /* Read the data, check for a constant integer, do a range check */ - ED = ParseScalarInitInternal (IntPromotion (Sym->Type)); - if (!ED_IsConstAbsInt (&ED)) { - Error ("Constant initializer expected"); - ED_MakeConstAbsInt (&ED, 1); - } - - /* Truncate the initializer value to the width of the bit-field and check if we lost - ** any useful bits. - */ - Val = (unsigned) ED.IVal & Mask; - if (IsSignUnsigned (Sym->Type)) { - if (ED.IVal < 0 || (unsigned long) ED.IVal != Val) { - Warning ("Implicit truncation from '%s' to '%s : %u' in bit-field initializer" - " changes value from %ld to %u", - GetFullTypeName (ED.Type), GetFullTypeName (Sym->Type), - Sym->Type->A.B.Width, ED.IVal, Val); - } - } else { - /* Sign extend back to full width of host long. */ - unsigned ShiftBits = sizeof (long) * CHAR_BIT - Sym->Type->A.B.Width; - long RestoredVal = asr_l(asl_l (Val, ShiftBits), ShiftBits); - if (ED.IVal != RestoredVal) { - Warning ("Implicit truncation from '%s' to '%s : %u' in bit-field initializer " - "changes value from %ld to %ld", - GetFullTypeName (ED.Type), GetFullTypeName (Sym->Type), - Sym->Type->A.B.Width, ED.IVal, RestoredVal); - } - } - - /* Add the value to the currently stored bit-field value */ - Shift = (Sym->V.Offs - SI.Offs) * CHAR_BITS + Sym->Type->A.B.Offs; - SI.BitVal |= (Val << Shift); - - /* Account for the data and output any full bytes we have. */ - SI.ValBits += Sym->Type->A.B.Width; - /* Make sure unsigned is big enough to hold the value, 22 bits. - ** This is 22 bits because the most we can have is 7 bits left - ** over from the previous OutputBitField call, plus 15 bits - ** from this field. A 16-bit bit-field will always be byte - ** aligned, so will have padding before it. - */ - CHECK (SI.ValBits <= CHAR_BIT * sizeof(SI.BitVal)); - /* TODO: Generalize this so any type can be used. */ - CHECK (SI.ValBits <= CHAR_BITS + INT_BITS - 2); - while (SI.ValBits >= CHAR_BITS) { - DefineBitFieldData (&SI); - } - - } else { - - /* Standard member. We should never have stuff from a - ** bit-field left because an anonymous member was added - ** for padding by ParseStructDecl. - */ - CHECK (SI.ValBits == 0); - - /* Flexible array members may only be initialized if they are - ** the last field (or part of the last struct field). - */ - SI.Offs += ParseInitInternal (Sym->Type, Braces, AllowFlexibleMembers && Sym->NextSym == 0); - } - - /* More initializers? */ - if (CurTok.Tok != TOK_COMMA) { - break; - } - - /* Skip the comma next round */ - SkipComma = 1; - -NextMember: - /* Next member. For unions, only the first one can be initialized */ - if (IsTypeUnion (T)) { - /* Union */ - Sym = 0; - } else { - /* Struct */ - Sym = Sym->NextSym; - } - } - - if (HasCurly) { - /* Consume the closing curly brace */ - ConsumeRCurly (); - } - - /* If we have data from a bit-field left, output it now */ - CHECK (SI.ValBits < CHAR_BITS); - DefineBitFieldData (&SI); - - /* If there are struct fields left, reserve additional storage */ - if (SI.Offs < SI.Size) { - g_zerobytes (SI.Size - SI.Offs); - SI.Offs = SI.Size; - } - - /* Return the actual number of bytes initialized. This number may be - ** larger than sizeof (Struct) if flexible array members are present and - ** were initialized (possible in non ANSI mode). - */ - return SI.Offs; -} - - - -static unsigned ParseVoidInit (Type* T) -/* Parse an initialization of a void variable (special cc65 extension). -** Return the number of bytes initialized. -*/ -{ - unsigned Size; - - /* Opening brace */ - ConsumeLCurly (); - - /* Allow an arbitrary list of values */ - Size = 0; - do { - ExprDesc Expr = NoCodeConstExpr (hie1); - switch (GetUnderlyingTypeCode (&Expr.Type[0])) { - - case T_SCHAR: - case T_UCHAR: - if (ED_IsConstAbsInt (&Expr)) { - /* Make it byte sized */ - Expr.IVal &= 0xFF; - } - DefineData (&Expr); - Size += SIZEOF_CHAR; - break; - - case T_SHORT: - case T_USHORT: - case T_INT: - case T_UINT: - case T_PTR: - case T_ARRAY: - if (ED_IsConstAbsInt (&Expr)) { - /* Make it word sized */ - Expr.IVal &= 0xFFFF; - } - DefineData (&Expr); - Size += SIZEOF_INT; - break; - - case T_LONG: - case T_ULONG: - if (ED_IsConstAbsInt (&Expr)) { - /* Make it dword sized */ - Expr.IVal &= 0xFFFFFFFF; - } - DefineData (&Expr); - Size += SIZEOF_LONG; - break; - - default: - Error ("Illegal type in initialization"); - break; - - } - - if (CurTok.Tok != TOK_COMMA) { - break; - } - NextToken (); - - } while (CurTok.Tok != TOK_RCURLY); - - /* Closing brace */ - ConsumeRCurly (); - - /* Number of bytes determined by initializer */ - if (T->A.U != 0 && T->A.U != Size) { - Error ("'void' array initialized with elements of variant sizes"); - } else { - T->A.U = Size; - } - - /* Return the number of bytes initialized */ - return Size; -} - - - -static unsigned ParseInitInternal (Type* T, int *Braces, int AllowFlexibleMembers) -/* Parse initialization of variables. Return the number of data bytes. */ -{ - switch (GetUnderlyingTypeCode (T)) { - - case T_SCHAR: - case T_UCHAR: - case T_SHORT: - case T_USHORT: - case T_INT: - case T_UINT: - case T_LONG: - case T_ULONG: - case T_FLOAT: - case T_DOUBLE: - return ParseScalarInit (T); - - case T_PTR: - return ParsePointerInit (T); - - case T_ARRAY: - return ParseArrayInit (T, Braces, AllowFlexibleMembers); - - case T_STRUCT: - case T_UNION: - return ParseStructInit (T, Braces, AllowFlexibleMembers); - - case T_ENUM: - /* Incomplete enum type must have already raised errors. - ** Just proceed to consume the value. - */ - return ParseScalarInit (T); - - case T_VOID: - if (IS_Get (&Standard) == STD_CC65) { - /* Special cc65 extension in non-ANSI mode */ - return ParseVoidInit (T); - } - /* FALLTHROUGH */ - - default: - Error ("Illegal type"); - return SIZEOF_CHAR; - - } -} - - - -unsigned ParseInit (Type* T) -/* Parse initialization of variables. Return the number of data bytes. */ -{ - /* Current curly braces layers */ - int Braces = 0; - - /* Parse the initialization. Flexible array members can only be initialized - ** in cc65 mode. - */ - unsigned Size = ParseInitInternal (T, &Braces, IS_Get (&Standard) == STD_CC65); - - /* The initialization may not generate code on global level, because code - ** outside function scope will never get executed. - */ - if (HaveGlobalCode ()) { - Error ("Non constant initializers"); - RemoveGlobalCode (); - } - - /* Return the size needed for the initialization */ - return Size; -} diff --git a/src/cc65/declare.h b/src/cc65/declare.h index 3293a0dcb..2b8b36f1c 100644 --- a/src/cc65/declare.h +++ b/src/cc65/declare.h @@ -114,11 +114,6 @@ void CheckEmptyDecl (const DeclSpec* D); ** warning if not. */ -unsigned ParseInit (Type* T); -/* Parse initialization of variables. Return the number of initialized data -** bytes. -*/ - /* End of declare.h */ diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 3b9307a37..0275e61a3 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -25,6 +25,7 @@ #include "funcdesc.h" #include "function.h" #include "global.h" +#include "initdata.h" #include "litpool.h" #include "loadexpr.h" #include "macrotab.h" @@ -216,8 +217,11 @@ void LimitExprValue (ExprDesc* Expr) break; case T_LONG: + Expr->IVal = (int32_t)Expr->IVal; + break; + case T_ULONG: - /* No need to do anything */ + Expr->IVal = (uint32_t)Expr->IVal; break; case T_SCHAR: @@ -395,7 +399,7 @@ static void DoInc (ExprDesc* Expr, unsigned KeepResult) Val = IsTypePtr (Expr->Type) ? CheckedSizeOf (Expr->Type + 1) : 1; /* Special treatment is needed for bit-fields */ - if (IsTypeBitField (Expr->Type)) { + if (IsTypeFragBitField (Expr->Type)) { DoIncDecBitField (Expr, Val, KeepResult); return; } @@ -482,7 +486,7 @@ static void DoDec (ExprDesc* Expr, unsigned KeepResult) Val = IsTypePtr (Expr->Type) ? CheckedSizeOf (Expr->Type + 1) : 1; /* Special treatment is needed for bit-fields */ - if (IsTypeBitField (Expr->Type)) { + if (IsTypeFragBitField (Expr->Type)) { DoIncDecBitField (Expr, -Val, KeepResult); return; } @@ -846,7 +850,7 @@ static unsigned FunctionArgList (FuncDesc* Func, int IsFastcall, ExprDesc* ED) /* The function returns the size of all arguments pushed onto the stack. ** However, if there are parameters missed (which is an error, and was ** flagged by the compiler), AND a stack frame was preallocated above, - ** we would loose track of the stackpointer, and generate an internal error + ** we would lose track of the stackpointer, and generate an internal error ** later. So we correct the value by the parameters that should have been ** pushed into, to avoid an internal compiler error. Since an error was ** generated before, no code will be output anyway. @@ -2584,12 +2588,9 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */ CmpSigned = 0; flags |= CF_UNSIGNED; } + } else { unsigned rtype = TypeOf (Expr2.Type) | (flags & CF_CONST); - if (CmpSigned) { - ltype &= ~CF_UNSIGNED; - rtype &= ~CF_UNSIGNED; - } flags |= g_typeadjust (ltype, rtype); } @@ -3786,7 +3787,7 @@ static void hieOr (ExprDesc *Expr) /* Load false only if the result is not true */ g_getimmed (CF_INT | CF_CONST, 0, 0); /* Load FALSE */ g_falsejump (CF_NONE, DoneLab); - + /* Load the true value */ g_defcodelabel (TrueLab); g_getimmed (CF_INT | CF_CONST, 1, 0); /* Load TRUE */ diff --git a/src/cc65/exprdesc.h b/src/cc65/exprdesc.h index a1487a0bd..13eb36e5e 100644 --- a/src/cc65/exprdesc.h +++ b/src/cc65/exprdesc.h @@ -38,12 +38,12 @@ +#include <inttypes.h> #include <string.h> /* common */ #include "fp.h" #include "inline.h" -#include "inttypes.h" /* cc65 */ #include "asmcode.h" diff --git a/src/cc65/global.c b/src/cc65/global.c index a337549fe..8b9838dc5 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -66,6 +66,7 @@ IntStack CodeSizeFactor = INTSTACK(100);/* Size factor for generated code */ IntStack DataAlignment = INTSTACK(1); /* Alignment for data */ /* File names */ -StrBuf DepName = STATIC_STRBUF_INITIALIZER; /* Name of dependencies file */ -StrBuf FullDepName = STATIC_STRBUF_INITIALIZER; /* Name of full dependencies file */ -StrBuf DepTarget = STATIC_STRBUF_INITIALIZER; /* Name of dependency target */ +StrBuf DepName = STATIC_STRBUF_INITIALIZER; /* Name of dependencies file */ +StrBuf FullDepName = STATIC_STRBUF_INITIALIZER; /* Name of full dependencies file */ +StrBuf DepTarget = STATIC_STRBUF_INITIALIZER; /* Name of dependency target */ +StrBuf DebugTableName = STATIC_STRBUF_INITIALIZER; /* Name of debug table dump file */ diff --git a/src/cc65/global.h b/src/cc65/global.h index b9bcf5550..266035346 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -77,6 +77,7 @@ extern IntStack DataAlignment; /* Alignment for data */ extern StrBuf DepName; /* Name of dependencies file */ extern StrBuf FullDepName; /* Name of full dependencies file */ extern StrBuf DepTarget; /* Name of dependency target */ +extern StrBuf DebugTableName; /* Name of debug table dump file */ diff --git a/src/cc65/initdata.c b/src/cc65/initdata.c new file mode 100644 index 000000000..99dacdca9 --- /dev/null +++ b/src/cc65/initdata.c @@ -0,0 +1,807 @@ +/*****************************************************************************/ +/* */ +/* initdata.c */ +/* */ +/* Parse and generate initializer data */ +/* */ +/* */ +/* */ +/* (C) 1998-2015, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#include <limits.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +/* common */ +#include "addrsize.h" +#include "mmodel.h" +#include "shift.h" +#include "xmalloc.h" + +/* cc65 */ +#include "anonname.h" +#include "codegen.h" +#include "datatype.h" +#include "declattr.h" +#include "error.h" +#include "expr.h" +#include "exprdesc.h" +#include "funcdesc.h" +#include "function.h" +#include "global.h" +#include "litpool.h" +#include "pragma.h" +#include "scanner.h" +#include "shift.h" +#include "standard.h" +#include "symtab.h" +#include "wrappedcall.h" +#include "typeconv.h" +#include "initdata.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +typedef struct StructInitData StructInitData; +struct StructInitData { + unsigned Size; /* Size of struct */ + unsigned Offs; /* Current offset in struct */ + unsigned BitVal; /* Summed up bit-field value */ + unsigned ValBits; /* Valid bits in Val */ +}; + + + +/*****************************************************************************/ +/* Forwards */ +/*****************************************************************************/ + + + +static unsigned ParseInitInternal (Type* T, int* Braces, int AllowFlexibleMembers); +/* Parse initialization of variables. Return the number of data bytes. */ + + + +/*****************************************************************************/ +/* code */ +/*****************************************************************************/ + + + +static void SkipInitializer (int BracesExpected) +/* Skip the remainder of an initializer in case of errors. Try to be somewhat +** smart so we don't have too many following errors. +*/ +{ + while (CurTok.Tok != TOK_CEOF && CurTok.Tok != TOK_SEMI && BracesExpected >= 0) { + switch (CurTok.Tok) { + case TOK_RCURLY: --BracesExpected; break; + case TOK_LCURLY: ++BracesExpected; break; + default: break; + } + if (BracesExpected >= 0) { + NextToken (); + } + } +} + + + +static unsigned OpeningCurlyBraces (unsigned BracesNeeded) +/* Accept any number of opening curly braces around an initialization, skip +** them and return the number. If the number of curly braces is less than +** BracesNeeded, issue a warning. +*/ +{ + unsigned BraceCount = 0; + while (CurTok.Tok == TOK_LCURLY) { + ++BraceCount; + NextToken (); + } + if (BraceCount < BracesNeeded) { + Error ("'{' expected"); + } + return BraceCount; +} + + + +static void ClosingCurlyBraces (unsigned BracesExpected) +/* Accept and skip the given number of closing curly braces together with +** an optional comma. Output an error messages, if the input does not contain +** the expected number of braces. +*/ +{ + while (BracesExpected) { + /* TODO: Skip all excess initializers until next closing curly brace */ + if (CurTok.Tok == TOK_RCURLY) { + NextToken (); + } else if (CurTok.Tok == TOK_COMMA && NextTok.Tok == TOK_RCURLY) { + NextToken (); + NextToken (); + } else { + Error ("'}' expected"); + return; + } + --BracesExpected; + } +} + + + +static void DefineData (ExprDesc* Expr) +/* Output a data definition for the given expression */ +{ + switch (ED_GetLoc (Expr)) { + + case E_LOC_NONE: + /* Immediate numeric value with no storage */ + g_defdata (CF_IMM | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); + break; + + case E_LOC_ABS: + /* Absolute numeric address */ + g_defdata (CF_ABSOLUTE | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); + break; + + case E_LOC_GLOBAL: + /* Global variable */ + g_defdata (CF_EXTERNAL, Expr->Name, Expr->IVal); + break; + + case E_LOC_STATIC: + /* Static variable */ + g_defdata (CF_STATIC, Expr->Name, Expr->IVal); + break; + + case E_LOC_LITERAL: + /* Literal in the literal pool */ + g_defdata (CF_LITERAL, Expr->Name, Expr->IVal); + break; + + case E_LOC_REGISTER: + /* Register variable. Taking the address is usually not + ** allowed. + */ + if (IS_Get (&AllowRegVarAddr) == 0) { + Error ("Cannot take the address of a register variable"); + } + g_defdata (CF_REGVAR, Expr->Name, Expr->IVal); + break; + + case E_LOC_CODE: + /* Code label location */ + g_defdata (CF_CODE, Expr->Name, Expr->IVal); + break; + + case E_LOC_STACK: + case E_LOC_PRIMARY: + case E_LOC_EXPR: + Error ("Non constant initializer"); + break; + + default: + Internal ("Unknown constant type: 0x%04X", ED_GetLoc (Expr)); + } +} + + + +static void DefineBitFieldData (StructInitData* SI) +/* Output bit field data */ +{ + /* Ignore if we have no data */ + if (SI->ValBits > 0) { + + /* Output the data */ + g_defdata (CF_CHAR | CF_UNSIGNED | CF_CONST, SI->BitVal, 0); + + /* Update the data from SI and account for the size */ + if (SI->ValBits >= CHAR_BITS) { + SI->BitVal >>= CHAR_BITS; + SI->ValBits -= CHAR_BITS; + } else { + SI->BitVal = 0; + SI->ValBits = 0; + } + SI->Offs += SIZEOF_CHAR; + } +} + + + +static void DefineStrData (Literal* Lit, unsigned Count) +{ + /* Translate into target charset */ + TranslateLiteral (Lit); + + /* Output the data */ + g_defbytes (GetLiteralStr (Lit), Count); +} + + + +static ExprDesc ParseScalarInitInternal (const Type* T) +/* Parse initializaton for scalar data types. This function will not output the +** data but return it in ED. +*/ +{ + /* Optional opening brace */ + unsigned BraceCount = OpeningCurlyBraces (0); + + /* We warn if an initializer for a scalar contains braces, because this is + ** quite unusual and often a sign for some problem in the input. + */ + if (BraceCount > 0) { + Warning ("Braces around scalar initializer"); + } + + /* Get the expression and convert it to the target type */ + ExprDesc ED = NoCodeConstExpr (hie1); + TypeConversion (&ED, T); + + /* Close eventually opening braces */ + ClosingCurlyBraces (BraceCount); + + return ED; +} + + + +static unsigned ParseScalarInit (const Type* T) +/* Parse initializaton for scalar data types. Return the number of data bytes. */ +{ + /* Parse initialization */ + ExprDesc ED = ParseScalarInitInternal (T); + + /* Output the data */ + DefineData (&ED); + + /* Do this anyways for safety */ + DoDeferred (SQP_KEEP_NONE, &ED); + + /* Done */ + return SizeOf (T); +} + + + +static unsigned ParsePointerInit (const Type* T) +/* Parse initializaton for pointer data types. Return the number of data bytes. */ +{ + /* Optional opening brace */ + unsigned BraceCount = OpeningCurlyBraces (0); + + /* Expression */ + ExprDesc ED = NoCodeConstExpr (hie1); + TypeConversion (&ED, T); + + /* Output the data */ + DefineData (&ED); + + /* Do this anyways for safety */ + DoDeferred (SQP_KEEP_NONE, &ED); + + /* Close eventually opening braces */ + ClosingCurlyBraces (BraceCount); + + /* Done */ + return SIZEOF_PTR; +} + + + +static unsigned ParseArrayInit (Type* T, int* Braces, int AllowFlexibleMembers) +/* Parse initializaton for arrays. Return the number of data bytes. */ +{ + int Count; + int HasCurly = 0; + + /* Get the array data */ + Type* ElementType = IndirectModifiable (T); + unsigned ElementSize = SizeOf (ElementType); + long ElementCount = GetElementCount (T); + + /* Special handling for a character array initialized by a literal */ + if (IsClassChar (ElementType) && + (CurTok.Tok == TOK_SCONST || CurTok.Tok == TOK_WCSCONST || + (CurTok.Tok == TOK_LCURLY && + (NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) { + + /* Char array initialized by string constant */ + int NeedParen; + + /* If we initializer is enclosed in brackets, remember this fact and + ** skip the opening bracket. + */ + NeedParen = (CurTok.Tok == TOK_LCURLY); + if (NeedParen) { + NextToken (); + } + + /* If the array is one too small for the string literal, omit the + ** trailing zero. + */ + Count = GetLiteralSize (CurTok.SVal); + if (ElementCount != UNSPECIFIED && + ElementCount != FLEXIBLE && + Count == ElementCount + 1) { + /* Omit the trailing zero */ + --Count; + } + + /* Output the data */ + DefineStrData (CurTok.SVal, Count); + + /* Skip the string */ + NextToken (); + + /* If the initializer was enclosed in curly braces, we need a closing + ** one. + */ + if (NeedParen) { + ConsumeRCurly (); + } + + } else { + + /* Arrays can be initialized without a pair of curly braces */ + if (*Braces == 0 || CurTok.Tok == TOK_LCURLY) { + /* Consume the opening curly brace */ + HasCurly = ConsumeLCurly (); + *Braces += HasCurly; + } + + /* Initialize the array members */ + Count = 0; + while (CurTok.Tok != TOK_RCURLY) { + /* Flexible array members may not be initialized within + ** an array (because the size of each element may differ + ** otherwise). + */ + ParseInitInternal (ElementType, Braces, 0); + ++Count; + if (CurTok.Tok != TOK_COMMA) + break; + NextToken (); + } + + if (HasCurly) { + /* Closing curly braces */ + ConsumeRCurly (); + } + } + + /* Size of 'void' elements are determined after initialization */ + if (ElementSize == 0) { + ElementSize = SizeOf (ElementType); + } + + if (ElementCount == UNSPECIFIED) { + /* Number of elements determined by initializer */ + SetElementCount (T, Count); + ElementCount = Count; + } else if (ElementCount == FLEXIBLE) { + if (AllowFlexibleMembers) { + /* In non ANSI mode, allow initialization of flexible array + ** members. + */ + ElementCount = Count; + } else { + /* Forbid */ + Error ("Initializing flexible array member is forbidden"); + ElementCount = Count; + } + } else if (Count < ElementCount) { + g_zerobytes ((ElementCount - Count) * ElementSize); + } else if (Count > ElementCount && HasCurly) { + Error ("Excess elements in array initializer"); + } + return ElementCount * ElementSize; +} + + + +static unsigned ParseStructInit (Type* T, int* Braces, int AllowFlexibleMembers) +/* Parse initialization of a struct or union. Return the number of data bytes. */ +{ + SymEntry* Sym; + SymTable* Tab; + StructInitData SI; + int HasCurly = 0; + int SkipComma = 0; + + + /* Fields can be initialized without a pair of curly braces */ + if (*Braces == 0 || CurTok.Tok == TOK_LCURLY) { + /* Consume the opening curly brace */ + HasCurly = ConsumeLCurly (); + *Braces += HasCurly; + } + + /* Get a pointer to the struct entry from the type */ + Sym = GetESUSymEntry (T); + + /* Get the size of the struct from the symbol table entry */ + SI.Size = Sym->V.S.Size; + + /* Check if this struct definition has a field table. If it doesn't, it + ** is an incomplete definition. + */ + Tab = Sym->V.S.SymTab; + if (Tab == 0) { + Error ("Cannot initialize variables with incomplete type"); + /* Try error recovery */ + SkipInitializer (HasCurly); + /* Nothing initialized */ + return 0; + } + + /* Get a pointer to the list of symbols */ + Sym = Tab->SymHead; + + /* Initialize fields */ + SI.Offs = 0; + SI.BitVal = 0; + SI.ValBits = 0; + while (CurTok.Tok != TOK_RCURLY) { + + /* Check for excess elements */ + if (Sym == 0) { + /* Is there just one trailing comma before a closing curly? */ + if (NextTok.Tok == TOK_RCURLY && CurTok.Tok == TOK_COMMA) { + /* Skip comma and exit scope */ + NextToken (); + break; + } + + if (HasCurly) { + Error ("Excess elements in %s initializer", GetBasicTypeName (T)); + SkipInitializer (HasCurly); + } + return SI.Offs; + } + + /* Check for special members that don't consume the initializer */ + if ((Sym->Flags & SC_ALIAS) == SC_ALIAS) { + /* Just skip */ + goto NextMember; + } + + /* This may be an anonymous bit-field, in which case it doesn't + ** have an initializer. + */ + if (SymIsBitField (Sym) && (IsAnonName (Sym->Name))) { + /* Account for the data and output it if we have at least a full + ** byte. We may have more if there was storage unit overlap, for + ** example two consecutive 7 bit fields. Those would be packed + ** into 2 bytes. + */ + SI.ValBits += Sym->Type->A.B.Width; + CHECK (SI.ValBits <= CHAR_BIT * sizeof(SI.BitVal)); + /* TODO: Generalize this so any type can be used. */ + CHECK (SI.ValBits <= LONG_BITS); + while (SI.ValBits >= CHAR_BITS) { + DefineBitFieldData (&SI); + } + /* Avoid consuming the comma if any */ + goto NextMember; + } + + /* Skip comma this round */ + if (SkipComma) { + NextToken (); + SkipComma = 0; + } + + if (SymIsBitField (Sym)) { + + /* Parse initialization of one field. Bit-fields need a special + ** handling. + */ + ExprDesc Field; + ED_Init (&Field); + unsigned long Val; + unsigned Shift; + + /* Calculate the bitmask from the bit-field data */ + unsigned long Mask = shl_l (1UL, Sym->Type->A.B.Width) - 1UL; + + /* Safety ... */ + CHECK (Sym->V.Offs * CHAR_BITS + Sym->Type->A.B.Offs == + SI.Offs * CHAR_BITS + SI.ValBits); + + /* Read the data, check for a constant integer, do a range check */ + Field = ParseScalarInitInternal (IntPromotion (Sym->Type)); + if (!ED_IsConstAbsInt (&Field)) { + Error ("Constant initializer expected"); + ED_MakeConstAbsInt (&Field, 1); + } + + /* Truncate the initializer value to the width of the bit-field and check if we lost + ** any useful bits. + */ + Val = (unsigned long) Field.IVal & Mask; + if (IsSignUnsigned (Sym->Type)) { + if (Field.IVal < 0 || (unsigned long) Field.IVal != Val) { + Warning (IsSignUnsigned (Field.Type) ? + "Implicit truncation from '%s' to '%s : %u' in bit-field initializer" + " changes value from %lu to %lu" : + "Implicit truncation from '%s' to '%s : %u' in bit-field initializer" + " changes value from %ld to %lu", + GetFullTypeName (Field.Type), GetFullTypeName (Sym->Type), + Sym->Type->A.B.Width, Field.IVal, Val); + } + } else { + /* Sign extend back to full width of host long. */ + unsigned ShiftBits = sizeof (long) * CHAR_BIT - Sym->Type->A.B.Width; + long RestoredVal = asr_l (asl_l (Val, ShiftBits), ShiftBits); + if (Field.IVal != RestoredVal) { + Warning (IsSignUnsigned (Field.Type) ? + "Implicit truncation from '%s' to '%s : %u' in bit-field initializer" + " changes value from %lu to %ld" : + "Implicit truncation from '%s' to '%s : %u' in bit-field initializer" + " changes value from %ld to %ld", + GetFullTypeName (Field.Type), GetFullTypeName (Sym->Type), + Sym->Type->A.B.Width, Field.IVal, RestoredVal); + } + } + + /* Add the value to the currently stored bit-field value */ + Shift = (Sym->V.Offs - SI.Offs) * CHAR_BITS + Sym->Type->A.B.Offs; + SI.BitVal |= (Val << Shift); + + /* Account for the data and output any full bytes we have. */ + SI.ValBits += Sym->Type->A.B.Width; + /* Make sure unsigned is big enough to hold the value, 32 bits. + ** This cannot be more than 32 bits because a 16-bit or 32-bit + ** bit-field will always be byte-aligned with padding before it + ** if there are bits from prior fields that haven't been output + ** yet. + */ + CHECK (SI.ValBits <= CHAR_BIT * sizeof(SI.BitVal)); + /* TODO: Generalize this so any type can be used. */ + CHECK (SI.ValBits <= LONG_BITS); + while (SI.ValBits >= CHAR_BITS) { + DefineBitFieldData (&SI); + } + + } else { + + /* Standard member. We should never have stuff from a + ** bit-field left because an anonymous member was added + ** for padding by ParseStructDecl. + */ + CHECK (SI.ValBits == 0); + + /* Flexible array members may only be initialized if they are + ** the last field (or part of the last struct field). + */ + SI.Offs += ParseInitInternal (Sym->Type, Braces, AllowFlexibleMembers && Sym->NextSym == 0); + } + + /* More initializers? */ + if (CurTok.Tok != TOK_COMMA) { + break; + } + + /* Skip the comma next round */ + SkipComma = 1; + +NextMember: + /* Next member. For unions, only the first one can be initialized */ + if (IsTypeUnion (T)) { + /* Union */ + Sym = 0; + } else { + /* Struct */ + Sym = Sym->NextSym; + } + } + + if (HasCurly) { + /* Consume the closing curly brace */ + ConsumeRCurly (); + } + + /* If we have data from a bit-field left, output it now */ + CHECK (SI.ValBits < CHAR_BITS); + DefineBitFieldData (&SI); + + /* If there are struct fields left, reserve additional storage */ + if (SI.Offs < SI.Size) { + g_zerobytes (SI.Size - SI.Offs); + SI.Offs = SI.Size; + } + + /* Return the actual number of bytes initialized. This number may be + ** larger than sizeof (Struct) if flexible array members are present and + ** were initialized (possible in non ANSI mode). + */ + return SI.Offs; +} + + + +static unsigned ParseVoidInit (Type* T) +/* Parse an initialization of a void variable (special cc65 extension). +** Return the number of bytes initialized. +*/ +{ + unsigned Size; + + /* Opening brace */ + ConsumeLCurly (); + + /* Allow an arbitrary list of values */ + Size = 0; + do { + ExprDesc Expr = NoCodeConstExpr (hie1); + switch (GetUnderlyingTypeCode (&Expr.Type[0])) { + + case T_SCHAR: + case T_UCHAR: + if (ED_IsConstAbsInt (&Expr)) { + /* Make it byte sized */ + Expr.IVal &= 0xFF; + } + DefineData (&Expr); + Size += SIZEOF_CHAR; + break; + + case T_SHORT: + case T_USHORT: + case T_INT: + case T_UINT: + case T_PTR: + case T_ARRAY: + if (ED_IsConstAbsInt (&Expr)) { + /* Make it word sized */ + Expr.IVal &= 0xFFFF; + } + DefineData (&Expr); + Size += SIZEOF_INT; + break; + + case T_LONG: + case T_ULONG: + if (ED_IsConstAbsInt (&Expr)) { + /* Make it dword sized */ + Expr.IVal &= 0xFFFFFFFF; + } + DefineData (&Expr); + Size += SIZEOF_LONG; + break; + + default: + Error ("Illegal type in initialization"); + break; + + } + + if (CurTok.Tok != TOK_COMMA) { + break; + } + NextToken (); + + } while (CurTok.Tok != TOK_RCURLY); + + /* Closing brace */ + ConsumeRCurly (); + + /* Number of bytes determined by initializer */ + if (T->A.U != 0 && T->A.U != Size) { + Error ("'void' array initialized with elements of variant sizes"); + } else { + T->A.U = Size; + } + + /* Return the number of bytes initialized */ + return Size; +} + + + +static unsigned ParseInitInternal (Type* T, int *Braces, int AllowFlexibleMembers) +/* Parse initialization of variables. Return the number of data bytes. */ +{ + switch (GetUnderlyingTypeCode (T)) { + + case T_SCHAR: + case T_UCHAR: + case T_SHORT: + case T_USHORT: + case T_INT: + case T_UINT: + case T_LONG: + case T_ULONG: + case T_FLOAT: + case T_DOUBLE: + return ParseScalarInit (T); + + case T_PTR: + return ParsePointerInit (T); + + case T_ARRAY: + return ParseArrayInit (T, Braces, AllowFlexibleMembers); + + case T_STRUCT: + case T_UNION: + return ParseStructInit (T, Braces, AllowFlexibleMembers); + + case T_ENUM: + /* Incomplete enum type must have already raised errors. + ** Just proceed to consume the value. + */ + return ParseScalarInit (T); + + case T_VOID: + if (IS_Get (&Standard) == STD_CC65) { + /* Special cc65 extension in non-ANSI mode */ + return ParseVoidInit (T); + } + /* FALLTHROUGH */ + + default: + Error ("Illegal type"); + return SIZEOF_CHAR; + + } +} + + + +unsigned ParseInit (Type* T) +/* Parse initialization of variables. Return the number of data bytes. */ +{ + /* Current curly braces layers */ + int Braces = 0; + + /* Parse the initialization. Flexible array members can only be initialized + ** in cc65 mode. + */ + unsigned Size = ParseInitInternal (T, &Braces, IS_Get (&Standard) == STD_CC65); + + /* The initialization may not generate code on global level, because code + ** outside function scope will never get executed. + */ + if (HaveGlobalCode ()) { + Error ("Non constant initializers"); + RemoveGlobalCode (); + } + + /* Return the size needed for the initialization */ + return Size; +} diff --git a/src/cc65/initdata.h b/src/cc65/initdata.h new file mode 100644 index 000000000..6fa3f20b3 --- /dev/null +++ b/src/cc65/initdata.h @@ -0,0 +1,61 @@ +/*****************************************************************************/ +/* */ +/* initdata.h */ +/* */ +/* Parse and generate initializer data */ +/* */ +/* */ +/* */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef INITDATA_H +#define INITDATA_H + + + +/* cc65 */ +#include "datatype.h" + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +unsigned ParseInit (Type* T); +/* Parse initialization of variables. Return the number of initialized data +** bytes. +*/ + + + +/* End of initdata.h */ + +#endif diff --git a/src/cc65/loadexpr.c b/src/cc65/loadexpr.c index a742087b7..4b7f8e279 100644 --- a/src/cc65/loadexpr.c +++ b/src/cc65/loadexpr.c @@ -110,6 +110,8 @@ static void LoadAddress (unsigned Flags, ExprDesc* Expr) void LoadExpr (unsigned Flags, struct ExprDesc* Expr) /* Load an expression into the primary register if it is not already there. +** If Flags contains any CF_TYPEMASK bits, it then overrides the codegen type +** info that would be otherwise taken from the expression type. ** Note: This function can't modify the content in Expr since there are many ** instances of the "GetCodePos + LoadExpr (maybe indirectly) + RemoveCode" ** code pattern here and there which assumes that Expr should be unchanged, @@ -125,32 +127,24 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr) int AdjustBitField = 0; unsigned BitFieldFullWidthFlags = 0; if ((Flags & CF_TYPEMASK) == 0) { - if (IsTypeBitField (Expr->Type)) { - unsigned EndBit = Expr->Type->A.B.Offs + Expr->Type->A.B.Width; - AdjustBitField = Expr->Type->A.B.Offs != 0 || (EndBit != CHAR_BITS && EndBit != INT_BITS); - - /* TODO: This probably needs to be guarded by AdjustBitField when long bit-fields are - ** supported. - */ - Flags |= (EndBit <= CHAR_BITS) ? CF_CHAR : CF_INT; - if (IsSignUnsigned (Expr->Type)) { - Flags |= CF_UNSIGNED; - } + if (IsTypeFragBitField (Expr->Type)) { + /* We need to adjust the bits in this case. */ + AdjustBitField = 1; /* Flags we need operate on the whole bit-field, without CF_FORCECHAR. */ - BitFieldFullWidthFlags = Flags; + BitFieldFullWidthFlags = Flags | TypeOf (Expr->Type); + + /* Flags we need operate on the whole chunk containing the bit-field. */ + Flags |= TypeOf (GetBitFieldChunkType (Expr->Type)); /* If we're adjusting, then only load a char (not an int) and do only char ops; - ** We will clear the high byte in the adjustment. CF_FORCECHAR does nothing if the - ** type is not CF_CHAR. + ** We will clear the high byte in the adjustment. CF_FORCECHAR does nothing if + ** the type is not CF_CHAR; + ** If adjusting, then we're sign extending manually, so do everything unsigned + ** to make shifts faster. */ - if (AdjustBitField) { - /* If adjusting, then we're sign extending manually, so do everything unsigned - ** to make shifts faster. - */ - Flags |= CF_UNSIGNED | CF_FORCECHAR; - BitFieldFullWidthFlags |= CF_UNSIGNED; - } + Flags |= CF_UNSIGNED | CF_FORCECHAR; + BitFieldFullWidthFlags |= CF_UNSIGNED; } else { /* If Expr is an incomplete ESY type, bail out */ if (IsIncompleteESUType (Expr->Type)) { diff --git a/src/cc65/loadexpr.h b/src/cc65/loadexpr.h index c9e70e1f6..90862e33a 100644 --- a/src/cc65/loadexpr.h +++ b/src/cc65/loadexpr.h @@ -55,7 +55,10 @@ struct ExprDesc; void LoadExpr (unsigned Flags, struct ExprDesc* Expr); -/* Load an expression into the primary register if it is not already there. */ +/* Load an expression into the primary register if it is not already there. +** If Flags contains any CF_TYPEMASK bits, it then overrides the codegen type +** info that would be otherwise taken from the expression type. +*/ diff --git a/src/cc65/locals.c b/src/cc65/locals.c index d3902f329..297994455 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -46,6 +46,7 @@ #include "expr.h" #include "function.h" #include "global.h" +#include "initdata.h" #include "loadexpr.h" #include "locals.h" #include "stackptr.h" diff --git a/src/cc65/main.c b/src/cc65/main.c index 0ed5af986..c08616efa 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -114,6 +114,7 @@ static void Usage (void) " --create-full-dep name\tCreate a full make dependency file\n" " --data-name seg\t\tSet the name of the DATA segment\n" " --debug\t\t\tDebug mode\n" + " --debug-tables name\t\tWrite symbol table debug info to a file\n" " --debug-info\t\t\tAdd debug info to object file\n" " --debug-opt name\t\tDebug optimization steps\n" " --debug-opt-output\t\tDebug output of each optimization step\n" @@ -172,6 +173,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__ATARI5200__", 1); break; + case TGT_ATARI7800: + DefineNumericMacro ("__ATARI7800__", 1); + break; + case TGT_ATARI: DefineNumericMacro ("__ATARI__", 1); break; @@ -494,7 +499,11 @@ static void OptDebug (const char* Opt attribute ((unused)), ++Debug; } - +static void OptDebugTables (const char* Opt, const char* Arg) +/* Dump tables to file */ +{ + FileNameOption (Opt, Arg, &DebugTableName); +} static void OptDebugInfo (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) @@ -865,6 +874,7 @@ int main (int argc, char* argv[]) { "--create-full-dep", 1, OptCreateFullDep }, { "--data-name", 1, OptDataName }, { "--debug", 0, OptDebug }, + { "--debug-tables", 1, OptDebugTables }, { "--debug-info", 0, OptDebugInfo }, { "--debug-opt", 1, OptDebugOpt }, { "--debug-opt-output", 0, OptDebugOptOutput }, diff --git a/src/cc65/shiftexpr.c b/src/cc65/shiftexpr.c index 168574a1b..f7385ace1 100644 --- a/src/cc65/shiftexpr.c +++ b/src/cc65/shiftexpr.c @@ -64,11 +64,11 @@ void ShiftExpr (struct ExprDesc* Expr) CodeMark Mark1; CodeMark Mark2; token_t Tok; /* The operator token */ - const Type* EffType; /* Effective lhs type */ const Type* ResultType; /* Type of the result */ unsigned ExprBits; /* Bits of the lhs operand */ unsigned GenFlags; /* Generator flags */ unsigned ltype; + int lconst; /* Operand is a constant */ int rconst; /* Operand is a constant */ @@ -92,7 +92,7 @@ void ShiftExpr (struct ExprDesc* Expr) NextToken (); /* Get the type of the result */ - ResultType = EffType = IntPromotion (Expr->Type); + ResultType = IntPromotion (Expr->Type); /* Prepare the code generator flags */ GenFlags = TypeOf (ResultType); @@ -103,7 +103,8 @@ void ShiftExpr (struct ExprDesc* Expr) /* Get the lhs on stack */ GetCodePos (&Mark1); ltype = TypeOf (Expr->Type); - if (ED_IsConstAbs (Expr)) { + lconst = ED_IsConstAbs (Expr); + if (lconst) { /* Constant value */ GetCodePos (&Mark2); g_push (ltype | CF_CONST, Expr->IVal); @@ -115,7 +116,7 @@ void ShiftExpr (struct ExprDesc* Expr) } /* Get the right hand side */ - ExprWithCheck (hie8, &Expr2); + MarkedExprWithCheck (hie8, &Expr2); /* Check the type of the rhs */ if (!IsClassInt (Expr2.Type)) { @@ -124,7 +125,7 @@ void ShiftExpr (struct ExprDesc* Expr) } /* Check for a constant right side expression */ - rconst = ED_IsConstAbs (&Expr2); + rconst = ED_IsConstAbs (&Expr2) && ED_CodeRangeIsEmpty (&Expr2); if (!rconst) { /* Not constant, load into the primary */ @@ -154,31 +155,32 @@ void ShiftExpr (struct ExprDesc* Expr) } - /* If the shift count is zero, nothing happens */ - if (Expr2.IVal == 0) { + /* If the shift count is zero, nothing happens. If the left hand + ** side is a constant, the result is constant. + */ + if (Expr2.IVal == 0 || lconst) { - /* Result is already in Expr, remove the generated code */ - RemoveCode (&Mark1); + /* Set the type */ + Expr->Type = ResultType; - /* Done */ - goto Next; - } + if (lconst) { - /* If the left hand side is a constant, the result is constant */ - if (ED_IsConstAbs (Expr)) { + /* Evaluate the result */ + switch (Tok) { + case TOK_SHL: Expr->IVal <<= Expr2.IVal; break; + case TOK_SHR: Expr->IVal >>= Expr2.IVal; break; + default: /* Shutup gcc */ break; + } - /* Evaluate the result */ - switch (Tok) { - case TOK_SHL: Expr->IVal <<= Expr2.IVal; break; - case TOK_SHR: Expr->IVal >>= Expr2.IVal; break; - default: /* Shutup gcc */ break; + /* Limit the calculated value to the range of its type */ + LimitExprValue (Expr); } - /* Both operands are constant, remove the generated code */ + /* Result is already got, remove the generated code */ RemoveCode (&Mark1); /* Done */ - goto Next; + continue; } /* If we're shifting an integer or unsigned to the right, the lhs @@ -188,13 +190,12 @@ void ShiftExpr (struct ExprDesc* Expr) ** shift count is zero, we're done. */ if (Tok == TOK_SHR && - IsTypeInt (Expr->Type) && + IsClassInt (Expr->Type) && + SizeOf (Expr->Type) == SIZEOF_INT && ED_IsLVal (Expr) && ED_IsLocQuasiConst (Expr) && Expr2.IVal >= 8) { - const Type* OldType; - /* Increase the address by one and decrease the shift count */ ++Expr->IVal; Expr2.IVal -= 8; @@ -202,7 +203,6 @@ void ShiftExpr (struct ExprDesc* Expr) /* Replace the type of the expression temporarily by the ** corresponding char type. */ - OldType = Expr->Type; if (IsSignUnsigned (Expr->Type)) { Expr->Type = type_uchar; } else { @@ -215,9 +215,6 @@ void ShiftExpr (struct ExprDesc* Expr) /* Generate again code for the load, this time with the new type */ LoadExpr (CF_NONE, Expr); - /* Reset the type */ - Expr->Type = OldType; - /* If the shift count is now zero, we're done */ if (Expr2.IVal == 0) { /* Be sure to mark the value as in the primary */ @@ -238,7 +235,6 @@ MakeRVal: /* We have an rvalue in the primary now */ ED_FinalizeRValLoad (Expr); -Next: /* Set the type of the result */ Expr->Type = ResultType; } diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index c1c5c4696..b4c97e962 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -37,6 +37,7 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> +#include <errno.h> /* common */ #include "check.h" @@ -68,8 +69,6 @@ /* Data */ /*****************************************************************************/ - - /* An empty symbol table */ SymTable EmptySymTab = { 0, /* PrevTab */ @@ -99,6 +98,7 @@ static SymTable* LabelTab = 0; static SymTable* SPAdjustTab = 0; static SymTable* FailSafeTab = 0; /* For errors */ +static FILE* DebugTableFile = 0; /*****************************************************************************/ /* struct SymTable */ @@ -256,11 +256,25 @@ void PopLexicalLevel (void) --LexLevelDepth; } - - void EnterGlobalLevel (void) /* Enter the program global lexical level */ { + const char* OutName = NULL; + if (!SB_IsEmpty (&DebugTableName)) { + OutName = SB_GetConstBuf (&DebugTableName); + } + + if (OutName) { + /* Open the table file */ + DebugTableFile = fopen (OutName, "w"); + if (DebugTableFile == 0) { + Error ("Cannot create table dump file '%s': %s", OutName, strerror (errno)); + } + } + else if (Debug) { + DebugTableFile = stdout; + } + /* Safety */ PRECONDITION (GetLexicalLevel () == LEX_LEVEL_NONE); @@ -280,8 +294,6 @@ void EnterGlobalLevel (void) FailSafeTab = NewSymTable (SYMTAB_SIZE_GLOBAL); } - - void LeaveGlobalLevel (void) /* Leave the program global lexical level */ { @@ -292,9 +304,41 @@ void LeaveGlobalLevel (void) CheckSymTable (SymTab0); /* Dump the tables if requested */ - if (Debug) { - PrintSymTable (SymTab0, stdout, "Global symbol table"); - PrintSymTable (TagTab0, stdout, "Global tag table"); + if (DebugTableFile) { + SymEntry* Entry; + StrBuf* Header; + + PrintSymTable (SymTab0, DebugTableFile, "Global symbol table"); + PrintSymTable (TagTab0, DebugTableFile, "Global tag table"); + + Entry = TagTab0->SymHead; + if (Entry) { + fputs ("\nGlobal struct and union definitions", DebugTableFile); + fputs ("\n=========================\n", DebugTableFile); + + do { + if (!((Entry->Flags & SC_STRUCT) || (Entry->Flags & SC_UNION)) || !Entry->V.S.SymTab) { + continue; + } + + Header = NewStrBuf(); + if(Entry->Flags & SC_STRUCT) { + SB_AppendStr (Header, "SC_STRUCT: "); + } + else { + SB_AppendStr (Header, "SC_UNION: "); + } + SB_AppendStr (Header, Entry->Name); + SB_Terminate (Header); + + PrintSymTable (Entry->V.S.SymTab, DebugTableFile, SB_GetConstBuf (Header)); + } while ((Entry = Entry->NextSym)); + } + + /* Close the file */ + if (DebugTableFile != stdout && fclose (DebugTableFile) != 0) { + Error ("Error closing table dump file '%s': %s", SB_GetConstBuf(&DebugTableName), strerror (errno)); + } } /* Don't delete the symbol and struct tables! */ @@ -386,6 +430,18 @@ void LeaveFunctionLevel (void) CheckSymTable (SymTab); CheckSymTable (LabelTab); + /* Dump the tables if requested */ + if (DebugTableFile) { + StrBuf* SymbolHeader = NewStrBuf(); + + SB_AppendStr (SymbolHeader, "SC_FUNC: "); + SB_AppendStr (SymbolHeader, CurrentFunc->FuncEntry->AsmName); + SB_AppendStr (SymbolHeader, ": Symbol table"); + SB_Terminate (SymbolHeader); + + PrintSymTable (SymTab, DebugTableFile, SB_GetConstBuf(SymbolHeader)); + } + /* Drop the label table if it is empty */ if (LabelTab->SymCount == 0) { FreeSymTable (LabelTab); diff --git a/src/cl65/error.c b/src/cl65/error.c index ee2adcfcc..9c234681f 100644 --- a/src/cl65/error.c +++ b/src/cl65/error.c @@ -39,7 +39,7 @@ /* common */ #include "cmdline.h" - + /* cl65 */ #include "global.h" #include "error.h" diff --git a/src/cl65/main.c b/src/cl65/main.c index dba4915f2..e032baee4 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -538,7 +538,7 @@ static void AssembleFile (const char* File, unsigned ArgCount) /* Check if this is the last processing step */ if (DoLink) { /* We're linking later. Add the output file of the assembly - ** the the file list of the linker. The name of the output + ** to the file list of the linker. The name of the output ** file is that of the input file with ".s" replaced by ".o". */ char* ObjName = MakeFilename (File, ".o"); @@ -1503,7 +1503,7 @@ int main (int argc, char* argv []) case 'E': /* Forward -E to compiler */ - CmdAddArg (&CC65, Arg); + CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking (); break; @@ -1513,7 +1513,7 @@ int main (int argc, char* argv []) OptAsmArgs (Arg, GetArg (&I, 3)); } else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - /* Remember -Wc sub arguments in cc65 arg struct */ + /* Remember -Wc sub arguments in cc65 arg struct */ OptCCArgs (Arg, GetArg (&I, 3)); } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ @@ -1627,7 +1627,7 @@ int main (int argc, char* argv []) break; case FILETYPE_O65: - /* Add the the object file converter files */ + /* Add the object file converter files */ ConvertO65 (Arg); break; diff --git a/src/co65/convert.h b/src/co65/convert.h index 8c7782ff3..5045acedd 100644 --- a/src/co65/convert.h +++ b/src/co65/convert.h @@ -56,7 +56,7 @@ struct O65Data; void Convert (const struct O65Data* D); -/* Convert the o65 file in D */ +/* Convert the o65 file in D */ diff --git a/src/co65/error.c b/src/co65/error.c index 1fa099c94..dc3e4e73b 100644 --- a/src/co65/error.c +++ b/src/co65/error.c @@ -81,7 +81,7 @@ void Error (const char* Format, ...) void Internal (const char* Format, ...) /* Print an internal error message and die */ { - va_list ap; + va_list ap; va_start (ap, Format); fprintf (stderr, "%s: Internal error: ", ProgName); vfprintf (stderr, Format, ap); diff --git a/src/co65/model.c b/src/co65/model.c index bb815cd15..2206993bf 100644 --- a/src/co65/model.c +++ b/src/co65/model.c @@ -53,7 +53,7 @@ O65Model Model = O65_MODEL_NONE; /* Name table */ static const char* const NameTable[O65_MODEL_COUNT] = { - "none", + "none", "os/a65", "lunix", "cc65-module" diff --git a/src/common.vcxproj b/src/common.vcxproj index f7929df2b..df99fc4a9 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -74,7 +74,6 @@ <ClInclude Include="common\inline.h" /> <ClInclude Include="common\intptrstack.h" /> <ClInclude Include="common\intstack.h" /> - <ClInclude Include="common\inttypes.h" /> <ClInclude Include="common\libdefs.h" /> <ClInclude Include="common\lidefs.h" /> <ClInclude Include="common\matchpat.h" /> diff --git a/src/common/debugflag.c b/src/common/debugflag.c index 7d2e80009..0a452ae36 100644 --- a/src/common/debugflag.c +++ b/src/common/debugflag.c @@ -32,7 +32,7 @@ /*****************************************************************************/ - + /* common */ #include "debugflag.h" diff --git a/src/common/debugflag.h b/src/common/debugflag.h index d325a9eb9..39034044e 100644 --- a/src/common/debugflag.h +++ b/src/common/debugflag.h @@ -31,7 +31,7 @@ /* */ /*****************************************************************************/ - + #ifndef DEBUGFLAG_H #define DEBUGFLAG_H diff --git a/src/common/filepos.c b/src/common/filepos.c index 51488ffe5..b2cac79e1 100644 --- a/src/common/filepos.c +++ b/src/common/filepos.c @@ -60,7 +60,7 @@ int CompareFilePos (const FilePos* P1, const FilePos* P2) ** compare rates file index over line over column. */ { - if (P1->Name > P2->Name) { + if (P1->Name > P2->Name) { return 1; } else if (P1->Name < P2->Name) { return -1; diff --git a/src/common/fp.c b/src/common/fp.c index 0c4d2790c..0682f9f9e 100644 --- a/src/common/fp.c +++ b/src/common/fp.c @@ -134,7 +134,7 @@ Float FP_F_Sub (Float Left, Float Right) Float FP_F_Mul (Float Left, Float Right) -/* Multiplicate two floats */ +/* Multiply two floats */ { Float D; D.V = Left.V * Right.V; @@ -220,7 +220,7 @@ Double FP_D_Sub (Double Left, Double Right) Double FP_D_Mul (Double Left, Double Right) -/* Multiplicate two floats */ +/* Multiply two floats */ { Double D; D.V = Left.V * Right.V; diff --git a/src/common/fp.h b/src/common/fp.h index 978359b8b..4e89e2316 100644 --- a/src/common/fp.h +++ b/src/common/fp.h @@ -102,7 +102,7 @@ Float FP_F_Sub (Float Left, Float Right); /* Subtract two floats */ Float FP_F_Mul (Float Left, Float Right); -/* Multiplicate two floats */ +/* Multiply two floats */ Float FP_F_Div (Float Left, Float Right); /* Divide two floats */ @@ -129,7 +129,7 @@ Double FP_D_Sub (Double Left, Double Right); /* Subtract two floats */ Double FP_D_Mul (Double Left, Double Right); -/* Multiplicate two floats */ +/* Multiply two floats */ Double FP_D_Div (Double Left, Double Right); /* Divide two floats */ diff --git a/src/common/inttypes.h b/src/common/inttypes.h deleted file mode 100644 index 28ffb2cc5..000000000 --- a/src/common/inttypes.h +++ /dev/null @@ -1,123 +0,0 @@ -/*****************************************************************************/ -/* */ -/* inttypes.h */ -/* */ -/* Define integer types */ -/* */ -/* */ -/* */ -/* (C) 2004 Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ -/* */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - - - -#ifndef INTTYPES_H -#define INTTYPES_H - - - -/* If we have <stdint.h>, include it; otherwise, adapt types from <stddef.h> -** and define integer boundary constants. -** gcc and msvc don't define __STDC_VERSION__ without special flags, so check -** for them explicitly. Undefined symbols are replaced by zero; so, checks for -** defined(__GNUC__) and defined(_MSC_VER) aren't necessary. -*/ -#if (__STDC_VERSION__ >= 199901) || (__GNUC__ >= 3) || (_MSC_VER >= 1600) -#include <stdint.h> -#else - -/* Assume that ptrdiff_t and size_t are wide enough to hold pointers. -** Assume that they are the widest type. -*/ -#include <limits.h> -#include <stddef.h> - -typedef ptrdiff_t intptr_t; -typedef size_t uintptr_t; -typedef ptrdiff_t intmax_t; -typedef size_t uintmax_t; - -#define INT8_MAX (0x7F) -#define INT16_MAX (0x7FFF) -#define INT32_MAX (0x7FFFFFFF) - -#define INT8_MIN (-INT8_MAX - 1) -#define INT16_MIN (-INT16_MAX - 1) -#define INT32_MIN (-INT32_MAX - 1) - -#define UINT8_MAX (0xFF) -#define UINT16_MAX (0xFFFF) -#define UINT32_MAX (0xFFFFFFFF) - -#if UCHAR_MAX == UINT8_MAX -typedef unsigned char uint8_t; -#else -#error "No suitable type for uint8_t found." -#endif - -#if SCHAR_MIN == INT8_MIN && SCHAR_MAX == INT8_MAX -typedef signed char int8_t; -#else -#error "No suitable type for int8_t found." -#endif - -#if UINT_MAX == UINT16_MAX -typedef unsigned int uint16_t; -#elif USHRT_MAX == UINT16_MAX -typedef unsigned short uint16_t; -#else -#error "No suitable type for uint16_t found." -#endif - -#if INT_MIN == INT16_MIN && INT_MAX == INT16_MAX -typedef int int16_t; -#elif SHRT_MIN == INT16_MIN && SHRT_MAX == INT16_MAX -typedef short int16_t; -#else -#error "No suitable type for int16_t found." -#endif - -#if UINT_MAX == UINT32_MAX -typedef unsigned int uint32_t; -#elif ULONG_MAX == UINT32_MAX -typedef unsigned long uint32_t; -#else -#error "No suitable type for uint32_t found." -#endif - -#if INT_MIN == INT32_MIN && INT_MAX == INT32_MAX -typedef int int32_t; -#elif LONG_MIN == INT32_MIN && LONG_MAX == INT32_MAX -typedef long int32_t; -#else -#error "No suitable type for int32_t found." -#endif - -#endif - - - -/* End of inttypes.h */ -#endif diff --git a/src/common/searchpath.c b/src/common/searchpath.c index ca7017e6f..70237a1c9 100644 --- a/src/common/searchpath.c +++ b/src/common/searchpath.c @@ -210,9 +210,9 @@ int PushSearchPath (SearchPaths* P, const char* NewPath) ** that it's not already there. If the path is already at the first position, ** return zero, otherwise return a non zero value. */ -{ +{ /* Generate a clean copy of NewPath */ - char* Path = CleanupPath (NewPath); + char* Path = CleanupPath (NewPath); /* If we have paths, check if Path is already at position zero */ if (CollCount (P) > 0 && strcmp (CollConstAt (P, 0), Path) == 0) { diff --git a/src/common/strstack.c b/src/common/strstack.c index 29dd10426..6b9fb0f8b 100644 --- a/src/common/strstack.c +++ b/src/common/strstack.c @@ -32,12 +32,12 @@ /*****************************************************************************/ - + /* common */ #include "check.h" #include "strstack.h" #include "xmalloc.h" - + /*****************************************************************************/ diff --git a/src/common/strutil.c b/src/common/strutil.c index dabed34cd..60284e860 100644 --- a/src/common/strutil.c +++ b/src/common/strutil.c @@ -66,7 +66,7 @@ char* StrCopy (char* Dest, size_t DestSize, const char* Source) int StrCaseCmp (const char* S1, const char* S2) -/* Compare two strings ignoring case */ +/* Compare two strings ignoring case */ { int Diff; while ((Diff = toupper (*S1) - toupper (*S2)) == 0 && *S1) { @@ -77,4 +77,4 @@ int StrCaseCmp (const char* S1, const char* S2) } - + diff --git a/src/common/target.c b/src/common/target.c index a35bf67a8..4a851034a 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -147,6 +147,7 @@ static const TargetEntry TargetMap[] = { { "atari", TGT_ATARI }, { "atari2600", TGT_ATARI2600 }, { "atari5200", TGT_ATARI5200 }, + { "atari7800", TGT_ATARI7800 }, { "atarixl", TGT_ATARIXL }, { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, @@ -188,6 +189,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "atari", CPU_6502, BINFMT_BINARY, CTAtari }, { "atari2600", CPU_6502, BINFMT_BINARY, CTNone }, { "atari5200", CPU_6502, BINFMT_BINARY, CTAtari }, + { "atari7800", CPU_6502, BINFMT_BINARY, CTNone }, { "atarixl", CPU_6502, BINFMT_BINARY, CTAtari }, { "vic20", CPU_6502, BINFMT_BINARY, CTPET }, { "c16", CPU_6502, BINFMT_BINARY, CTPET }, diff --git a/src/common/target.h b/src/common/target.h index 7f85713cf..7087048e2 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -57,6 +57,7 @@ typedef enum { TGT_ATARI, TGT_ATARI2600, TGT_ATARI5200, + TGT_ATARI7800, TGT_ATARIXL, TGT_VIC20, TGT_C16, diff --git a/src/common/va_copy.h b/src/common/va_copy.h index 4aa2428db..413d96bdd 100644 --- a/src/common/va_copy.h +++ b/src/common/va_copy.h @@ -41,7 +41,7 @@ #include <stdarg.h> - + /* No action if we have a working va_copy */ #if !defined(va_copy) diff --git a/src/common/xsprintf.c b/src/common/xsprintf.c index a7d26d5ef..a3fbc676b 100644 --- a/src/common/xsprintf.c +++ b/src/common/xsprintf.c @@ -33,6 +33,7 @@ +#include <inttypes.h> #include <stdio.h> #include <stddef.h> #include <string.h> @@ -41,7 +42,6 @@ /* common */ #include "chartype.h" #include "check.h" -#include "inttypes.h" #include "strbuf.h" #include "va_copy.h" #include "xsprintf.h" @@ -580,7 +580,7 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap) CHECK (S != 0); /* Handle the length by using a precision */ if ((P.Flags & fPrec) != 0) { - /* Precision already specified, use length of string + /* Precision already specified, use length of string ** if less. */ if ((unsigned) P.Prec > SB_GetLen (S)) { diff --git a/src/common/xsprintf.h b/src/common/xsprintf.h index a37b71914..4d32a7410 100644 --- a/src/common/xsprintf.h +++ b/src/common/xsprintf.h @@ -33,9 +33,9 @@ -/* We need a way to output a StrBuf, but on the other side, we don't want to -** switch off gcc's printf format string checking. So we cheat as follows: -** %m (which is a gcc extension and doesn't take an argument) switches %p +/* We need a way to output a StrBuf, but on the other side, we don't want to +** switch off gcc's printf format string checking. So we cheat as follows: +** %m (which is a gcc extension and doesn't take an argument) switches %p ** between outputting a pointer and a string buf. This works just one time, ** so each StrBuf needs in fact a %m%p spec. There's no way to apply a width ** and precision to such a StrBuf, but *not* using %p would bring up a warning diff --git a/src/da65/comments.c b/src/da65/comments.c index cf0b9d4e9..7c671131f 100644 --- a/src/da65/comments.c +++ b/src/da65/comments.c @@ -36,7 +36,7 @@ /* common */ #include "xmalloc.h" -/* da65 */ +/* da65 */ #include "attrtab.h" #include "comments.h" #include "error.h" diff --git a/src/da65/opc6502dtv.h b/src/da65/opc6502dtv.h index e63e4e44c..33b485029 100644 --- a/src/da65/opc6502dtv.h +++ b/src/da65/opc6502dtv.h @@ -58,4 +58,4 @@ extern const OpcDesc OpcTable_6502DTV[256]; - + diff --git a/src/da65/opc6502x.h b/src/da65/opc6502x.h index e086f87ae..23cd9068c 100644 --- a/src/da65/opc6502x.h +++ b/src/da65/opc6502x.h @@ -58,4 +58,4 @@ extern const OpcDesc OpcTable_6502X[256]; - + diff --git a/src/da65/opctable.h b/src/da65/opctable.h index 69a64db9c..7c871f7b0 100644 --- a/src/da65/opctable.h +++ b/src/da65/opctable.h @@ -38,7 +38,7 @@ -/* common */ +/* common */ #include "cpu.h" /* da65 */ diff --git a/src/dbginfo/dbginfo.h b/src/dbginfo/dbginfo.h index 7317e575f..38d891e7c 100644 --- a/src/dbginfo/dbginfo.h +++ b/src/dbginfo/dbginfo.h @@ -135,7 +135,7 @@ struct cc65_csymdata { unsigned char csym_kind; /* Kind of c symbol */ unsigned char csym_sc; /* Storage class of c symbol */ int csym_offs; /* Offset for auto and register */ - unsigned type_id; /* Id of the data type */ + unsigned type_id; /* Id of the data type */ unsigned symbol_id; /* Attached asm symbol if any */ unsigned scope_id; /* Scope of c symbol */ const char* csym_name; /* Name of the symbol */ diff --git a/src/ld65/condes.c b/src/ld65/condes.c index d8c378211..734b64ebd 100644 --- a/src/ld65/condes.c +++ b/src/ld65/condes.c @@ -281,7 +281,7 @@ const ConDesImport* ConDesGetImport (unsigned Type) /* Check the parameters */ PRECONDITION (Type <= CD_TYPE_MAX); - /* Return the import */ + /* Return the import */ Import = &ConDes[Type].Import; return (Import->Name != INVALID_STRING_ID)? Import : 0; } diff --git a/src/ld65/fragment.h b/src/ld65/fragment.h index 7d6dd9201..34eb5b695 100644 --- a/src/ld65/fragment.h +++ b/src/ld65/fragment.h @@ -100,7 +100,7 @@ INLINE const char* GetFragmentSourceName (const Fragment* F) #if defined(HAVE_INLINE) INLINE unsigned GetFragmentSourceLine (const Fragment* F) /* Return the source file line for this fragment */ -{ +{ return GetSourceLineFromList (&F->LineInfos); } #else diff --git a/src/ld65/mapfile.c b/src/ld65/mapfile.c index 7fec986ff..10d65960e 100644 --- a/src/ld65/mapfile.c +++ b/src/ld65/mapfile.c @@ -93,7 +93,7 @@ void CreateMapFile (int ShortMap) ** requested */ if (VerboseMap || S->Size > 0) { - fprintf (F, + fprintf (F, " %-17s Offs=%06lX Size=%06lX " "Align=%05lX Fill=%04lX\n", GetString (S->Seg->Name), S->Offs, S->Size, diff --git a/src/od65/dump.c b/src/od65/dump.c index 2f538fe1d..1a8c4dbb1 100644 --- a/src/od65/dump.c +++ b/src/od65/dump.c @@ -933,7 +933,7 @@ void DumpObjSegSize (FILE* F, unsigned long Offset) unsigned Len = strlen (Name); /* Skip segment flags, read size */ - (void) ReadVar (F); + (void) ReadVar (F); Size = ReadVar (F); /* Skip alignment, type and fragment count */ diff --git a/src/od65/fileio.c b/src/od65/fileio.c index a8d31c730..1689c4734 100644 --- a/src/od65/fileio.c +++ b/src/od65/fileio.c @@ -53,7 +53,7 @@ void FileSetPos (FILE* F, unsigned long Pos) /* Seek to the given absolute position, fail on errors */ -{ +{ if (fseek (F, Pos, SEEK_SET) != 0) { Error ("Cannot seek: %s", strerror (errno)); } diff --git a/src/sim65/6502.c b/src/sim65/6502.c index b3c06293a..6c23b0dfc 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -1270,8 +1270,8 @@ static void OPC_6502_6C (void) Cycles = 6; Regs.PC = MemReadWord(Lo); } - - ParaVirtHooks (&Regs); + + ParaVirtHooks (&Regs); } @@ -1283,7 +1283,7 @@ static void OPC_65C02_6C (void) Cycles = 5; Regs.PC = MemReadWord (MemReadWord (Regs.PC+1)); - ParaVirtHooks (&Regs); + ParaVirtHooks (&Regs); } @@ -1439,7 +1439,7 @@ static void OPC_65SC02_7C (void) Adr = MemReadWord (PC+1); Regs.PC = MemReadWord(Adr+Regs.XR); - ParaVirtHooks (&Regs); + ParaVirtHooks (&Regs); } diff --git a/src/sp65/bin.c b/src/sp65/bin.c index a3f856340..93e6a456a 100644 --- a/src/sp65/bin.c +++ b/src/sp65/bin.c @@ -53,7 +53,7 @@ -void WriteBinFile (const StrBuf* Data, const Collection* A, +void WriteBinFile (const StrBuf* Data, const Collection* A, const Bitmap* B attribute ((unused))) /* Write the contents of Data to the given file in binary format */ { diff --git a/src/sp65/color.h b/src/sp65/color.h index 31688bff4..6d898ab2e 100644 --- a/src/sp65/color.h +++ b/src/sp65/color.h @@ -60,7 +60,7 @@ struct Color { /*****************************************************************************/ - + #if defined(HAVE_INLINE) INLINE Color RGB (unsigned char R, unsigned char G, unsigned char B) diff --git a/src/sp65/geosbitmap.h b/src/sp65/geosbitmap.h index 759030224..8f9f09a29 100644 --- a/src/sp65/geosbitmap.h +++ b/src/sp65/geosbitmap.h @@ -54,8 +54,8 @@ StrBuf* GenGeosBitmap (const Bitmap* B, const Collection* A); -/* Generate binary output in GEOS compacted bitmap format for the bitmap B. -** The output is stored in a string buffer (which is actually a dynamic char +/* Generate binary output in GEOS compacted bitmap format for the bitmap B. +** The output is stored in a string buffer (which is actually a dynamic char ** array) and returned. */ @@ -67,4 +67,4 @@ StrBuf* GenGeosBitmap (const Bitmap* B, const Collection* A); - + diff --git a/src/sp65/koala.c b/src/sp65/koala.c index e2122c781..688e37f61 100644 --- a/src/sp65/koala.c +++ b/src/sp65/koala.c @@ -94,7 +94,7 @@ StrBuf* GenKoala (const Bitmap* B, const Collection* A attribute ((unused))) /* Add $4400 as load address */ SB_AppendChar (D, 0x00); SB_AppendChar (D, 0x44); - + /* TODO: The actual work ;-) */ (void) Screen; diff --git a/src/sp65/lynxsprite.h b/src/sp65/lynxsprite.h index 4f9a9f07d..fe686ec8e 100644 --- a/src/sp65/lynxsprite.h +++ b/src/sp65/lynxsprite.h @@ -54,7 +54,7 @@ StrBuf* GenLynxSprite (const Bitmap* B, const Collection* A); -/* Generate binary output in packed Lynx sprite format for the bitmap B. The output +/* Generate binary output in packed Lynx sprite format for the bitmap B. The output ** is stored in a string buffer (which is actually a dynamic char array) and ** returned. */ diff --git a/src/sp65/vic2sprite.c b/src/sp65/vic2sprite.c index 94a9ad499..4ea71b562 100644 --- a/src/sp65/vic2sprite.c +++ b/src/sp65/vic2sprite.c @@ -83,7 +83,7 @@ static enum Mode GetMode (const Collection* A) } else { Error ("Invalid value for attribute 'mode'"); } - } + } return smAuto; } diff --git a/src/sp65/vic2sprite.h b/src/sp65/vic2sprite.h index b6c839c7c..ce2f078e4 100644 --- a/src/sp65/vic2sprite.h +++ b/src/sp65/vic2sprite.h @@ -54,7 +54,7 @@ StrBuf* GenVic2Sprite (const Bitmap* B, const Collection* A); -/* Generate binary output in VICII sprite format for the bitmap B. The output +/* Generate binary output in VICII sprite format for the bitmap B. The output ** is stored in a string buffer (which is actually a dynamic char array) and ** returned. */ diff --git a/targettest/Makefile b/targettest/Makefile index 806f6b445..0450bfd4e 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -673,6 +673,9 @@ EXELIST_atari2600 = \ EXELIST_atari5200 = \ minimal +EXELIST_atari7800 = \ + minimal + EXELIST_gamate = \ minimal @@ -728,6 +731,7 @@ TARGETS := \ atarixl \ atari2600 \ atari5200 \ + atari7800 \ atmos \ bbc \ c128 \ diff --git a/targettest/accelerator/Makefile b/targettest/accelerator/Makefile index bcddac1fa..dd5011459 100644 --- a/targettest/accelerator/Makefile +++ b/targettest/accelerator/Makefile @@ -32,16 +32,16 @@ endif EXELIST_c64 = \ c64-scpu-test.prg \ - c128-scpu-test.prg \ c64dtv-test.prg \ - c64-c128-test.prg \ + c64-test.prg \ chameleon-test.prg \ c65-test.prg \ turbomaster-test.prg - + EXELIST_c128 = \ + c128-scpu-test.prg \ c128-test.prg - + ifneq ($(EXELIST_$(SYS)),) testcode: $(EXELIST_$(SYS)) else @@ -58,24 +58,16 @@ else endif c64-scpu-test.prg: c64-c128-scpu-test.c -# do not use cl65 to prevent tests from failing randomly because of one process -# deleting the temp files from another -# $(CL) -t c64 c64-c128-scpu-test.c -o c64-scpu-test.prg - $(CC) -t c64 c64-c128-scpu-test.c -o c64-scpu-test.s - $(CL) -t c64 c64-scpu-test.s -o c64-scpu-test.prg + $(CL) -t c64 c64-c128-scpu-test.c -o c64-scpu-test.prg c128-scpu-test.prg: c64-c128-scpu-test.c -# do not use cl65 to prevent tests from failing randomly because of one process -# deleting the temp files from another -# $(CL) -t c128 c64-c128-scpu-test.c -o c128-scpu-test.prg - $(CC) -t c128 c64-c128-scpu-test.c -o c128-scpu-test.s - $(CL) -t c128 c128-scpu-test.s -o c128-scpu-test.prg + $(CL) -t c128 c64-c128-scpu-test.c -o c128-scpu-test.prg c64dtv-test.prg: c64dtv-test.c $(CL) -t c64 c64dtv-test.c -o c64dtv-test.prg -c64-c128-test.prg: c64-c128-test.c - $(CL) -t c64 c64-c128-test.c -o c64-c128-test.prg +c64-test.prg: c64-c128-test.c + $(CL) -t c64 c64-c128-test.c -o c64-test.prg c128-test.prg: c64-c128-test.c $(CL) -t c128 c64-c128-test.c -o c128-test.prg @@ -91,4 +83,3 @@ turbomaster-test.prg: turbomaster-test.c clean: @$(DEL) *.prg 2>$(NULLDEV) - @$(DEL) *.s 2>$(NULLDEV) diff --git a/targettest/cpeek-test.c b/targettest/cpeek-test.c index 1777bce4a..4c1aadcb2 100644 --- a/targettest/cpeek-test.c +++ b/targettest/cpeek-test.c @@ -294,8 +294,8 @@ int main (void) revers(0); cputc('x'); chBack (); c1 = cpeekrevers(); chForth(); revers(1); cputc('X'); chBack (); c2 = cpeekrevers(); chForth(); cputc('\n'); cputc('\r'); - revers(c1); cputc('o'); - revers(c2); cputc('O'); + revers(c1); cputc('o'); + revers(c2); cputc('O'); /* test cpeeks() */ revers(0); diff --git a/targettest/ft.c b/targettest/ft.c index 880df6369..3dfa0e37b 100644 --- a/targettest/ft.c +++ b/targettest/ft.c @@ -8,7 +8,7 @@ ** ** The program asks for a filename (if it hasn't ** got one from argv). I then opens the file, -** reads the the first 16 bytes and displays them +** reads the first 16 bytes and displays them ** (as hex values). ** The values of sp (cc65 runtime stack pointer) ** are displayed at some places. The displayed diff --git a/targettest/gamate/audiotest.s b/targettest/gamate/audiotest.s index f40199994..4f1496789 100644 --- a/targettest/gamate/audiotest.s +++ b/targettest/gamate/audiotest.s @@ -155,7 +155,7 @@ nocursor: .proc printy ldy #0 -loop1: +loop1: tya pha asl diff --git a/targettest/minimal.c b/targettest/minimal.c index 65ec37a97..f950a5d13 100644 --- a/targettest/minimal.c +++ b/targettest/minimal.c @@ -1,4 +1,4 @@ - + /* this is a minimal / empty c program, any supported target that has some * sort of C support should be able to link this. Failure indicates a problem * with the crt0 or the linker config of the respective target */ diff --git a/targettest/uname-test.c b/targettest/uname-test.c index b0733d0bd..2851da19c 100644 --- a/targettest/uname-test.c +++ b/targettest/uname-test.c @@ -4,7 +4,7 @@ int main (void) -{ +{ /* Get the uname data */ struct utsname buf; if (uname (&buf) != 0) { @@ -12,7 +12,7 @@ int main (void) return EXIT_FAILURE; } - /* Print it */ + /* Print it */ printf ("sysname: \"%s\"\n", buf.sysname); printf ("nodename: \"%s\"\n", buf.nodename); printf ("release: \"%s\"\n", buf.release); diff --git a/test/asm/Makefile b/test/asm/Makefile index e951c2015..b35c30c9f 100644 --- a/test/asm/Makefile +++ b/test/asm/Makefile @@ -1,77 +1,34 @@ -# Makefile for the assembler regression tests +# top-level Makefile for the regression tests ifneq ($(shell echo),) CMD_EXE = 1 endif ifdef CMD_EXE - EXE = .exe - MKDIR = mkdir $(subst /,\,$1) - RMDIR = -rmdir /q /s $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) else - EXE = - MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 endif -ifdef QUIET - .SILENT: -endif +WORKDIR = ../testwrk/asm -CA65 := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65) -LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) +SUBDIRS = cpudetect opcodes listing -WORKDIR = ../../testwrk/asm +.PHONY: all continue mostlyclean clean -ISEQUAL = ../../testwrk/isequal$(EXE) +all: mostlyclean continue -CC = gcc -CFLAGS = -O2 +define CALL_template -.PHONY: all clean +continue:: + @$(MAKE) -C $1 all -OPCODE_REFS := $(wildcard *-opcodes.ref) -OPCODE_BINS = $(OPCODE_REFS:%.ref=$(WORKDIR)/%.bin) -OPCODE_CPUS = $(OPCODE_REFS:%-opcodes.ref=%) +mostlyclean:: + @$(MAKE) -C $1 clean -CPUDETECT_REFS := $(wildcard *-cpudetect.ref) -CPUDETECT_BINS = $(CPUDETECT_REFS:%.ref=$(WORKDIR)/%.bin) -CPUDETECT_CPUS = $(CPUDETECT_REFS:%-cpudetect.ref=%) +endef -all: $(OPCODE_BINS) $(CPUDETECT_BINS) $(WORKDIR)/paramcount.o +$(foreach subdir,$(SUBDIRS),$(eval $(call CALL_template,$(subdir)))) -$(WORKDIR): - $(call MKDIR,$(WORKDIR)) - -$(ISEQUAL): ../isequal.c | $(WORKDIR) - $(CC) $(CFLAGS) -o $@ $< - -define OPCODE_template - -$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL) - $(if $(QUIET),echo asm/$1-opcodes.bin) - $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< - $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib - $(ISEQUAL) $1-opcodes.ref $$@ - -endef # OPCODE_template - -$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) - -define CPUDETECT_template - -$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $1-cpudetect.ref $(ISEQUAL) - $(if $(QUIET),echo asm/$1-cpudetect.bin) - $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< - $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib - $(ISEQUAL) $1-cpudetect.ref $$@ - -endef # CPUDETECT_template - -$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu)))) - -$(WORKDIR)/%.o: %.s | $(WORKDIR) - $(CA65) -l $(@:.o=.lst) -o $@ $< - -clean: +clean: mostlyclean @$(call RMDIR,$(WORKDIR)) diff --git a/test/asm/4510-cpudetect.ref b/test/asm/cpudetect/4510-cpudetect.ref similarity index 100% rename from test/asm/4510-cpudetect.ref rename to test/asm/cpudetect/4510-cpudetect.ref diff --git a/test/asm/6502-cpudetect.ref b/test/asm/cpudetect/6502-cpudetect.ref similarity index 100% rename from test/asm/6502-cpudetect.ref rename to test/asm/cpudetect/6502-cpudetect.ref diff --git a/test/asm/6502dtv-cpudetect.ref b/test/asm/cpudetect/6502dtv-cpudetect.ref similarity index 100% rename from test/asm/6502dtv-cpudetect.ref rename to test/asm/cpudetect/6502dtv-cpudetect.ref diff --git a/test/asm/6502x-cpudetect.ref b/test/asm/cpudetect/6502x-cpudetect.ref similarity index 100% rename from test/asm/6502x-cpudetect.ref rename to test/asm/cpudetect/6502x-cpudetect.ref diff --git a/test/asm/65816-cpudetect.ref b/test/asm/cpudetect/65816-cpudetect.ref similarity index 100% rename from test/asm/65816-cpudetect.ref rename to test/asm/cpudetect/65816-cpudetect.ref diff --git a/test/asm/65c02-cpudetect.ref b/test/asm/cpudetect/65c02-cpudetect.ref similarity index 100% rename from test/asm/65c02-cpudetect.ref rename to test/asm/cpudetect/65c02-cpudetect.ref diff --git a/test/asm/65sc02-cpudetect.ref b/test/asm/cpudetect/65sc02-cpudetect.ref similarity index 100% rename from test/asm/65sc02-cpudetect.ref rename to test/asm/cpudetect/65sc02-cpudetect.ref diff --git a/test/asm/cpudetect/Makefile b/test/asm/cpudetect/Makefile new file mode 100644 index 000000000..ffddb1ad8 --- /dev/null +++ b/test/asm/cpudetect/Makefile @@ -0,0 +1,61 @@ +# Makefile for the assembler regression tests + +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /q /s $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + +ifdef QUIET + .SILENT: +endif + +CA65 := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65) +LD65 := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65) + +WORKDIR = ../../../testwrk/asm/cpudetect + +ISEQUAL = ../../../testwrk/isequal$(EXE) + +CC = gcc +CFLAGS = -O2 + +.PHONY: all clean + +CPUDETECT_REFS := $(wildcard *-cpudetect.ref) +CPUDETECT_BINS = $(CPUDETECT_REFS:%.ref=$(WORKDIR)/%.bin) +CPUDETECT_CPUS = $(CPUDETECT_REFS:%-cpudetect.ref=%) + +all: $(CPUDETECT_BINS) + +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(ISEQUAL): ../../isequal.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define CPUDETECT_template + +$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $1-cpudetect.ref $(ISEQUAL) + $(if $(QUIET),echo asm/$1-cpudetect.bin) + $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< + $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib + $(ISEQUAL) $1-cpudetect.ref $$@ + +endef # CPUDETECT_template + +$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu)))) + +$(WORKDIR)/%.o: %.s | $(WORKDIR) + $(CA65) -l $(@:.o=.lst) -o $@ $< + +clean: + @$(call RMDIR,$(WORKDIR)) diff --git a/test/asm/cpudetect.s b/test/asm/cpudetect/cpudetect.s similarity index 100% rename from test/asm/cpudetect.s rename to test/asm/cpudetect/cpudetect.s diff --git a/test/asm/huc6280-cpudetect.ref b/test/asm/cpudetect/huc6280-cpudetect.ref similarity index 100% rename from test/asm/huc6280-cpudetect.ref rename to test/asm/cpudetect/huc6280-cpudetect.ref diff --git a/test/asm/cpudetect/readme.txt b/test/asm/cpudetect/readme.txt new file mode 100644 index 000000000..6a1adf480 --- /dev/null +++ b/test/asm/cpudetect/readme.txt @@ -0,0 +1,15 @@ +CPU Detect Tests +---------------- + +These tests all assemble the same file "cpudetect.s" which contains several +conditionals for several CPUs, only using every option known to the "--cpu" +command-line switch of ca65/cl65. + +Reference (".ref") Files +------------------------ + +Some hints about creating new files: +Make an empty file with the CPU's name prepended to "-cpudetect.ref". Run the +tests; one of them will fail due to a mismatch. Review the output of the +".lst" file pedantically, then copy the ".bin" over the empty ".ref" file. + diff --git a/test/asm/listing/Makefile b/test/asm/listing/Makefile new file mode 100644 index 000000000..c152db7be --- /dev/null +++ b/test/asm/listing/Makefile @@ -0,0 +1,89 @@ +# Makefile for the assembler regression tests + +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /q /s $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + +ifdef QUIET + .SILENT: +endif + +CA65 := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65) +LD65 := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65) + +WORKDIR = ../../../testwrk/asm/listing + +ISEQUAL = ../../../testwrk/isequal$(EXE) + +CC = gcc +CFLAGS = -O2 + +.PHONY: all clean + +LISTING_SRC := $(wildcard *.s) +LISTING_TESTS = $(LISTING_SRC:%.s=%) +LISTING_BINS = $(LISTING_SRC:%.s=$(WORKDIR)/%.bin) + +all: $(LISTING_BINS) + +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(ISEQUAL): ../../isequal.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + + +define LISTING_template + +$(WORKDIR)/$1.bin: $1.s $(ISEQUAL) + $(if $(QUIET),echo asm/$1.bin) + +# compile without generating listing + $(CA65) -t none -o $$(@:.bin=.o) $$< + $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib + +ifneq ($(wildcard $1.bin-ref),) + $(ISEQUAL) $1.bin-ref $$@ +endif + + $(CA65) -t none -l $$(@:.bin=.list.orig) -o $$(@:.bin=.list-o) $$< + $(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib + +# check if the result bin is the same as without listing file + $(ISEQUAL) $$@ $$(@:.bin=.list-bin) + +ifneq ($(wildcard $1.list-ref),) +# we have a reference file, compare that, too + +# remove first line which contains a version number + tail -n +2 $$(@:.bin=.lst.orig) > $$(@:.bin=.lst) + $(ISEQUAL) $1.list-ref $$(@:.bin=.lst) +endif + +# $(CA65) -t none -f -l $$(@:.bin=.flist.orig) -o $$(@:.bin=.flist-o) $$< +# $(LD65) -t none -o $$(@:.bin=.flist-bin) $$(@:.bin=.flist-o) none.lib + +# # check if the result bin is the same as without listing file +# $(ISEQUAL) $$@ $$(@:.bin=.flist-bin) + +endef # LISTING_template + + +$(foreach listing,$(LISTING_TESTS),$(eval $(call LISTING_template,$(listing)))) + + +$(WORKDIR)/%.o: %.s | $(WORKDIR) + $(CA65) -l $(@:.o=.lst) -o $@ $< + +clean: + @$(call RMDIR,$(WORKDIR)) diff --git a/test/asm/paramcount.s b/test/asm/listing/paramcount.s similarity index 100% rename from test/asm/paramcount.s rename to test/asm/listing/paramcount.s diff --git a/test/asm/listing/readme.txt b/test/asm/listing/readme.txt new file mode 100644 index 000000000..e43f2008a --- /dev/null +++ b/test/asm/listing/readme.txt @@ -0,0 +1,27 @@ +Overall test: +------------- + +These testcases can be used to test different aspects of the assembler. +The name of a test is everything in the form <test>.s. + +The following reference files can be added: + +- <test>.bin-ref: + This is a reference for the resulting binary. + The binary as binary tested against this file. + If they are not equal, the test fails. + +- <test>.list-ref + This is a reference for the resulting listing output + This file *must* have the first line of the listing removed, as that + contains a ca65 version string, and almost always this will be changed! + + +Note that the resulting .bin file is generated twice: Once with no listing +file, and once with listing file. This way, one can find out if the listing +file generation changes anything with the resulting binary output. + + +TODO: +- add the possibility to test for specific error output that are to be + expected diff --git a/test/asm/4510-opcodes.ref b/test/asm/opcodes/4510-opcodes.ref similarity index 100% rename from test/asm/4510-opcodes.ref rename to test/asm/opcodes/4510-opcodes.ref diff --git a/test/asm/4510-opcodes.s b/test/asm/opcodes/4510-opcodes.s similarity index 100% rename from test/asm/4510-opcodes.s rename to test/asm/opcodes/4510-opcodes.s diff --git a/test/asm/6502-opcodes.ref b/test/asm/opcodes/6502-opcodes.ref similarity index 100% rename from test/asm/6502-opcodes.ref rename to test/asm/opcodes/6502-opcodes.ref diff --git a/test/asm/6502-opcodes.s b/test/asm/opcodes/6502-opcodes.s similarity index 100% rename from test/asm/6502-opcodes.s rename to test/asm/opcodes/6502-opcodes.s diff --git a/test/asm/6502dtv-opcodes.ref b/test/asm/opcodes/6502dtv-opcodes.ref similarity index 100% rename from test/asm/6502dtv-opcodes.ref rename to test/asm/opcodes/6502dtv-opcodes.ref diff --git a/test/asm/6502dtv-opcodes.s b/test/asm/opcodes/6502dtv-opcodes.s similarity index 100% rename from test/asm/6502dtv-opcodes.s rename to test/asm/opcodes/6502dtv-opcodes.s diff --git a/test/asm/6502x-opcodes.ref b/test/asm/opcodes/6502x-opcodes.ref similarity index 100% rename from test/asm/6502x-opcodes.ref rename to test/asm/opcodes/6502x-opcodes.ref diff --git a/test/asm/6502x-opcodes.s b/test/asm/opcodes/6502x-opcodes.s similarity index 100% rename from test/asm/6502x-opcodes.s rename to test/asm/opcodes/6502x-opcodes.s diff --git a/test/asm/65c02-opcodes.ref b/test/asm/opcodes/65c02-opcodes.ref similarity index 100% rename from test/asm/65c02-opcodes.ref rename to test/asm/opcodes/65c02-opcodes.ref diff --git a/test/asm/65c02-opcodes.s b/test/asm/opcodes/65c02-opcodes.s similarity index 100% rename from test/asm/65c02-opcodes.s rename to test/asm/opcodes/65c02-opcodes.s diff --git a/test/asm/65sc02-opcodes.ref b/test/asm/opcodes/65sc02-opcodes.ref similarity index 100% rename from test/asm/65sc02-opcodes.ref rename to test/asm/opcodes/65sc02-opcodes.ref diff --git a/test/asm/65sc02-opcodes.s b/test/asm/opcodes/65sc02-opcodes.s similarity index 100% rename from test/asm/65sc02-opcodes.s rename to test/asm/opcodes/65sc02-opcodes.s diff --git a/test/asm/opcodes/Makefile b/test/asm/opcodes/Makefile new file mode 100644 index 000000000..00be96d91 --- /dev/null +++ b/test/asm/opcodes/Makefile @@ -0,0 +1,61 @@ +# Makefile for the assembler regression tests + +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /q /s $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + +ifdef QUIET + .SILENT: +endif + +CA65 := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65) +LD65 := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65) + +WORKDIR = ../../../testwrk/asm/opcodes + +ISEQUAL = ../../../testwrk/isequal$(EXE) + +CC = gcc +CFLAGS = -O2 + +.PHONY: all clean + +OPCODE_REFS := $(wildcard *-opcodes.ref) +OPCODE_BINS = $(OPCODE_REFS:%.ref=$(WORKDIR)/%.bin) +OPCODE_CPUS = $(OPCODE_REFS:%-opcodes.ref=%) + +all: $(OPCODE_BINS) + +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(ISEQUAL): ../../isequal.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define OPCODE_template + +$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL) + $(if $(QUIET),echo asm/$1-opcodes.bin) + $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< + $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib + $(ISEQUAL) $1-opcodes.ref $$@ + +endef # OPCODE_template + +$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) + +$(WORKDIR)/%.o: %.s | $(WORKDIR) + $(CA65) -l $(@:.o=.lst) -o $@ $< + +clean: + @$(call RMDIR,$(WORKDIR)) diff --git a/test/asm/huc6280-opcodes.ref b/test/asm/opcodes/huc6280-opcodes.ref similarity index 100% rename from test/asm/huc6280-opcodes.ref rename to test/asm/opcodes/huc6280-opcodes.ref diff --git a/test/asm/huc6280-opcodes.s b/test/asm/opcodes/huc6280-opcodes.s similarity index 100% rename from test/asm/huc6280-opcodes.s rename to test/asm/opcodes/huc6280-opcodes.s diff --git a/test/asm/m740-opcodes.s b/test/asm/opcodes/m740-opcodes.s similarity index 100% rename from test/asm/m740-opcodes.s rename to test/asm/opcodes/m740-opcodes.s diff --git a/test/asm/opcodes/readme.txt b/test/asm/opcodes/readme.txt new file mode 100644 index 000000000..098dd549a --- /dev/null +++ b/test/asm/opcodes/readme.txt @@ -0,0 +1,29 @@ +Opcode Tests: +------------- + +These testcases are inspired by the ones now removed from test/assembler. +The main purpose is to have each possible opcode generated at least once, +either by an Assembly instruction or a ".byte"-placeholder. Typically +generated by disassembling a binary dump that contains data in the form +of the pattern that each opcode is stated once in order followed by easy +to recognise: + +00 00 EA 00 +01 00 EA 00 +02 00 EA 00 +[...] +fe 00 EA 00 +ff 00 EA 00 + +The disassembly is then put in a better readable form by replacing the +leftover dummy opcode parameters with something more recognizable. + +The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been +put together by Sven Oliver ("SvOlli") Moll, as well as a template for the +m740 instructions set. Later 6502dtv support was also added. + +Still to do is to find a way to implement an opcode testcase for the 65816 +processor, since it's capable of executing instructions with an 8-bit and +a 16-bit operator alike, distinguished by only one processor flag. + + diff --git a/test/asm/readme.txt b/test/asm/readme.txt index 1d135c895..18354bb47 100644 --- a/test/asm/readme.txt +++ b/test/asm/readme.txt @@ -4,44 +4,16 @@ Assembler Testcases Opcode Tests: ------------- -These testcases are inspired by the ones now removed from test/assembler. -The main purpose is to have each possible opcode generated at least once, -either by an Assembly instruction or a ".byte"-placeholder. Typically -generated by disassembling a binary dump that contains data in the form -of the pattern that each opcode is stated once in order followed by easy -to recognise: - -00 00 EA 00 -01 00 EA 00 -02 00 EA 00 -[...] -fe 00 EA 00 -ff 00 EA 00 - -The disassembly is then put in a better readable form by replacing the -leftover dummy opcode parameters with something more recognizable. - -The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been -put together by Sven Oliver ("SvOlli") Moll, as well as a template for the -m740 instructions set. Later 6502dtv support was also added. - -Still to do is to find a way to implement an opcode testcase for the 65816 -processor, since it's capable of executing instructions with an 8-bit and -a 16-bit operator alike, distinguished by only one processor flag. +these go into opcodes/. Refer to opcodes/readme.txt CPU Detect Tests ---------------- -These tests all assemble the same file "cpudetect.s" which contains several -conditionals for several CPUs, only using every option known to the "--cpu" -command-line switch of ca65/cl65. +these go into cpudetect/. Refer to cpudetect/readme.txt -Reference (".ref") Files ------------------------- +Overall tests: +-------------- -Some hints about creating new files: -Make an empty file with the CPU's name prepended to "-cpudetect.ref". Run the -tests; one of them will fail due to a mismatch. Review the output of the -".lst" file pedantically, then copy the ".bin" over the empty ".ref" file. +These go into listing/. Refer to listing/readme.txt diff --git a/test/err/bug1098.c b/test/err/bug1098.c index c49296245..eddbce3f1 100644 --- a/test/err/bug1098.c +++ b/test/err/bug1098.c @@ -1,7 +1,7 @@ /* bug #1098 Empty enumerator-list */ -/* The C Standard requires that something exists between the braces for +/* The C Standard requires that something exists between the braces for * enum, struct, and union. */ enum { diff --git a/test/err/bug1098a.c b/test/err/bug1098a.c index 63c1c8da0..aed750267 100644 --- a/test/err/bug1098a.c +++ b/test/err/bug1098a.c @@ -1,7 +1,7 @@ /* bug #1098 Empty enumerator-list */ -/* The C Standard requires that something exists between the braces for +/* The C Standard requires that something exists between the braces for * enum, struct, and union. */ struct { diff --git a/test/err/bug1098b.c b/test/err/bug1098b.c index ebd3e94c8..5f6d8b0f2 100644 --- a/test/err/bug1098b.c +++ b/test/err/bug1098b.c @@ -1,7 +1,7 @@ /* bug #1098 Empty enumerator-list */ -/* The C Standard requires that something exists between the braces for +/* The C Standard requires that something exists between the braces for * enum, struct, and union. */ union { diff --git a/test/err/cc65091001.c b/test/err/cc65091001.c index 65ce6ec83..8bcf158ac 100644 --- a/test/err/cc65091001.c +++ b/test/err/cc65091001.c @@ -27,4 +27,4 @@ int main() { printf("it works :)\n"); return 0; -} \ No newline at end of file +} diff --git a/test/err/pr1110.c b/test/err/pr1110.c index 86955c720..671abf9a4 100644 --- a/test/err/pr1110.c +++ b/test/err/pr1110.c @@ -1,5 +1,5 @@ -/* pr #1110 - not only should the current test case for #975 compile and work, +/* pr #1110 - not only should the current test case for #975 compile and work, * but also the code piece below fail to compile and generate errors like commented: */ static const unsigned char array[3]; /* OK */ @@ -7,7 +7,7 @@ static const unsigned char array[] = { 0, 1, 2 }; /* OK - complete definition* static const unsigned char array[3]; /* OK */ static const unsigned char array[]; /* OK */ static const unsigned char array[] = { 1, 2, 3 }; /* Error - redefinition */ -static const unsigned char array[4]; /* Error - conflicting size */ +static const unsigned char array[4]; /* Error - conflicting size */ int main(void) { diff --git a/test/misc/bug1265.c b/test/misc/bug1265.c index 36d1459a7..7c34a25b7 100644 --- a/test/misc/bug1265.c +++ b/test/misc/bug1265.c @@ -17,7 +17,7 @@ int main (void) { x = 1234; n = f1 (x); sprintf (str2, "%p\n", &x); - + if (strcmp(str1, str2)) { puts("not equal"); failures++; @@ -31,7 +31,7 @@ int main (void) { x = 2345; n = f2 (x); sprintf (str2, "%p\n", &x); - + if (strcmp(str1, str2)) { puts("not equal"); failures++; diff --git a/test/misc/sitest.c b/test/misc/sitest.c index d13acf92c..6c8a6f1e2 100644 --- a/test/misc/sitest.c +++ b/test/misc/sitest.c @@ -38,7 +38,7 @@ #ifdef NO_WCHAR -#warn "this test checks C99 features, but NO_WCHAR is defined so the test will most definitely fail." +#warning "this test checks C99 features, but NO_WCHAR is defined so the test will most definitely fail." #endif @@ -106,7 +106,7 @@ int main() { int status = 0; /* exit status to be returned */ - + /* <stdint.h> features: */ printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); @@ -526,12 +526,12 @@ main() { else /* for trailing semicolon */ #else - + #define SCAN(buf,fs,var,exp) #define PRINT(fs,var,exp) #endif - + #ifdef SCNo32 SCAN(in_dn, SCNo32, int32, 9); @@ -586,7 +586,7 @@ main() { #endif #if 0 - + #ifdef INT16_MAX { INT16_MAX, INT16_MAX, }, { -INT16_MAX, INT16_MAX, }, @@ -830,7 +830,7 @@ main() { } #endif } - + { char *endptr; wchar_t *wendptr; diff --git a/test/ref/array.c b/test/ref/array.c index 96bf22c3a..19265ef90 100644 --- a/test/ref/array.c +++ b/test/ref/array.c @@ -29,7 +29,7 @@ main() { p[j] = x[i][j]; } g(z, y); - + return 0; } diff --git a/test/ref/cc65070303.c b/test/ref/cc65070303.c index 6dbceeefc..6cf2e9dc7 100644 --- a/test/ref/cc65070303.c +++ b/test/ref/cc65070303.c @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) test.c(20): Error: Incompatible pointer types for   APtr=&(Bs[7].Data[1]); -My experience in C is very limited, but as this works both in MSVC and +My experience in C is very limited, but as this works both in MSVC and the 8 bit Z80 compiler i originally used, i guess its an bug in CC65. As a workaround, an typecast via  APtr=(TypA*)&(Bs[7].Data[1]); @@ -35,4 +35,4 @@ seems to work. greetings,    Andreas -*/ \ No newline at end of file +*/ diff --git a/test/ref/cc65080227.c b/test/ref/cc65080227.c index 78afbb2c2..86d5ee331 100644 --- a/test/ref/cc65080227.c +++ b/test/ref/cc65080227.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! @@ -36,4 +36,4 @@ int main(void) 000023r 1 A4 rr ldy sreg 000025r 1 8C rr rr sty _b+2 000028r 1 8C rr rr sty _b+3 ; lost 4th BYTE ! -*/ \ No newline at end of file +*/ diff --git a/test/ref/cc65080328.c b/test/ref/cc65080328.c index 630638f3d..7e26ea20a 100644 --- a/test/ref/cc65080328.c +++ b/test/ref/cc65080328.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! diff --git a/test/ref/cc65090111.c b/test/ref/cc65090111.c index be889a608..30b2b3cd0 100644 --- a/test/ref/cc65090111.c +++ b/test/ref/cc65090111.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! diff --git a/test/ref/cc65090124.c b/test/ref/cc65090124.c index 3a75b28fa..910dc1195 100644 --- a/test/ref/cc65090124.c +++ b/test/ref/cc65090124.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! @@ -8,7 +8,7 @@ #include <stdio.h> /* -there is a bug in the preprocessor (i think) ... the following works +there is a bug in the preprocessor (i think) ... the following works (compiles) correctly: unsigned long fs,fd,a; @@ -32,7 +32,7 @@ int main(void) fs=(func((fd/a),(func(2,0x0082c90f)))); } -i get "Error: ')' expected" on that line. (this is with the snapshot, freshly +i get "Error: ')' expected" on that line. (this is with the snapshot, freshly compiled 5 minutes ago) */ diff --git a/test/ref/cc65090726.c b/test/ref/cc65090726.c index 609594dc4..f22b9c203 100644 --- a/test/ref/cc65090726.c +++ b/test/ref/cc65090726.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! @@ -36,7 +36,7 @@ void Proc1(RecordPtr PtrParIn) Proc3((*(PtrParIn->PtrComp)).PtrComp); Proc3(NextRecord.PtrComp); #endif - + #undef NextRecord } diff --git a/test/ref/cc65101209.c b/test/ref/cc65101209.c index c14543640..eba209d1d 100644 --- a/test/ref/cc65101209.c +++ b/test/ref/cc65101209.c @@ -34,5 +34,5 @@ So testing with 999 gives: 231 mod 999 is 0 999 mod 999 is 0 -This seems to be systematic. -*/ \ No newline at end of file +This seems to be systematic. +*/ diff --git a/test/ref/cc65101216.c b/test/ref/cc65101216.c index eaaf0b3e4..1f6101afa 100644 --- a/test/ref/cc65101216.c +++ b/test/ref/cc65101216.c @@ -24,4 +24,4 @@ int main() printf("a / b = %d", c); return 0; -} \ No newline at end of file +} diff --git a/test/ref/cf.c b/test/ref/cf.c index bb0c13e8b..6001009ce 100644 --- a/test/ref/cf.c +++ b/test/ref/cf.c @@ -67,7 +67,7 @@ char *argv[]; } printf("input:\n\n"); - + nc = 0; while ((c = GETCHAR()) != -1) { diff --git a/test/ref/strptr.c b/test/ref/strptr.c index 152c1bb48..d596e19d1 100644 --- a/test/ref/strptr.c +++ b/test/ref/strptr.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! !!ORIGIN!! testsuite !!LICENCE!! Public Domain !!AUTHOR!! Groepaz/Hitmen @@ -24,7 +24,7 @@ FILE *outfile=NULL; #else #endif - + #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -65,17 +65,17 @@ static unsigned char ch; /* basic line-link / file-length */ memcpy(buffer,b1,4); - - dir->off=dir->off+4; + + dir->off=dir->off+4; entry.d_reclen=254*(buffer[2]+(buffer[3]<<8)); /* read file entry */ memcpy(buffer,b2,0x10); - - dir->off=dir->off+i; + + dir->off=dir->off+i; printf("Xreaddir: '%s'\n",buffer); - + /* skip until either quote (file) or b (blocks free => end) */ i=0;ii=0; while(i==0){ @@ -113,9 +113,9 @@ int main(void) char mydirname[XNAME_MAX+1]="."; XDIR mydir; struct Xdirent *mydirent; - + printf("start\n"); - + if((mydirent=Xreaddir(&mydir))==NULL) { printf("NULL\n"); diff --git a/test/ref/struct.c b/test/ref/struct.c index 15fae62fc..e5957f265 100644 --- a/test/ref/struct.c +++ b/test/ref/struct.c @@ -246,7 +246,7 @@ rect screen = ); test1(); - + for (i = 0; i < sizeof pts/sizeof pts[0]; i++) { printf("(%d,%d) is ", pts[i].x, (x = makepoint(pts[i].x, pts[i].y)).y); diff --git a/test/ref/switch2.c b/test/ref/switch2.c index 78d383b52..0e52775e4 100644 --- a/test/ref/switch2.c +++ b/test/ref/switch2.c @@ -169,7 +169,7 @@ void testdefault2(unsigned char i) { case 170: break; - + case 18: break; case 19: @@ -215,12 +215,12 @@ int main(void) { testlimits(32767); testlimits(-32768); testlimits(-1); - + testdefault1(1); testdefault1(2); testdefault1(3); testdefault1(4); - + testdefault2(1); testdefault2(2); testdefault2(3); diff --git a/test/ref/yacc.c b/test/ref/yacc.c index 776e4f93d..3831b67fd 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -70,7 +70,7 @@ int yytchar; #define yyout outfile extern int yylineno; -struct yysvf +struct yysvf { struct yywork *yystoff; struct yysvf *yyother; @@ -150,7 +150,7 @@ yyfussy: } } - + #ifdef YYDEBUG fprintf(yyout,"yylex: return 0\n"); #endif @@ -164,9 +164,9 @@ int yyvstop[] = }; # define YYTYPE char -struct yywork -{ - YYTYPE verify, advance; +struct yywork +{ + YYTYPE verify, advance; } yycrank[] = { {0,0}, {0,0}, {1,3}, {0,0}, @@ -178,12 +178,12 @@ struct yywork {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, - + {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, - + {0,0}, {1,5}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, @@ -193,17 +193,17 @@ struct yywork {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {0,0}, {0,0}, {0,0}, - + {0,0}, {0,0}, {0,0}, {0,0}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, - + {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {0,0}, {0,0}, - + {0,0}, {0,0}, {6,8}, {0,0}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, @@ -240,7 +240,7 @@ struct yywork }; /* -struct yysvf +struct yysvf { struct yywork *yystoff; struct yysvf *yyother; @@ -281,27 +281,27 @@ char yymatch[] = #endif 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - + 011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - + '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 , - + /* 0x40 (ascii) @A... (petscii) @a... */ 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,'A' , - + /* 0x60 (ascii) @a... */ 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , - + #ifdef CHARSETHACK /* 0x80 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, @@ -312,10 +312,10 @@ char yymatch[] = /* 0xc0 (petcii) @A... */ 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - + 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , - + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, @@ -354,9 +354,9 @@ yylook() int debug; # endif */ - + char *yylastch; - + /* start off machines */ /* @@ -372,11 +372,11 @@ yylook() # else #define debug 0 #endif - + #ifdef YYDEBUG fprintf(yyout,"yylook()\n"); # endif - + if (!yymorfg) yylastch = yytext; else @@ -388,7 +388,7 @@ yylook() #ifdef YYDEBUG fprintf(yyout,"yylook: yymorfg=%d\n",yymorfg); # endif - + for(;;) { #ifdef YYDEBUG @@ -400,7 +400,7 @@ yylook() if (yyprevious==YYNEWLINE) yystate++; testbreak=0; - + for (;;) { # ifdef LEXDEBUG @@ -412,12 +412,12 @@ yylook() exit(EXIT_FAILURE); } testbreak++; - + yyt = yystate->yystoff; /* fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); */ - + if(yyt == yycrank) { /* may not be any transitions */ yyz = yystate->yyother; @@ -430,7 +430,7 @@ yylook() fprintf(yyout,"yylook: input "); printchar("yych",yych); # endif - + tryagain: # ifdef LEXDEBUG @@ -440,7 +440,7 @@ yylook() yyr = yyt; /* fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ - + if ( yyt > yycrank) { yyt = yyr + yych; @@ -467,7 +467,7 @@ yylook() } # ifdef YYOPTIM else if(yyt < yycrank) /* r < yycrank */ - { + { yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG fprintf(yyout,"yylook: compressed state\n"); @@ -492,7 +492,7 @@ yylook() fprintf(yyout,"yylook: continue (2)\n"); # endif goto contin; - + } # ifdef LEXDEBUG /* @@ -509,12 +509,12 @@ yylook() */ fprintf(yyout,"yylook: try fall back character\n"); # endif - if(yyt <= yytop && yyt->verify+yysvec == yystate) + if(yyt <= yytop && yyt->verify+yysvec == yystate) { # ifdef LEXDEBUG fprintf(yyout,"yylook: (2a)\n"); # endif - + if(yyt->advance+yysvec == YYLERR) /* error transition */ { # ifdef LEXDEBUG @@ -531,7 +531,7 @@ yylook() fprintf(yyout,"yylook: continue (3)\n"); # endif goto contin; - + } # ifdef LEXDEBUG fprintf(yyout,"yylook: (2)\n"); @@ -578,7 +578,7 @@ yylook() { yyolsp = lsp; if(yyextra[*yyfnd]) /* must backup */ - { + { while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate) { lsp--; @@ -630,7 +630,7 @@ yylook() # endif } - + yyback(p, m) int *p; { @@ -648,25 +648,25 @@ yyback(p, m) yyinput() { int out=input(); - + #ifdef YYDEBUG fprintf(yyout,"yylook: input "); printchar("out",out); -#endif +#endif return(out); } yyoutput(c) - int c; + int c; { output(c); } yyunput(c) - int c; + int c; { unput(c); } -main() +main() { printf("main start\n"); infile = fopen("yacc.in","rb"); @@ -681,8 +681,8 @@ main() } /* yyerror - issue error message */ -yyerror(s) -char *s; +yyerror(s) +char *s; { printf("[%s]\n", s); } @@ -722,39 +722,39 @@ short yyact[]= 0, 0, 0, 0, 0, 0, 0, 6, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4, 6 + 0, 0, 0, 0, 0, 0, 0, 4, 6 }; short yypact[]= { -1000, -9,-1000, 5, -7, -59,-1000,-1000,-1000, -40, -29, -40, -40,-1000,-1000, -40, -40, -40, -40, -38, - -35, -38, -38,-1000,-1000,-1000 + -35, -38, -38,-1000,-1000,-1000 }; short yypgo[]= { - 0, 21, 20, 17, 11 + 0, 21, 20, 17, 11 }; short yyr1[]= { 0, 1, 1, 1, 1, 2, 4, 4, 4, 4, - 4, 4, 4, 4, 3 + 4, 4, 4, 4, 3 }; short yyr2[]= { 0, 0, 2, 3, 3, 3, 3, 3, 3, 3, - 2, 3, 1, 1, 1 + 2, 3, 1, 1, 1 }; short yychk[]= { -1000, -1, 10, -2, 256, -3, 257, 10, 10, 61, -4, 45, 40, -3, 258, 43, 45, 42, 47, -4, - -4, -4, -4, -4, -4, 41 + -4, -4, -4, -4, -4, 41 }; short yydef[]= { 1, -2, 2, 0, 0, 0, 14, 3, 4, 0, 5, 0, 0, 12, 13, 0, 0, 0, 0, 10, - 0, 6, 7, 8, 9, 11 + 0, 6, 7, 8, 9, 11 }; # define YYFLAG -1000 @@ -774,7 +774,7 @@ int yychar = -1; /* current input token number */ int yynerrs = 0; /* number of errors */ short yyerrflag = 0; /* error recovery flag */ -yyparse() +yyparse() { short yys[YYMAXDEPTH]; short yyj, yym; @@ -820,23 +820,23 @@ yyparse() #ifdef YYDEBUG printf("yyparse: yynewstate (1)\n"); #endif - + if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; #ifdef YYDEBUG - + printf("yyparse: yynewstate yyn=%d ",yyn); printchar("yychar",yychar); #endif - + if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; #ifdef YYDEBUG printf("yyparse: yynewstate (2)\n"); #endif - + if( yychk[ yyn=yyact[ yyn ] ] == yychar ) /* valid shift */ - { + { yychar = -1; yyval = yylval; yystate = yyn; @@ -872,9 +872,9 @@ yyparse() #ifdef YYDEBUG printf("yyparse: yyn=%d yyerrflag=%d\n",yyn,yyerrflag); #endif - + if( yyn == 0 ) /* error */ - { + { /* error ... attempt to resume parsing */ switch( yyerrflag ){ @@ -942,65 +942,65 @@ yyparse() yyn = yyr1[yyn]; yyj = yypgo[yyn] + *yyps + 1; if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; - + switch(yym) { case 4: - { - yyerrok; + { + yyerrok; } break; case 5: - { + { printf("[STORE]\n"); - } + } break; case 6: - { + { printf("[ADD]\n"); - } + } break; case 7: - { + { printf("[NEG]\n[ADD]\n"); - } + } break; case 8: - { + { printf("[MUL]\n"); - } + } break; case 9: - { + { printf("[DIV]\n"); - } + } break; case 10: - { - printf("[NEG]\n"); - } + { + printf("[NEG]\n"); + } break; case 12: - { - printf("[LOAD]\n"); - } + { + printf("[LOAD]\n"); + } break; case 13: - { + { printf("[PUSH %s]\n", yytext); - } + } break; case 14: - { + { printf("[%s]\n", yytext); - } + } break; } - + goto yystack; /* stack new state and value */ } - -int yywrap() -{ - return 1; + +int yywrap() +{ + return 1; } diff --git a/test/ref/yacc2.c b/test/ref/yacc2.c index 3b4819c55..33288b25d 100644 --- a/test/ref/yacc2.c +++ b/test/ref/yacc2.c @@ -8,9 +8,9 @@ #include <stdio.h> # define YYTYPE char -struct yywork -{ - YYTYPE verify, advance; +struct yywork +{ + YYTYPE verify, advance; } yycrank[] = { {0,0}, {0,0}, {1,3}, {0,0}, @@ -22,12 +22,12 @@ struct yywork {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, - + {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, - + {0,0}, {1,5}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, @@ -37,17 +37,17 @@ struct yywork {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {0,0}, {0,0}, {0,0}, - + {0,0}, {0,0}, {0,0}, {0,0}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, - + {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {0,0}, {0,0}, - + {0,0}, {0,0}, {6,8}, {0,0}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, {6,8}, @@ -90,7 +90,7 @@ int yyvstop[] = 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 }; -struct yysvf +struct yysvf { struct yywork *yystoff; struct yysvf *yyother; @@ -157,7 +157,7 @@ void subtest3(void) yyt=yycrank; yystate=yysvec; - + bogus(); if(yyt <= yytop && yyt->verify+yysvec == yystate) { @@ -173,7 +173,7 @@ void subtest3(void) short yyr2[]= { 0, 0, 2, 3, 3, 3, 3, 3, 3, 3, - 2, 3, 1, 1, 1 + 2, 3, 1, 1, 1 }; // yyps -= yyr2[yyn]; diff --git a/test/val/enum-bitfield.c b/test/val/bitfield-enum.c similarity index 61% rename from test/val/enum-bitfield.c rename to test/val/bitfield-enum.c index 5669978c9..ce74b062e 100644 --- a/test/val/enum-bitfield.c +++ b/test/val/bitfield-enum.c @@ -1,5 +1,5 @@ /* - Copyright 2020 The cc65 Authors + Copyright 2020-2022 The cc65 Authors This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -247,7 +247,7 @@ static void test_enum_bitfield_char(void) failures++; } if (e8scbf.y != 5) { - printf ("Got e8scbf.y = %d, expected 10.\n", e8scbf.y); + printf ("Got e8scbf.y = %d, expected 5.\n", e8scbf.y); failures++; } if (e8scbf.z != 100) { @@ -273,12 +273,170 @@ static void test_enum_bitfield_char(void) } } +/* Enum with underlying type unsigned long. */ +enum e20ul { + E20UL_10 = 10, + E20UL_1000 = 1000, + E20UL_1000000000 = 1000000000L, +}; + +static struct enum_bitfield_ulong { + enum e20ul x : 4; + enum e20ul y : 16; + enum e20ul z : CHAR_BIT * sizeof (enum e20ul); +} e20ulbf = {E20UL_10, E20UL_1000, E20UL_1000000000}; + +static void test_enum_bitfield_ulong(void) +{ + if (sizeof (struct enum_bitfield_ulong) != 7) { + printf ("Got sizeof(struct enum_bitfield_ulong) = %zu, expected 7.\n", + sizeof(struct enum_bitfield_ulong)); + failures++; + } + + if (e20ulbf.x != 10) { + printf ("Got e20ulbf.x = %u, expected 10.\n", e20ulbf.x); + failures++; + } + if (e20ulbf.y != 1000) { + printf ("Got e20ulbf.y = %u, expected 1000.\n", e20ulbf.y); + failures++; + } + if (e20ulbf.z != 1000000000L) { + printf ("Got e20ulbf.z = %ul, expected 1000000000.\n", e20ulbf.z); + failures++; + } + + e20ulbf.x = 8; + e20ulbf.y = -1; /* Will store 65535. */ + e20ulbf.z = 1048575L; + + if (e20ulbf.x != 8) { + printf ("Got e20ulbf.x = %ld, expected 8.\n", (long)e20ulbf.x); + failures++; + } + + /* Check signedness, should be signed. */ + { + if (e20ulbf.x - 9 >= 0) { + printf ("Got non-negative e20ulbf.x - 9 = %lu, expected negative.\n", (unsigned long)(e20ulbf.x - 9)); + failures++; + } + } + + if (e20ulbf.y != 65535L) { + printf ("Got e20ulbf.y = %ld, expected 65535.\n", (long)e20ulbf.y); + failures++; + } + + /* Check signedness, should be signed. */ + { + if (e20ulbf.y - 65536L >= 0) { + printf ("Got non-negative e20ulbf.y - 65536L = %lu, expected negative.\n", (unsigned long)(e20ulbf.y - 65536L)); + failures++; + } + } + + if (e20ulbf.z != 1048575L) { + printf ("Got e20ulbf.z = %lu, expected 1048575.\n", (unsigned long)e20ulbf.z); + failures++; + } + + /* Check signedness, should be unsigned. */ + { + if (e20ulbf.z - 1048576L < 0) { + printf ("Got negative e20ulbf.z - 1048576 = %ld, expected positive.\n", (long)(e20ulbf.z - 1048576L)); + failures++; + } + } +} + +/* Enum with underlying type signed long. */ +enum e20sl { + E20SL_M1 = -1, + E20SL_1000 = 1000, + E20SL_1000000000 = 1000000000L, +}; + +static struct enum_bitfield_long { + enum e20sl x : 2; + enum e20sl y : 16; + enum e20sl z : CHAR_BIT * sizeof (enum e20sl); +} e20slbf = {E20SL_M1, E20SL_1000, E20SL_1000000000}; + +static void test_enum_bitfield_long(void) +{ + if (sizeof (struct enum_bitfield_long) != 7) { + printf ("Got sizeof(struct enum_bitfield_long) = %zu, expected 8.\n", + sizeof(struct enum_bitfield_long)); + failures++; + } + + if (e20slbf.x != -1) { + printf ("Got e20slbf.x = %ld, expected -1.\n", (long)e20slbf.x); + failures++; + } + if (e20slbf.y != 1000) { + printf ("Got e20slbf.y = %ld, expected 1000.\n", (long)e20slbf.y); + failures++; + } + if (e20slbf.z != 1000000000L) { + printf ("Got e20slbf.z = %ld, expected 1000000000.\n", (long)e20slbf.z); + failures++; + } + + e20slbf.x = 1; + e20slbf.y = 257; + e20slbf.z = 1048575L; + + if (e20slbf.x != 1) { + printf ("Got e20slbf.x = %d, expected 1.\n", e20slbf.x); + failures++; + } + + /* Check signedness, should be signed. */ + { + if (e20slbf.x - 2 >= 0) { + printf ("Got non-negative e20slbf.x - 2 = %lu, expected negative.\n", (unsigned long)(e20slbf.x - 2)); + failures++; + } + } + + if (e20slbf.y != 257) { + printf ("Got e20slbf.y = %ld, expected 257.\n", (long)e20slbf.y); + failures++; + } + + /* Check signedness, should be signed. */ + { + if (e20slbf.y - 258 >= 0) { + printf ("Got non-negative e20slbf.y - 258 = %lu, expected negative.\n", (unsigned long)(e20slbf.y - 258)); + failures++; + } + } + + if (e20slbf.z != 1048575L) { + printf ("Got e20slbf.z = %ld, expected 1048575.\n", (long)e20slbf.z); + failures++; + } + + /* Check signedness, should be signed. */ + { + if (e20slbf.z - 1048576L >= 0) { + printf ("Got non-negative e20slbf.z - 1048576L = %ld, expected negative.\n", (long)(e20slbf.z - 1048576L)); + failures++; + } + } +} + int main(void) { test_enum_bitfield_uint(); test_enum_bitfield_int(); test_enum_bitfield_uchar(); test_enum_bitfield_char(); + test_enum_bitfield_ulong(); + test_enum_bitfield_long(); printf("failures: %u\n", failures); return failures; } diff --git a/test/val/bitfield-packing-char.c b/test/val/bitfield-packing-char.c new file mode 100644 index 000000000..18621e0eb --- /dev/null +++ b/test/val/bitfield-packing-char.c @@ -0,0 +1,278 @@ +/* + Copyright 2020-2022 The cc65 Authors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Tests of char bit-field packing and typedef works with them; see issues below + - packing issue: https://github.com/cc65/cc65/issues/1054 + - typedef issue: https://github.com/cc65/cc65/pull/1662 + - char bit-field support: https://github.com/cc65/cc65/issues/1047 +*/ + +#include <stdio.h> + +static unsigned char failures = 0; + +typedef unsigned char field_type; + +static struct four_bits { + field_type x : 4; +} fb = {1}; + +static void test_four_bits(void) +{ + if (sizeof(struct four_bits) != 1) { + printf("Got sizeof(struct four_bits) = %zu, expected 1.\n", + sizeof(struct four_bits)); + failures++; + } + + if (fb.x != 1) { + printf("Got fb.x = %u, expected 1.\n", fb.x); + failures++; + } + + fb.x = 3; + + if (fb.x != 3) { + printf("Got fb.x = %u, expected 3.\n", fb.x); + failures++; + } +} + +/* + Logic is somewhat diferent for bit-fields that end a struct vs + having additional fields. +*/ + +static struct four_bits_with_char { + field_type x : 4; + field_type y; +} fbi = {1, 2}; + +static void test_four_bits_with_char(void) +{ + /* The first 4-bit bit-field just takes one byte, so the size is 2. */ + if (sizeof(struct four_bits_with_char) != 2) { + printf("Got sizeof(struct four_bits_with_char) = %zu, expected 2.\n", + sizeof(struct four_bits_with_char)); + failures++; + } + + if (fbi.x != 1) { + printf("Got fbi.x = %u, expected 1.\n", fbi.x); + failures++; + } + + if (fbi.y != 2) { + printf("Got fbi.y = %u, expected 2.\n", fbi.y); + failures++; + } + + fbi.x = 3; + fbi.y = 17; + + if (fbi.x != 3) { + printf("Got fbi.x = %u, expected 3.\n", fbi.x); + failures++; + } + + if (fbi.y != 17) { + printf("Got fbi.y = %u, expected 17.\n", fbi.y); + failures++; + } +} + +static struct overlap { + field_type x : 6; + field_type y : 6; +} o = {11, 22}; + +/* Tests that bit-fields can share allocation units. */ +static void test_overlap(void) +{ + if (sizeof(struct overlap) != 2) { + printf("Got sizeof(struct overlap) = %zu, expected 2.\n", + sizeof(struct overlap)); + failures++; + } + + if (o.x != 11) { + printf("Got o.x = %u, expected 11.\n", o.x); + failures++; + } + + if (o.y != 22) { + printf("Got o.y = %u, expected 22.\n", o.y); + failures++; + } + + o.x = 33; + o.y = 44; + + if (o.x != 33) { + printf("Got o.x = %u, expected 33.\n", o.x); + failures++; + } + + if (o.y != 44) { + printf("Got o.y = %u, expected 44.\n", o.y); + failures++; + } +} + +static struct overlap_with_char { + field_type x : 6; + field_type y : 6; + field_type z; +} oi = {11, 22, 33}; + +static void test_overlap_with_char(void) +{ + /* First two fields in 2 bytes, then another 1 byte. */ + if (sizeof(struct overlap_with_char) != 3) { + printf("Got sizeof(struct overlap_with_char) = %zu, expected 3.\n", + sizeof(struct overlap_with_char)); + failures++; + } + + if (oi.x != 11) { + printf("Got oi.x = %u, expected 11.\n", oi.x); + failures++; + } + + if (oi.y != 22) { + printf("Got oi.y = %u, expected 22.\n", oi.y); + failures++; + } + + if (oi.z != 33) { + printf("Got oi.z = %u, expected 33.\n", oi.z); + failures++; + } + + oi.x = 44; + oi.y = 55; + oi.z = 66; + + if (oi.x != 44) { + printf("Got oi.x = %u, expected 44.\n", oi.x); + failures++; + } + + if (oi.y != 55) { + printf("Got oi.y = %u, expected 55.\n", oi.y); + failures++; + } + + if (oi.z != 66) { + printf("Got oi.z = %u, expected 66.\n", oi.z); + failures++; + } +} + +static struct full_width { + field_type x : 8; + field_type y : 8; +} fw = {255, 17}; + +static void test_full_width(void) +{ + if (sizeof(struct full_width) != 2) { + printf("Got sizeof(struct full_width) = %zu, expected 2.\n", + sizeof(struct full_width)); + failures++; + } + + if (fw.x != 255) { + printf("Got fw.x = %u, expected 255.\n", fw.x); + failures++; + } + + if (fw.y != 17) { + printf("Got fw.y = %u, expected 17.\n", fw.y); + failures++; + } + + fw.x = 42; + fw.y = 255; + + if (fw.x != 42) { + printf("Got fw.x = %u, expected 42.\n", fw.x); + failures++; + } + + if (fw.y != 255) { + printf("Got fw.y = %u, expected 255.\n", fw.y); + failures++; + } +} + +static struct aligned_end { + field_type : 2; + field_type x : 6; + /* y crosses a byte boundary, but fits in a byte when shifted. */ + field_type : 6; + field_type y : 7; +} ae = {63, 17}; + +static void test_aligned_end(void) +{ + if (sizeof(struct aligned_end) != 3) { + printf("Got sizeof(struct aligned_end) = %zu, expected 3.\n", + sizeof(struct aligned_end)); + failures++; + } + + if (ae.x != 63) { + printf("Got ae.x = %u, expected 63.\n", ae.x); + failures++; + } + + if (ae.y != 17) { + printf("Got ae.y = %u, expected 17.\n", ae.y); + failures++; + } + + ae.x = 42; + ae.y = 127; + + if (ae.x != 42) { + printf("Got ae.x = %u, expected 42.\n", ae.x); + failures++; + } + + if (ae.y != 127) { + printf("Got ae.y = %u, expected 127.\n", ae.y); + failures++; + } + +} + +int main(void) +{ + test_four_bits(); + test_four_bits_with_char(); + test_overlap(); + test_overlap_with_char(); + test_full_width(); + test_aligned_end(); + printf("failures: %u\n", failures); + return failures; +} diff --git a/test/val/bitfield-packing-long.c b/test/val/bitfield-packing-long.c new file mode 100644 index 000000000..fcc8eb7fe --- /dev/null +++ b/test/val/bitfield-packing-long.c @@ -0,0 +1,315 @@ +/* + Copyright 2020-2022 The cc65 Authors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Tests of long bit-field packing and typedef works with them; see issues below + - packing: https://github.com/cc65/cc65/issues/1054 + - typedef: https://github.com/cc65/cc65/pull/1662 + - long bit-field support: https://github.com/cc65/cc65/issues/1131 +*/ + +#include <stdio.h> + +static unsigned char failures = 0; + +typedef unsigned long field_type; + +static struct four_bits { + field_type x : 4; +} fb = {1}; + +static void test_four_bits(void) +{ + if (sizeof(struct four_bits) != 1) { + printf("Got sizeof(struct four_bits) = %zu, expected 1.\n", + sizeof(struct four_bits)); + failures++; + } + + if (fb.x != 1) { + printf("Got fb.x = %u, expected 1.\n", fb.x); + failures++; + } + + fb.x = 3; + + if (fb.x != 3) { + printf("Got fb.x = %u, expected 3.\n", fb.x); + failures++; + } +} + +/* + Logic is somewhat diferent for bit-fields that end a struct vs + having additional fields. +*/ + +static struct four_bits_with_long { + field_type x : 4; + field_type y; +} fbi = {1, 2}; + +static void test_four_bits_with_long(void) +{ + /* The first 4-bit bit-field just takes one byte, so the size is 5. */ + if (sizeof(struct four_bits_with_long) != 5) { + printf("Got sizeof(struct four_bits_with_long) = %zu, expected 5.\n", + sizeof(struct four_bits_with_long)); + failures++; + } + + if (fbi.x != 1) { + printf("Got fbi.x = %u, expected 1.\n", fbi.x); + failures++; + } + + if (fbi.y != 2) { + printf("Got fbi.y = %lu, expected 2.\n", fbi.y); + failures++; + } + + fbi.x = 3; + fbi.y = 65537; + + if (fbi.x != 3) { + printf("Got fbi.x = %u, expected 3.\n", fbi.x); + failures++; + } + + if (fbi.y != 65537) { + printf("Got fbi.y = %lu, expected 65537.\n", fbi.y); + failures++; + } +} + +static struct overlap { + field_type x : 10; + field_type y : 10; +} o = {11, 22}; + +/* Tests that bit-fields can share allocation units. */ +static void test_overlap(void) +{ + if (sizeof(struct overlap) != 3) { + printf("Got sizeof(struct overlap) = %zu, expected 3.\n", + sizeof(struct overlap)); + failures++; + } + + if (o.x != 11) { + printf("Got o.x = %u, expected 11.\n", o.x); + failures++; + } + + if (o.y != 22) { + printf("Got o.y = %u, expected 22.\n", o.y); + failures++; + } + + o.x = 33; + o.y = 44; + + if (o.x != 33) { + printf("Got o.x = %u, expected 33.\n", o.x); + failures++; + } + + if (o.y != 44) { + printf("Got o.y = %u, expected 44.\n", o.y); + failures++; + } +} + +static struct overlap_with_long { + field_type x : 10; + field_type y : 10; + field_type z; +} oi = {111, 222, 333}; + +static void test_overlap_with_long(void) +{ + /* First two fields in 3 bytes, then another 4 bytes. */ + if (sizeof(struct overlap_with_long) != 7) { + printf("Got sizeof(struct overlap_with_long) = %zu, expected 7.\n", + sizeof(struct overlap_with_long)); + failures++; + } + + if (oi.x != 111) { + printf("Got oi.x = %u, expected 111.\n", oi.x); + failures++; + } + + if (oi.y != 222) { + printf("Got oi.y = %u, expected 222.\n", oi.y); + failures++; + } + + if (oi.z != 333) { + printf("Got oi.z = %u, expected 333.\n", oi.z); + failures++; + } + + oi.x = 444; + oi.y = 555; + oi.z = 4294967295; + + if (oi.x != 444) { + printf("Got oi.x = %u, expected 444.\n", oi.x); + failures++; + } + + if (oi.y != 555) { + printf("Got oi.y = %u, expected 555.\n", oi.y); + failures++; + } + + if (oi.z != 4294967295) { + printf("Got oi.z = %lu, expected 4294967295.\n", oi.z); + failures++; + } +} + +static struct full_width { + field_type x : 8; + field_type y : 16; + field_type z : 32; +} fw = {255, 17, 1}; + +static void test_full_width(void) +{ + if (sizeof(struct full_width) != 7) { + printf("Got sizeof(struct full_width) = %zu, expected 7.\n", + sizeof(struct full_width)); + failures++; + } + + if (fw.x != 255) { + printf("Got fw.x = %u, expected 255.\n", fw.x); + failures++; + } + + if (fw.y != 17) { + printf("Got fw.y = %u, expected 17.\n", fw.y); + failures++; + } + + if (fw.z != 1) { + printf("Got fw.z = %lu, expected 1.\n", fw.z); + failures++; + } + + fw.x = 42; + fw.y = 1023; + fw.z = 65537; + + if (fw.x != 42) { + printf("Got fw.x = %u, expected 42.\n", fw.x); + failures++; + } + + if (fw.y != 1023) { + printf("Got fw.y = %u, expected 1023.\n", fw.y); + failures++; + } + + if (fw.z != 65537) { + printf("Got fw.z = %lu, expected 65537.\n", fw.z); + failures++; + } +} + +static struct aligned_end { + field_type : 2; + field_type x : 6; + field_type : 3; + field_type y : 13; + field_type : 14; + field_type z : 18; + /* w crosses a byte boundary, but fits in a byte when shifted. */ + field_type : 6; + field_type w : 7; +} ae = {63, 17, 1, 100}; + +static void test_aligned_end(void) +{ + if (sizeof(struct aligned_end) != 9) { + printf("Got sizeof(struct aligned_end) = %zu, expected 9.\n", + sizeof(struct aligned_end)); + failures++; + } + + if (ae.x != 63) { + printf("Got ae.x = %u, expected 63.\n", ae.x); + failures++; + } + + if (ae.y != 17) { + printf("Got ae.y = %u, expected 17.\n", ae.y); + failures++; + } + + if (ae.z != 1) { + printf("Got ae.z = %lu, expected 1.\n", ae.z); + failures++; + } + + if (ae.w != 100) { + printf("Got ae.w = %u, expected 100.\n", ae.w); + failures++; + } + + ae.x = 42; + ae.y = 1023; + ae.z = 262143; + ae.w = 66; + + if (ae.x != 42) { + printf("Got ae.x = %u, expected 42.\n", ae.x); + failures++; + } + + if (ae.y != 1023) { + printf("Got ae.y = %u, expected 1023.\n", ae.y); + failures++; + } + + if (ae.z != 262143) { + printf("Got ae.z = %lu, expected 262143.\n", ae.z); + failures++; + } + + if (ae.w != 66) { + printf("Got ae.w = %u, expected 66.\n", ae.w); + failures++; + } +} + +int main(void) +{ + test_four_bits(); + test_four_bits_with_long(); + test_overlap(); + test_overlap_with_long(); + test_full_width(); + test_aligned_end(); + printf("failures: %u\n", failures); + return failures; +} diff --git a/test/val/bitfield.c b/test/val/bitfield-packing.c similarity index 93% rename from test/val/bitfield.c rename to test/val/bitfield-packing.c index 1de19777a..5786d6906 100644 --- a/test/val/bitfield.c +++ b/test/val/bitfield-packing.c @@ -1,5 +1,5 @@ /* - Copyright 2020 The cc65 Authors + Copyright 2020-2022 The cc65 Authors This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,7 +19,9 @@ */ /* - Tests of bit-field packing; see https://github.com/cc65/cc65/issues/1054 + Tests of int bit-field packing and typedef works with them; see issues below + - packing issue: https://github.com/cc65/cc65/issues/1054 + - typedef issue: https://github.com/cc65/cc65/pull/1662 */ #include <stdio.h> @@ -83,15 +85,15 @@ static void test_four_bits_with_int(void) } fbi.x = 3; - fbi.y = 17; + fbi.y = 257; if (fbi.x != 3) { printf("Got fbi.x = %u, expected 3.\n", fbi.x); failures++; } - if (fbi.y != 17) { - printf("Got fbi.y = %u, expected 17.\n", fbi.y); + if (fbi.y != 257) { + printf("Got fbi.y = %u, expected 257.\n", fbi.y); failures++; } } @@ -166,7 +168,7 @@ static void test_overlap_with_int(void) oi.x = 444; oi.y = 555; - oi.z = 666; + oi.z = 65535; if (oi.x != 444) { printf("Got oi.x = %u, expected 444.\n", oi.x); @@ -178,8 +180,8 @@ static void test_overlap_with_int(void) failures++; } - if (oi.z != 666) { - printf("Got oi.z = %u, expected 666.\n", oi.z); + if (oi.z != 65535) { + printf("Got oi.z = %u, expected 65535.\n", oi.z); failures++; } } diff --git a/test/val/bitfield-plain.c b/test/val/bitfield-plain.c new file mode 100644 index 000000000..735f3dc87 --- /dev/null +++ b/test/val/bitfield-plain.c @@ -0,0 +1,180 @@ +/* + Copyright 2020-2022 The cc65 Authors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Tests that plain bit-fields are unsigned; see issues below + - unsigned integer types by default: https://github.com/cc65/cc65/issues/1095 + - char bit-field support: https://github.com/cc65/cc65/issues/1047 + - long bit-field support: https://github.com/cc65/cc65/issues/1131 +*/ + +#include <stdio.h> + +static unsigned char failures = 0; + +static struct plain_ints { + int x : 4; + int y : 10; +} pi = {15, 700}; + +static void test_plain_int_bitfields (void) +{ + if (pi.x != 15) { + printf ("Got pi.x = %ld, expected 15.\n", (long)pi.x); + failures++; + } + if (pi.y != 700) { + printf ("Got pi.y = %ld, expected 700.\n", (long)pi.y); + failures++; + } + + pi.x = 3; + pi.y = 1023; + + if (pi.x != 3) { + printf ("Got pi.x = %ld, expected 3.\n", (long)pi.x); + failures++; + } + if (pi.y != 1023) { + printf ("Got pi.y = %ld, expected 1023.\n", (long)pi.y); + failures++; + } +} + +static struct plain_shorts { + short x : 4; + short y : 10; +} ps = {15, 700}; + +static void test_plain_short_bitfields (void) +{ + if (ps.x != 15) { + printf ("Got ps.x = %ld, expected 15.\n", (long)ps.x); + failures++; + } + if (ps.y != 700) { + printf ("Got ps.y = %ld, expected 700.\n", (long)ps.y); + failures++; + } + + ps.x = 3; + ps.y = 1023; + + if (ps.x != 3) { + printf ("Got ps.x = %ld, expected 3.\n", (long)ps.x); + failures++; + } + if (ps.y != 1023) { + printf ("Got ps.y = %ld, expected 1023.\n", (long)ps.y); + failures++; + } +} + +static struct plain_chars { + char x : 4; +} pc = {15}; + +static void test_plain_char_bitfields (void) +{ + if (pc.x != 15) { + printf ("Got pc.x = %ld, expected 15.\n", (long)pc.x); + failures++; + } + + pc.x = 3; + + if (pc.x != 3) { + printf ("Got pc.x = %ld, expected 3.\n", (long)pc.x); + failures++; + } +} + +static struct plain_longs { + long x : 4; + long y : 10; + long z : 18; +} pl = {15, 700, 200000}; + +static void test_plain_long_bitfields (void) +{ + if (pl.x != 15) { + if (pl.x < 0) { + printf ("Got pl.x = %ld, expected 15.\n", (long)pl.x); + } else { + printf ("Got pl.x = %lu, expected 15.\n", (unsigned long)pl.x); + } + failures++; + } + if (pl.y != 700) { + if (pl.y < 0) { + printf ("Got pl.y = %ld, expected 700.\n", (long)pl.y); + } else { + printf ("Got pl.y = %lu, expected 700.\n", (unsigned long)pl.y); + } + failures++; + } + if (pl.z != 200000) { + if (pl.z < 0) { + printf ("Got pl.z = %ld, expected 200000.\n", (long)pl.z); + } else { + printf ("Got pl.z = %lu, expected 200000.\n", (unsigned long)pl.z); + } + failures++; + } + + pl.x = 3; + pl.y = 1023; + pl.z = 262143; + + if (pl.x != 3) { + if (pl.x < 0) { + printf ("Got pl.x = %ld, expected 3.\n", (long)pl.x); + } else { + printf ("Got pl.x = %lu, expected 3.\n", (unsigned long)pl.x); + } + failures++; + } + if (pl.y != 1023) { + if (pl.y < 0) { + printf ("Got pl.y = %ld, expected 1023.\n", (long)pl.y); + } else { + printf ("Got pl.y = %lu, expected 1023.\n", (unsigned long)pl.y); + } + failures++; + } + if (pl.z != 262143) { + if (pl.z < 0) { + printf ("Got pl.z = %ld, expected 262143.\n", (long)pl.z); + } else { + printf ("Got pl.z = %lu, expected 262143.\n", (unsigned long)pl.z); + } + failures++; + } +} + +int main (void) +{ + test_plain_int_bitfields (); + test_plain_short_bitfields (); + test_plain_char_bitfields (); + test_plain_long_bitfields (); + printf ("failures: %u\n", failures); + return failures; +} diff --git a/test/val/bitfield-signed.c b/test/val/bitfield-signed.c new file mode 100644 index 000000000..68f36f92a --- /dev/null +++ b/test/val/bitfield-signed.c @@ -0,0 +1,180 @@ +/* + Copyright 2020-2022 The cc65 Authors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be signedly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Tests that signed bit-fields are indeed signed; see issues below + - unsigned integer types by default: https://github.com/cc65/cc65/issues/1095 + - char bit-field support: https://github.com/cc65/cc65/issues/1047 + - long bit-field support: https://github.com/cc65/cc65/issues/1131 +*/ + +#include <stdio.h> + +static unsigned char failures = 0; + +static struct signed_ints { + signed int x : 4; + signed int y : 10; +} pi = {-8, -500}; + +static void test_signed_int_bitfields (void) +{ + if (pi.x != -8) { + printf ("Got pi.x = %ld, expected -8.\n", (long)pi.x); + failures++; + } + if (pi.y != -500) { + printf ("Got pi.y = %ld, expected -500.\n", (long)pi.y); + failures++; + } + + pi.x = -3; + pi.y = -512; + + if (pi.x != -3) { + printf ("Got pi.x = %ld, expected -3.\n", (long)pi.x); + failures++; + } + if (pi.y != -512) { + printf ("Got pi.y = %ld, expected -512.\n", (long)pi.y); + failures++; + } +} + +static struct signed_shorts { + signed short x : 4; + signed short y : 10; +} ps = {-8, -500}; + +static void test_signed_short_bitfields (void) +{ + if (ps.x != -8) { + printf ("Got ps.x = %ld, expected -8.\n", (long)ps.x); + failures++; + } + if (ps.y != -500) { + printf ("Got ps.y = %ld, expected -500.\n", (long)ps.y); + failures++; + } + + ps.x = -3; + ps.y = -512; + + if (ps.x != -3) { + printf ("Got ps.x = %ld, expected -3.\n", (long)ps.x); + failures++; + } + if (ps.y != -512) { + printf ("Got ps.y = %ld, expected -512.\n", (long)ps.y); + failures++; + } +} + +static struct signed_chars { + signed char x : 4; +} pc = {-8}; + +static void test_signed_char_bitfields (void) +{ + if (pc.x != -8) { + printf ("Got pc.x = %ld, expected -8.\n", (long)pc.x); + failures++; + } + + pc.x = -3; + + if (pc.x != -3) { + printf ("Got pc.x = %ld, expected -3.\n", (long)pc.x); + failures++; + } +} + +static struct signed_longs { + signed long x : 4; + signed long y : 10; + signed long z : 18; +} pl = {-8, -500, -70000}; + +static void test_signed_long_bitfields (void) +{ + if (pl.x != -8) { + if (pl.x < 0) { + printf ("Got pl.x = %ld, expected -8.\n", (long)pl.x); + } else { + printf ("Got pl.x = %lu, expected -8.\n", (unsigned long)pl.x); + } + failures++; + } + if (pl.y != -500) { + if (pl.y < 0) { + printf ("Got pl.y = %ld, expected -500.\n", (long)pl.y); + } else { + printf ("Got pl.y = %lu, expected -500.\n", (unsigned long)pl.y); + } + failures++; + } + if (pl.z != -70000) { + if (pl.z < 0) { + printf ("Got pl.z = %ld, expected -70000.\n", (long)pl.z); + } else { + printf ("Got pl.z = %lu, expected -70000.\n", (unsigned long)pl.z); + } + failures++; + } + + pl.x = -3; + pl.y = -512; + pl.z = -131072; + + if (pl.x != -3) { + if (pl.x < 0) { + printf ("Got pl.x = %ld, expected -3.\n", (long)pl.x); + } else { + printf ("Got pl.x = %lu, expected -3.\n", (unsigned long)pl.x); + } + failures++; + } + if (pl.y != -512) { + if (pl.y < 0) { + printf ("Got pl.y = %ld, expected -512.\n", (long)pl.y); + } else { + printf ("Got pl.y = %lu, expected -512.\n", (unsigned long)pl.y); + } + failures++; + } + if (pl.z != -131072) { + if (pl.z < 0) { + printf ("Got pl.z = %ld, expected -131072.\n", (long)pl.z); + } else { + printf ("Got pl.z = %lu, expected -131072.\n", (unsigned long)pl.z); + } + failures++; + } +} + +int main (void) +{ + test_signed_int_bitfields (); + test_signed_short_bitfields (); + test_signed_char_bitfields (); + test_signed_long_bitfields (); + printf ("failures: %u\n", failures); + return failures; +} diff --git a/test/val/bug1075.c b/test/val/bug1075.c index 6ff5ec8e7..3e259fd22 100644 --- a/test/val/bug1075.c +++ b/test/val/bug1075.c @@ -8,7 +8,7 @@ long rhs; int test(void) { - /* the whole lhs is errorneously treated as an absolute address (integer + /* the whole lhs is errorneously treated as an absolute address (integer constant) neglecting its dereference */ return *(char *)0xD77C + rhs; } diff --git a/test/val/bug1178.c b/test/val/bug1178.c index 043767e4c..7fb7e7803 100644 --- a/test/val/bug1178.c +++ b/test/val/bug1178.c @@ -41,7 +41,7 @@ void dotest1(void) StructArray1[0] = test1; - printf ("test1: %d, %d, %d, %d, %d\n", + printf ("test1: %d, %d, %d, %d, %d\n", (int)StructArray1[0].a, (int)StructArray1[0].b, (int)StructArray1[0].c, (int)StructArray1[0].d, (int)StructArray1[0].e); if ((StructArray1[0].a != 42) || @@ -62,7 +62,7 @@ void dotest2(void) StructArray2[0] = test2; - printf ("test2: %d, %d, %d, %d, %d\n", + printf ("test2: %d, %d, %d, %d, %d\n", (int)StructArray2[0].a, (int)StructArray2[0].b, (int)StructArray2[0].c, (int)StructArray2[0].d); if ((StructArray2[0].a != 42) || diff --git a/test/val/bug1181.c b/test/val/bug1181.c index 4ea2d54bf..077707d94 100644 --- a/test/val/bug1181.c +++ b/test/val/bug1181.c @@ -1,5 +1,5 @@ -/* bug #1181 - Testing struct member against NULL is broken */ +/* bug #1181 - Testing struct member against NULL is broken */ #include <stdio.h> #include <stdlib.h> @@ -52,7 +52,7 @@ MENUITEM optionsitems_menu[] = { static MENU optionsmenu_menu = { &optionsitems_menu[0], -}; +}; unsigned char __fastcall__ menu_getnumitems(MENU *menu) { diff --git a/test/val/bug1438.c b/test/val/bug1438.c index 3894f87f1..9c8f7a8ce 100644 --- a/test/val/bug1438.c +++ b/test/val/bug1438.c @@ -1,5 +1,5 @@ -/* Issue #1438 fix #1439 - crash in cc65, related to delayed post-counting +/* Issue #1438 fix #1439 - crash in cc65, related to delayed post-counting this is an odd issue, the compile would crash *sometimes*, perhaps in one of ten compilation runs. diff --git a/test/val/bug1552.c b/test/val/bug1552.c index 42f39eec6..92ad902bd 100644 --- a/test/val/bug1552.c +++ b/test/val/bug1552.c @@ -23,7 +23,7 @@ int execute(TREPTR argt, int execflg, int *pf1, int *pf2) { register TREPTR t; int type; - switch (type) + switch (type) { case 6: { diff --git a/test/val/bug1675-ub.c b/test/val/bug1675-ub.c new file mode 100644 index 000000000..72e372308 --- /dev/null +++ b/test/val/bug1675-ub.c @@ -0,0 +1,60 @@ +/* #1675 - Some UB cases of bit-shifts */ + +#include <stdio.h> + +int unexpected = 0; + +void Test_UB(void) +{ + { + /* UB per standard, lhs expected in cc65: (int)-32768 */ + if (!((0x4000 << 1) < 0)) { + ++unexpected; + printf("Expected: (0x4000 << 1) < 0, got lhs: %ld\n", (long)(0x4000 << 1)); + } + } + + { + /* UB per standard, lhs expected in cc65: (long)-2147483648L */ + if (!((0x40000000 << 1) < 0)) { + ++unexpected; + printf("Expected: (0x40000000 << 1) < 0, got lhs: %ld\n", (long)(0x40000000 << 1)); + } + } + + { + /* UB per standard, lhs expected in cc65: (int)-32768 */ + if (!(((unsigned char)0x80 << 8) < 0)) { + ++unexpected; + printf("Expected: ((unsigned char)0x80 << 8) < 0, got lhs: %ld\n", (long)((unsigned char)0x80 << 8)); + } + } + + { + /* UB per standard, lhs expected in cc65: (int)-32768 */ + if (!(((short)0x4000L << 1) < 0)) { + ++unexpected; + printf("Expected: ((short)0x4000L << 1) < 0, got lhs: %ld\n", (long)((short)0x4000L << 1)); + } + } + + { + const signed short x = 0x4000; + /* UB per standard, lhs expected in cc65: (int)-32768 */ + if (!((x << 1) < 0)) { + ++unexpected; + printf("Expected: (x << 1) < 0, got lhs: %ld\n", (long)(x << 1)); + } + } +} + +int main(void) +{ + Test_UB(); + + if (unexpected != 0) { + printf("Unexpected: %d\n", unexpected); + } + + return unexpected; +} diff --git a/test/val/bug1675.c b/test/val/bug1675.c new file mode 100644 index 000000000..ee24425df --- /dev/null +++ b/test/val/bug1675.c @@ -0,0 +1,101 @@ +/* #1675 - Some corner cases of bit-shifts */ + +#include <stdio.h> + +int failures = 0; + +void Test_Defined(void) +{ + { + /* Well-defined per standard, lhs expected in cc65: (int)-256 */ + if (!(((signed char)0x80 << 1) < 0)) { + ++failures; + printf("Expected: ((signed char)0x80 << 1) < 0, got lhs: %ld\n", (long)((signed char)0x80 << 1)); + } + } + + { + /* Implementation-defined per standard, lhs expected in cc65: (int)-128 */ + if (!(((signed char)0x80 >> 1 << 1) < 0)) { + ++failures; + printf("Expected: ((signed char)0x80 >> 1 << 1) < 0, got lhs: %ld\n", (long)((signed char)0x80 >> 1 << 1)); + } + } + + { + int x = 0; + /* Well-defined per standard, lhs expected in cc65: (int)1 */ + if (!((1 << (x++, 0)) == 1)) { + ++failures; + x = 0; + printf("Expected: (1 << (x++, 0)) == 1, got lhs: %ld\n", (long)(1 << (x++, 0))); + } + + /* Well-defined per standard, lhs expected in cc65: (int)1 */ + if (!(x == 1)) { + ++failures; + printf("Expected: (1 << (x++, 0)) == 1 && x == 1, got x: %d\n", x); + } + } + + { + int x = 0, y = 0x100; + /* Well-defined per standard, lhs expected in cc65: (int)128 */ + if (!((y >> (x++, 0) >> 1) == 0x80)) { + ++failures; + x = 0; + printf("Expected: (y >> (x++, 0) >> 1) == 0x80, got lhs: %ld\n", (long)(y >> (x++, 0) >> 1)); + } + + /* Well-defined per standard, lhs expected in cc65: (int)1 */ + if (!(x == 1)) { + ++failures; + printf("Expected: (y >> (x++, 0) >> 1) == 0x80 && x == 1, got x: %d\n", x); + } + } + + { + int x = 0, y = 0x100; + /* Well-defined per standard, lhs expected in cc65: (int)1 */ + if (!((y >> (x++, 8)) == 1)) { + ++failures; + x = 0; + printf("Expected: (y >> (x++, 8)) == 1, got lhs: %ld\n", (long)(y >> (x++, 8))); + } + + /* Well-defined per standard, lhs expected in cc65: (int)1 */ + if (!(x == 1)) { + ++failures; + printf("Expected: (y >> (x++, 8)) == 1 && x == 1, got x: %d\n", x); + } + } + + { + const signed char x = 0x80; + /* Well-defined per standard, lhs expected in cc65: (int)-256 */ + if (!((x << 1) < 0)) { + ++failures; + printf("Expected: (x << 1) < 0, got lhs: %ld\n", (long)(x << 1)); + } + } + + { + const signed char x = 0x40; + /* Well-defined per standard, lhs expected in cc65: (int)128 */ + if (!((x << 1) >= 0)) { + ++failures; + printf("Expected: (x << 1) >= 0, got lhs: %ld\n", (long)(x << 1)); + } + } +} + +int main(void) +{ + Test_Defined(); + + if (failures != 0) { + printf("Failures: %d\n", failures); + } + + return failures; +} diff --git a/test/val/bug1690.c b/test/val/bug1690.c new file mode 100644 index 000000000..499dc6b35 --- /dev/null +++ b/test/val/bug1690.c @@ -0,0 +1,30 @@ +/* OptCmp1 messed up with labels */ + +#include <stdio.h> + +static int failures = 0; +static unsigned int z = 0xFF23; + +int main(void) +{ + register unsigned int x = 0x200; + register unsigned int y = 0; + + do { + ++y; + } while (--x); + if (y != 0x200) { + printf("y should be 0x200, not 0x%X.\n", y); + ++failures;; + } + + if ((z -= 0x23)) { + /* Passed -- non-zero z looks like non-zero. */ + } else { + /* Failed -- only the low byte of z was tested. */ + printf("Test thinks non-zero z is zero.\n"); + ++failures; + } + + return failures; +} diff --git a/test/val/plain-int-bitfield.c b/test/val/bug1696.c similarity index 56% rename from test/val/plain-int-bitfield.c rename to test/val/bug1696.c index 4d158eca9..72cf9cc7e 100644 --- a/test/val/plain-int-bitfield.c +++ b/test/val/bug1696.c @@ -1,5 +1,5 @@ /* - Copyright 2020 The cc65 Authors + Copyright 2022 The cc65 Authors This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,45 +19,26 @@ */ /* - Tests that plain int bit-fields are unsigned. + Tests of unsigned short/unsigned int vs signed long comparisons; + see https://github.com/cc65/cc65/issues/1696 */ #include <stdio.h> static unsigned char failures = 0; -static struct plain_ints { - int x : 4; - int y : 10; -} pi = {15, 700}; - -static void test_plain_int_bitfields (void) +int main(void) { - if (pi.x != 15) { - printf ("Got pi.x = %u, expected 15.\n", pi.x); - failures++; + unsigned int x = 65535; + unsigned short y = 65535; + if (!(x > 1L)) { + printf("x = %ld but x > 1L failed\n", (long)x); + ++failures; } - if (pi.y != 700) { - printf ("Got pi.y = %u, expected 700.\n", pi.y); - failures++; + if (!(y == 65535L)) { + printf("y = %ld but y == 65535L failed\n", (long)y); + ++failures; } - - pi.x = 3; - pi.y = 1023; - - if (pi.x != 3) { - printf ("Got pi.x = %u, expected 3.\n", pi.x); - failures++; - } - if (pi.y != 1023) { - printf ("Got pi.y = %u, expected 1023.\n", pi.y); - failures++; - } -} - -int main (void) -{ - test_plain_int_bitfields (); - printf ("failures: %u\n", failures); + printf("failures: %u\n", failures); return failures; } diff --git a/test/val/call1.c b/test/val/call1.c index c7ac920b3..d09ae0dec 100644 --- a/test/val/call1.c +++ b/test/val/call1.c @@ -70,7 +70,7 @@ call5 (unsigned int k) return (k); } -unsigned char +unsigned char call6a(unsigned char uc) { if(uc>uchar1) @@ -85,7 +85,7 @@ call6(unsigned char uc) return(call6a(uc)); } -unsigned int +unsigned int call7a(unsigned int ui) { if(ui) diff --git a/test/val/cc65091020.c b/test/val/cc65091020.c index d23b70a06..8f6b11761 100644 --- a/test/val/cc65091020.c +++ b/test/val/cc65091020.c @@ -24,4 +24,4 @@ int main() { return 0; } -/* Assert fails. (SVN rev 4381) */ \ No newline at end of file +/* Assert fails. (SVN rev 4381) */ diff --git a/test/val/cc65150311.c b/test/val/cc65150311.c index cd644f491..10676d679 100644 --- a/test/val/cc65150311.c +++ b/test/val/cc65150311.c @@ -20,7 +20,7 @@ int main(void) { n = (p == &func); n = (p == func); -/* the following are not valid C and should go into seperate tests that MUST fail */ +/* the following are not valid C and should go into separate tests that MUST fail */ /* ++p; n = (p > &func); diff --git a/test/val/compare10.c b/test/val/compare10.c index 861a02d64..742213851 100644 --- a/test/val/compare10.c +++ b/test/val/compare10.c @@ -59,7 +59,7 @@ void c_char_gte_lit1(unsigned char expected_result) if(char0 >= 0x7e) result |= 0x10; - + if(char0 >= 0x7f) result |= 0x20; @@ -138,10 +138,10 @@ void c_int_gte_lit1(unsigned char expected_result) if(int0 >= 0x0101) result |= 0x10; - + if(int0 >= 0x01ff) result |= 0x20; - + if(int0 >= 0x0200) result |= 0x40; @@ -226,10 +226,10 @@ void c_int_gte_lit2(unsigned char expected_result) if(int0 >= -0x0101) result |= 0x10; - + if(int0 >= -0x0100) result |= 0x20; - + if(int0 >= -0xff) result |= 0x40; diff --git a/test/val/compare5.c b/test/val/compare5.c index f1d94d537..cf51fac89 100644 --- a/test/val/compare5.c +++ b/test/val/compare5.c @@ -284,7 +284,7 @@ void c_ifelse1(void) void c_minus1(void) { printf("long0:%ld long1:%ld\n",long0,long1); - + printf("(long0 != -1)\n"); if(long0 != -1) { @@ -432,7 +432,7 @@ main (void) success = failures; done (); - + printf("failures: %d\n",failures); return failures; diff --git a/test/val/compare6.c b/test/val/compare6.c index 85f16a1c4..bad411c0c 100644 --- a/test/val/compare6.c +++ b/test/val/compare6.c @@ -60,7 +60,7 @@ void c_char(void) if(char1 || !char0) failures++; - if((char0 >5 ) && (char0 < 10)) + if((char0 >5 ) && (char0 < 10)) failures++; char0 +=5; /* char0 = 6 now */ @@ -100,7 +100,7 @@ void c_int(void) if(int1 || !int0) failures++; - if((int0 >5 ) && (int0 < 10)) + if((int0 >5 ) && (int0 < 10)) failures++; int0 +=5; /* int0 = 6 now */ @@ -140,7 +140,7 @@ void c_long(void) if(long1 || !long0) failures++; - if((long0 >5 ) && (long0 < 10)) + if((long0 >5 ) && (long0 < 10)) failures++; long0 +=5; /* long0 = 6 now */ diff --git a/test/val/compare7.c b/test/val/compare7.c index 6c9636dec..d88952f62 100644 --- a/test/val/compare7.c +++ b/test/val/compare7.c @@ -129,10 +129,10 @@ void c_int_lt_lit1(unsigned char expected_result) if(int0 < 0x0101) result |= 0x10; - + if(int0 < 0x01ff) result |= 0x20; - + if(int0 < 0x0200) result |= 0x40; @@ -214,10 +214,10 @@ void c_int_lt_lit2(unsigned char expected_result) if(int0 < -0x0101) result |= 0x10; - + if(int0 < -0x0100) result |= 0x20; - + if(int0 < -0xff) result |= 0x40; diff --git a/test/val/compare8.c b/test/val/compare8.c index 0abff8c69..2621dad1d 100644 --- a/test/val/compare8.c +++ b/test/val/compare8.c @@ -59,10 +59,10 @@ void c_char_gt_lit1(unsigned char expected_result) if(char0 > 0x7e) result |= 0x10; - + if(char0 > 0x7f) result |= 0x20; - + if(result != expected_result) failures++; } @@ -132,10 +132,10 @@ void c_int_gt_lit1(unsigned char expected_result) if(int0 > 0x0101) result |= 0x10; - + if(int0 > 0x01ff) result |= 0x20; - + if(int0 > 0x0200) result |= 0x40; @@ -220,10 +220,10 @@ void c_int_gt_lit2(unsigned char expected_result) if(int0 > -0x0101) result |= 0x10; - + if(int0 > -0x0100) result |= 0x20; - + if(int0 > -0xff) result |= 0x40; diff --git a/test/val/compare9.c b/test/val/compare9.c index 4a3714199..a498c15cb 100644 --- a/test/val/compare9.c +++ b/test/val/compare9.c @@ -54,7 +54,7 @@ void c_char_lte_lit1(unsigned char expected_result) if(char0 <= 0x7f) result |= 0x10; - + if(result != expected_result) failures++; } @@ -124,10 +124,10 @@ void c_int_lte_lit1(unsigned char expected_result) if(int0 <= 0x0101) result |= 0x10; - + if(int0 <= 0x01ff) result |= 0x20; - + if(int0 <= 0x0200) result |= 0x40; @@ -209,10 +209,10 @@ void c_int_lte_lit2(unsigned char expected_result) if(int0 <= -0x0101) result |= 0x10; - + if(int0 <= -0x0100) result |= 0x20; - + if(int0 <= -0xff) result |= 0x40; diff --git a/test/val/constexpr.c b/test/val/constexpr.c index 4338717f4..c66946a19 100644 --- a/test/val/constexpr.c +++ b/test/val/constexpr.c @@ -8,7 +8,7 @@ if they are being compiled/evaluated correctly. related: pr #1424 - More compile-time constant expressions regarding object addresses -issue #1196 - Constant expressions in general +issue #1196 - Constant expressions in general */ diff --git a/test/val/cq22.c b/test/val/cq22.c index 015b7bf77..20048fa2c 100644 --- a/test/val/cq22.c +++ b/test/val/cq22.c @@ -125,7 +125,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq241.c b/test/val/cq241.c index 1f66a378c..611b5a376 100644 --- a/test/val/cq241.c +++ b/test/val/cq241.c @@ -267,7 +267,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq243.c b/test/val/cq243.c index aaec9a8ea..8aba7dfe8 100644 --- a/test/val/cq243.c +++ b/test/val/cq243.c @@ -245,7 +245,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq244.c b/test/val/cq244.c index 9f4704f36..896ddb75b 100644 --- a/test/val/cq244.c +++ b/test/val/cq244.c @@ -140,7 +140,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq25.c b/test/val/cq25.c index bfdade957..7cacebf0a 100644 --- a/test/val/cq25.c +++ b/test/val/cq25.c @@ -152,7 +152,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq26.c b/test/val/cq26.c index 239411f1c..1c88dfed6 100644 --- a/test/val/cq26.c +++ b/test/val/cq26.c @@ -197,7 +197,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq4.c b/test/val/cq4.c index a8b6b1d52..205f62c88 100644 --- a/test/val/cq4.c +++ b/test/val/cq4.c @@ -344,7 +344,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq61.c b/test/val/cq61.c index fc4d1d95f..c16b64066 100644 --- a/test/val/cq61.c +++ b/test/val/cq61.c @@ -167,7 +167,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq626.c b/test/val/cq626.c index a8b05c8f2..b7c592d58 100644 --- a/test/val/cq626.c +++ b/test/val/cq626.c @@ -318,7 +318,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq71.c b/test/val/cq71.c index f7167c728..725a40e88 100644 --- a/test/val/cq71.c +++ b/test/val/cq71.c @@ -221,7 +221,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq714.c b/test/val/cq714.c index d7a878033..c36c992aa 100644 --- a/test/val/cq714.c +++ b/test/val/cq714.c @@ -1776,7 +1776,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq714b.c b/test/val/cq714b.c index 9538281b8..19b58628c 100644 --- a/test/val/cq714b.c +++ b/test/val/cq714b.c @@ -997,7 +997,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq715.c b/test/val/cq715.c index 0fe864159..2e7e22d85 100644 --- a/test/val/cq715.c +++ b/test/val/cq715.c @@ -132,7 +132,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq72.c b/test/val/cq72.c index 421177a0b..6b8026576 100644 --- a/test/val/cq72.c +++ b/test/val/cq72.c @@ -326,7 +326,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq7813.c b/test/val/cq7813.c index 9d4308a3e..d6c9b445f 100644 --- a/test/val/cq7813.c +++ b/test/val/cq7813.c @@ -362,7 +362,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq81.c b/test/val/cq81.c index 85e1ac1d6..1e83a2e04 100644 --- a/test/val/cq81.c +++ b/test/val/cq81.c @@ -708,7 +708,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq84.c b/test/val/cq84.c index 64429e300..c1f62913e 100644 --- a/test/val/cq84.c +++ b/test/val/cq84.c @@ -249,7 +249,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq85.c b/test/val/cq85.c index 49423e7de..81a99c960 100644 --- a/test/val/cq85.c +++ b/test/val/cq85.c @@ -294,7 +294,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq86.c b/test/val/cq86.c index 9c850662a..90cfa0b7c 100644 --- a/test/val/cq86.c +++ b/test/val/cq86.c @@ -209,7 +209,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/cq88.c b/test/val/cq88.c index ef742824e..a9af7bef7 100644 --- a/test/val/cq88.c +++ b/test/val/cq88.c @@ -165,7 +165,7 @@ int main(int n,char **args) { int j; static struct defs d0, *pd0; - + d0.flgs = 1; /* These flags dictate */ d0.flgm = 1; /* the verbosity of */ d0.flgd = 1; /* the program. */ diff --git a/test/val/duffs-device.c b/test/val/duffs-device.c index effb33bb2..eb91e244f 100644 --- a/test/val/duffs-device.c +++ b/test/val/duffs-device.c @@ -1,6 +1,6 @@ /* !!DESCRIPTION!! Implementation of Duff's device (loop unrolling). - !!ORIGIN!! + !!ORIGIN!! !!LICENCE!! GPL, read COPYING.GPL */ @@ -34,7 +34,7 @@ int acmp(char* a, char* b, int count) return 0; } -void duffit (char* to, char* from, int count) +void duffit (char* to, char* from, int count) { int n = (count + 7) / 8; @@ -55,14 +55,14 @@ int main(void) { char a[ASIZE] = {1}; char b[ASIZE] = {2}; - + /* a and b should be different */ if(!acmp(a, b, ASIZE)) { failures++; } - + duffit(a, b, ASIZE); - + /* a and b should be the same */ if(acmp(a, b, ASIZE)) { failures++; diff --git a/test/val/lib_common_ctype.c b/test/val/lib_common_ctype.c index 39c92953b..281ee454e 100644 --- a/test/val/lib_common_ctype.c +++ b/test/val/lib_common_ctype.c @@ -16,7 +16,7 @@ #define NUMTESTS 257 -typedef struct +typedef struct { bool isalnum; bool isalpha; @@ -30,7 +30,7 @@ typedef struct bool isspace; bool isupper; bool isxdigit; - bool isblank; + bool isblank; } CTypeClassifications; @@ -89,7 +89,7 @@ CTypeClassifications testSet[NUMTESTS] = {false, false, true, false, false, true, false, true, true, false, false, false, false}, // 2D {false, false, true, false, false, true, false, true, true, false, false, false, false}, // 2E {false, false, true, false, false, true, false, true, true, false, false, false, false}, // 2F - + {true, false, true, false, true, true, false, true, false, false, false, true, false}, // 30 {true, false, true, false, true, true, false, true, false, false, false, true, false}, // 31 {true, false, true, false, true, true, false, true, false, false, false, true, false}, // 32 @@ -123,7 +123,7 @@ CTypeClassifications testSet[NUMTESTS] = {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 4D {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 4E {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 4F - + {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 50 {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 51 {true, true, true, false, false, true, false, true, false, false, true, false, false}, // 52 diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c index 6b2273e78..cf81bc404 100644 --- a/test/val/lib_common_memmove.c +++ b/test/val/lib_common_memmove.c @@ -10,7 +10,7 @@ TEST { unsigned i, v; char* p; - + for (i=0; i < BufferSize; ++i) Buffer[i+1] = (i%128); @@ -35,7 +35,7 @@ TEST ASSERT_AreEqual(i%128, (unsigned)Buffer[i+2], "%u", "Unexpected value in buffer at position %u!" COMMA i+2); } - v = Buffer[BufferSize+1]; // rember value of first untouched end-byte + v = Buffer[BufferSize+1]; // rember value of first untouched end-byte // copy downwards p = memmove(Buffer+1, Buffer+2, BufferSize); diff --git a/test/val/lib_common_mulxx.c b/test/val/lib_common_mulxx.c index cf5f089e9..e5afb3f0e 100644 --- a/test/val/lib_common_mulxx.c +++ b/test/val/lib_common_mulxx.c @@ -4,7 +4,7 @@ TEST { unsigned i; - + for (i=0; i < 256; ++i) { ASSERT_AreEqual(i*20, mul20(i), "%u", "Invalid 'mul20(%u)' calculation!" COMMA i); diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c index 1872053a4..3947c5130 100644 --- a/test/val/lib_common_strcat.c +++ b/test/val/lib_common_strcat.c @@ -11,7 +11,7 @@ TEST { unsigned i,j; char* p; - + for (i=0; i < SourceStringSize; ++i) SourceString[i] = (i%128)+1; @@ -23,13 +23,13 @@ TEST DestinationString[0] = 0; ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); - + /* Test concatenation to empty buffer */ strcat(DestinationString, SourceString); - + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); - + /* Test concatenation to non empty buffer */ p = strcat(DestinationString, SourceString); diff --git a/test/val/lib_common_strchr.c b/test/val/lib_common_strchr.c index a48d287e5..6f2db258a 100644 --- a/test/val/lib_common_strchr.c +++ b/test/val/lib_common_strchr.c @@ -1,7 +1,7 @@ #include <string.h> #include "unittest.h" - + /* Test string. Must NOT have duplicate characters! */ static char S[] = "Helo wrd!\n"; diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c index f289ddb95..1adb19671 100644 --- a/test/val/lib_common_strcspn.c +++ b/test/val/lib_common_strcspn.c @@ -11,7 +11,7 @@ static char* TestChars="1234567890"; // we like to find numbe TEST { unsigned i; - + for (i=0; i < EstimatedStringSize; ++i) EstimatedString[i] = (i%26)+'A'; // put ABCD... into the string to be estimated diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c index a6f92ac05..54cf0e3e5 100644 --- a/test/val/lib_common_strncat.c +++ b/test/val/lib_common_strncat.c @@ -11,7 +11,7 @@ TEST { unsigned i; char* p; - + for (i=0; i < SourceStringSize; ++i) SourceString[i] = (i%128)+1; @@ -23,13 +23,13 @@ TEST DestinationString[0] = 0; ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); - + /* Test "unlimted" concatenation to empty buffer */ strncat(DestinationString, SourceString, 1024); - + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); - + /* Test limited concatenation to non empty buffer */ p = strncat(DestinationString, SourceString, 128); diff --git a/test/val/lib_common_strrchr.c b/test/val/lib_common_strrchr.c index a72c44db9..840ec2b7c 100644 --- a/test/val/lib_common_strrchr.c +++ b/test/val/lib_common_strrchr.c @@ -1,6 +1,6 @@ #include <string.h> #include "unittest.h" - + static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c index 96a006469..b7b4c1d85 100644 --- a/test/val/lib_common_strspn.c +++ b/test/val/lib_common_strspn.c @@ -10,7 +10,7 @@ static char* TestChars="1234567890"; // we like to find numbe TEST { unsigned i; - + for (i=0; i < EstimatedStringSize; ++i) EstimatedString[i] = (i%10)+'0'; // put 0123... into the string to be estimated diff --git a/test/val/mult1.c b/test/val/mult1.c index 831bde7ec..6d491a427 100644 --- a/test/val/mult1.c +++ b/test/val/mult1.c @@ -48,23 +48,23 @@ void m2(unsigned char uc) void m3(unsigned char uc) { volatile unsigned char vuc; - + /* uchar = uchar * lit */ /* testing literal multiply with same source and destination */ vuc = uc; - uc2 = 0; - uc1 = vuc; uc1 = uc1*1; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*2; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*3; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*4; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc2 = 0; + uc1 = vuc; uc1 = uc1*1; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*2; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*3; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*4; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*5; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*6; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*7; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*8; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*6; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*7; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*8; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*9; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*10; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*11; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*12; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*10; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*11; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*12; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*13; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*14; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*15; if( uc1 != (uc2+=TESTLIT) ) failures++; @@ -75,17 +75,17 @@ void m3(unsigned char uc) uc1 = vuc; uc1 = uc1*20; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*21; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*22; if( uc1 != (uc2+=TESTLIT) ) failures++; - uc1 = vuc; uc1 = uc1*23; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*23; if( uc1 != (uc2+=TESTLIT) ) failures++; uc1 = vuc; uc1 = uc1*24; if( uc1 != (uc2+=TESTLIT) ) failures++; - + uc1 = vuc; uc1 = uc1*31; if( uc1 != ((31*TESTLIT) & 0xff) ) failures++; uc1 = vuc; uc1 = uc1*32; if( uc1 != ((32*TESTLIT) & 0xff) ) failures++; uc1 = vuc; uc1 = uc1*64; if( uc1 != ((64*TESTLIT) & 0xff) ) failures++; uc1 = vuc; uc1 = uc1*128;if( uc1 != ((128*TESTLIT)& 0xff) ) failures++; /* testing literal multiply with different source and destination */ - uc1 = vuc*1; if( uc1 != ((1*TESTLIT) & 0xff) ) failures++; - uc1 = vuc*2; if( uc1 != ((2*TESTLIT) & 0xff) ) failures++; + uc1 = vuc*1; if( uc1 != ((1*TESTLIT) & 0xff) ) failures++; + uc1 = vuc*2; if( uc1 != ((2*TESTLIT) & 0xff) ) failures++; uc1 = vuc*4; if( uc1 != ((4*TESTLIT) & 0xff) ) failures++; } diff --git a/test/val/or1.c b/test/val/or1.c index 9e41d7a39..b5f550331 100644 --- a/test/val/or1.c +++ b/test/val/or1.c @@ -57,23 +57,23 @@ void or_lit2uint(void) failures++; uint0 |= 1; - if(uint0 != 1) + if(uint0 != 1) failures++; uint0 |= 2; - if(uint0 != 3) + if(uint0 != 3) failures++; uint0 |= 0x100; - if(uint0 != 0x103) + if(uint0 != 0x103) failures++; uint0 |= 0x102; - if(uint0 != 0x103) + if(uint0 != 0x103) failures++; uint0 |= 0x303; - if(uint0 != 0x303) + if(uint0 != 0x303) failures++; } @@ -83,27 +83,27 @@ void or_lit2ulong(void) failures++; ulong0 |= 1; - if(ulong0 != 1) + if(ulong0 != 1) failures++; ulong0 |= 2; - if(ulong0 != 3) + if(ulong0 != 3) failures++; ulong0 |= 0x100; - if(ulong0 != 0x103) + if(ulong0 != 0x103) failures++; ulong0 |= 0x102; - if(ulong0 != 0x103) + if(ulong0 != 0x103) failures++; ulong0 |= 0x303; - if(ulong0 != 0x303) + if(ulong0 != 0x303) failures++; ulong0 |= 0x80000000; - if(ulong0 != 0x80000303) + if(ulong0 != 0x80000303) failures++; } diff --git a/test/val/postdec-16-16.c b/test/val/postdec-16-16.c index e55b5765f..bb4475959 100644 --- a/test/val/postdec-16-16.c +++ b/test/val/postdec-16-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postdec-16-8.c b/test/val/postdec-16-8.c index 76a64d769..d2a5bab3b 100644 --- a/test/val/postdec-16-8.c +++ b/test/val/postdec-16-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postdec-8-16.c b/test/val/postdec-8-16.c index f7716ae89..7eeda2dcc 100644 --- a/test/val/postdec-8-16.c +++ b/test/val/postdec-8-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postdec-8-8.c b/test/val/postdec-8-8.c index b620c46dc..38470cb14 100644 --- a/test/val/postdec-8-8.c +++ b/test/val/postdec-8-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postinc-16-16.c b/test/val/postinc-16-16.c index 286e0364b..4a122e51f 100644 --- a/test/val/postinc-16-16.c +++ b/test/val/postinc-16-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 1; static unsigned short u16r = 3; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postinc-16-8.c b/test/val/postinc-16-8.c index dd0a03d6c..a604ab34c 100644 --- a/test/val/postinc-16-8.c +++ b/test/val/postinc-16-8.c @@ -1,12 +1,12 @@ #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -26,9 +26,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 1; static unsigned char u8r = 3; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = 0; @@ -40,17 +40,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -60,13 +60,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postinc-8-16.c b/test/val/postinc-8-16.c index 57e934ced..7ac57e9da 100644 --- a/test/val/postinc-8-16.c +++ b/test/val/postinc-8-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 1; static unsigned short u16r = 3; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/postinc-8-8.c b/test/val/postinc-8-8.c index b168af8df..97c8aa9f7 100644 --- a/test/val/postinc-8-8.c +++ b/test/val/postinc-8-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 1; static unsigned char u8r = 3; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/pptest4.c b/test/val/pptest4.c index 827be7200..6c0891661 100644 --- a/test/val/pptest4.c +++ b/test/val/pptest4.c @@ -2,7 +2,7 @@ /* preprocessor test #4 */ #define t(x,y,z) x ## y ## z -int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), +int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), t(10,,), t(,11,), t(,,12), t(,,) }; int e[] = { 123, 45, 67, 89, 10, 11, 12, }; diff --git a/test/val/pptest5.c b/test/val/pptest5.c index 82f642c8e..0b9db291d 100644 --- a/test/val/pptest5.c +++ b/test/val/pptest5.c @@ -1,7 +1,7 @@ /* preprocessor test #5 */ -#define t(x,y,z) x ## y ## z +#define t(x,y,z) x ## y ## z int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), t(10,,), t(,11,), t(,,12), t(,,) }; diff --git a/test/val/pr1423.c b/test/val/pr1423.c index 3135b64a3..47f0f0610 100644 --- a/test/val/pr1423.c +++ b/test/val/pr1423.c @@ -10,7 +10,7 @@ void test1(void) } fails++; return; -} +} void test2(void) { diff --git a/test/val/predec-16-16.c b/test/val/predec-16-16.c index 7d70b1208..a8c1658e4 100644 --- a/test/val/predec-16-16.c +++ b/test/val/predec-16-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/predec-16-8.c b/test/val/predec-16-8.c index 69a0a3e28..a0e77da89 100644 --- a/test/val/predec-16-8.c +++ b/test/val/predec-16-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/predec-8-16.c b/test/val/predec-8-16.c index 750312215..353f819d2 100644 --- a/test/val/predec-8-16.c +++ b/test/val/predec-8-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/predec-8-8.c b/test/val/predec-8-8.c index d1069b39e..e468c9426 100644 --- a/test/val/predec-8-8.c +++ b/test/val/predec-8-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/preinc-16-16.c b/test/val/preinc-16-16.c index d9c6dbf62..b600b6533 100644 --- a/test/val/preinc-16-16.c +++ b/test/val/preinc-16-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/preinc-16-8.c b/test/val/preinc-16-8.c index 97a5dd306..a7bc5d53a 100644 --- a/test/val/preinc-16-8.c +++ b/test/val/preinc-16-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned short u16w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u16w: %d\n\r", u16w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/preinc-8-16.c b/test/val/preinc-8-16.c index 3c3a9b479..2b4104df5 100644 --- a/test/val/preinc-8-16.c +++ b/test/val/preinc-8-16.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned short u16r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u16r: %d\n\r", u16r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/preinc-8-8.c b/test/val/preinc-8-8.c index a700bfc48..9f6ec35a9 100644 --- a/test/val/preinc-8-8.c +++ b/test/val/preinc-8-8.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef __C64__ +#ifdef __C64__ #include <conio.h> #endif /* apparently we dont trigger the bug when not using absolute addresses? */ -#ifdef __C64__ +#ifdef __C64__ #define TARGETMEM 0x4c8 #define SOURCEMEM 0x702 #elif __SIM6502__ @@ -27,9 +27,9 @@ static unsigned char mem[0x10]; static unsigned char u8w = 3; static unsigned char u8r = 5; -static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; -static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; -static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; static unsigned char i; static unsigned char err = EXIT_SUCCESS; @@ -41,17 +41,17 @@ void test1(void) void dotest(void) { - + memcpy(TARGETMEM, target, 8); memcpy(SOURCEMEM, source, 8); - + test1(); memcpy(target, TARGETMEM, 8); memcpy(source, SOURCEMEM, 8); -#ifdef __C64__ +#ifdef __C64__ clrscr(); -#endif +#endif printf("source:"); for(i = 0; i < 8; ++i) { printf("%0x ", source[i]); @@ -61,13 +61,13 @@ void dotest(void) printf("%0x ", target[i]); } printf("\n\r"); - + printf("u8w: %d\n\r", u8w); printf("u8r: %d\n\r", u8r); - + } - -int main(void) + +int main(void) { dotest(); dotest(); diff --git a/test/val/static-fwd-decl.c b/test/val/static-fwd-decl.c index 420640d97..a133e930f 100644 --- a/test/val/static-fwd-decl.c +++ b/test/val/static-fwd-decl.c @@ -15,7 +15,7 @@ typedef struct _DIRMENU { const char *name; struct _DIRMENU *dest; -} DIRMENU; +} DIRMENU; static DIRMENU rmenu; diff --git a/test/val/strnicmp-test.c b/test/val/strnicmp-test.c index 6376a39bb..e6e5a3b04 100644 --- a/test/val/strnicmp-test.c +++ b/test/val/strnicmp-test.c @@ -71,9 +71,9 @@ int main(void) ret = do_test("", "", 5); printresult(ret); - + printf("fails: %d\n", fails); - + #if defined(__CC65__) && !defined(__SIM6502__) && !defined(__SIM65C02__) cgetc(); #endif diff --git a/test/val/sub1.c b/test/val/sub1.c index 5dbba97df..06e5cf463 100644 --- a/test/val/sub1.c +++ b/test/val/sub1.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! Substraction Test + !!DESCRIPTION!! Subtraction Test !!ORIGIN!! SDCC regression tests !!LICENCE!! GPL, read COPYING.GPL */ diff --git a/test/val/sub2.c b/test/val/sub2.c index 835e65733..d3ea2a05b 100644 --- a/test/val/sub2.c +++ b/test/val/sub2.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! Substraction Test + !!DESCRIPTION!! Subtraction Test !!ORIGIN!! SDCC regression tests !!LICENCE!! GPL, read COPYING.GPL */ diff --git a/test/val/switch2.c b/test/val/switch2.c index 65c24eeda..eff06ce12 100644 --- a/test/val/switch2.c +++ b/test/val/switch2.c @@ -1,6 +1,6 @@ /* !!DESCRIPTION!! Testing empty bodied switch statements. - !!ORIGIN!! + !!ORIGIN!! !!LICENCE!! GPL, read COPYING.GPL */ diff --git a/test/val/time-test.c b/test/val/time-test.c index 304238fa0..db086410d 100644 --- a/test/val/time-test.c +++ b/test/val/time-test.c @@ -46,7 +46,7 @@ int main (void) sprintf (result, "%08lX - %s\n", t, buf); printf (result); if (strcmp(result, EXPECTSTR) != 0) { fails++; } - + printf("fails: %d\n", fails); return fails; diff --git a/test/val/xor.c b/test/val/xor.c index 2a346023e..98bd5faf1 100644 --- a/test/val/xor.c +++ b/test/val/xor.c @@ -31,12 +31,12 @@ void xor_chars_0_1(void) void xor_if(void) { - if(achar0 ^ achar1) + if(achar0 ^ achar1) failures++; achar0 ^= 0xff; - if( !(achar0 ^ achar1) ) + if( !(achar0 ^ achar1) ) failures++; } diff --git a/util/.gitignore b/util/.gitignore new file mode 100644 index 000000000..4da436acb --- /dev/null +++ b/util/.gitignore @@ -0,0 +1,3 @@ +/atari/ataricvt +/gamate/gamate-fixcart +/zlib/deflater diff --git a/util/atari/ataricvt.c b/util/atari/ataricvt.c index 104d4f6de..23ad5a24a 100644 --- a/util/atari/ataricvt.c +++ b/util/atari/ataricvt.c @@ -8,7 +8,7 @@ int main (void) putchar ('\n'); } else if (C == 0x7F) { putchar ('\t'); - } else { + } else { putchar (C); } }