diff --git a/asminc/c128.inc b/asminc/c128.inc index 7a98d770c..2852631f3 100644 --- a/asminc/c128.inc +++ b/asminc/c128.inc @@ -45,20 +45,6 @@ KBDREPEAT := $028a KBDREPEATRATE := $028b KBDREPEATDELAY := $028c -; --------------------------------------------------------------------------- -; Kernal routines - -; Direct entries -CURS_SET := $CD57 -CURS_ON := $CD6F -CURS_OFF := $CD9F -CLRSCR := $C142 -KBDREAD := $C006 -NEWLINE := $C363 -PRINT := $C322 -NMIEXIT := $FF33 -INDFET := $FF74 - ; --------------------------------------------------------------------------- ; Vectors diff --git a/asminc/c64.inc b/asminc/c64.inc index c12f8e64b..1d10f673d 100644 --- a/asminc/c64.inc +++ b/asminc/c64.inc @@ -37,14 +37,6 @@ KBDREPEAT := $28a KBDREPEATRATE := $28b KBDREPEATDELAY := $28c -; --------------------------------------------------------------------------- -; Kernal routines - -; Direct entries -CLRSCR := $E544 -KBDREAD := $E5B4 -NMIEXIT := $FEBC - ; --------------------------------------------------------------------------- ; Vector and other locations diff --git a/asminc/cbm.mac b/asminc/cbm.mac index b2bfe5992..6d7ac7e8d 100644 --- a/asminc/cbm.mac +++ b/asminc/cbm.mac @@ -1,9 +1,13 @@ ; Convert characters to screen codes -; Helper macro that converts and outputs one character +; Macro that converts one character. +; scrbyte() can be used as an instruction operand +.define scrbyte(code) (<(.strat ("h@dbdlhh", code >> 5) << 4) ^ code) + +; Helper macro that stores one character .macro _scrcode char .if (char < 256) - .byte <(.strat ("h@dbdlhh", char >> 5) << 4) ^ char + .byte scrbyte {char} .else .error "scrcode: Character constant out of range" .endif @@ -38,13 +42,9 @@ ; Anything else is an error .else - .error "scrcode: invalid argument type" - .endif ; Call the macro recursively with the remaining args scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 .endmacro - - diff --git a/asminc/cbm_kernal.inc b/asminc/cbm_kernal.inc index 4e2e927e4..29a6e5ddf 100644 --- a/asminc/cbm_kernal.inc +++ b/asminc/cbm_kernal.inc @@ -82,3 +82,28 @@ UDTIM := $FFEA PLOT := $FFF0 IOBASE := $FFF3 .endif + +; --------------------------------------------------------------------------- +; Kernal routines, direct entries + +.if .def(__VIC20__) + CLRSCR := $E55F + KBDREAD := $E5CF +.elseif .def(__C64__) + CLRSCR := $E544 + KBDREAD := $E5B4 + NMIEXIT := $FEBC +.elseif .def(__C128__) + CLRSCR := $C142 + KBDREAD := $C006 + NMIEXIT := $FF33 + NEWLINE := $C363 + PRINT := $C322 + CURS_SET := $CD57 + CURS_ON := $CD6F + CURS_OFF := $CD9F + INDFET := $FF74 +.elseif .def(__C16__) + CLRSCR := $D88B + KBDREAD := $D8C1 +.endif diff --git a/asminc/mouse-kernel.inc b/asminc/mouse-kernel.inc index 3eebca244..ab4790d1d 100644 --- a/asminc/mouse-kernel.inc +++ b/asminc/mouse-kernel.inc @@ -103,7 +103,7 @@ ;------------------------------------------------------------------------------ ; The mouse API version, stored in MOUSE_HDR::VERSION -MOUSE_API_VERSION = $05 +MOUSE_API_VERSION = $06 ;------------------------------------------------------------------------------ ; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS. diff --git a/asminc/plus4.inc b/asminc/plus4.inc index 5ea4dcf88..774722e93 100644 --- a/asminc/plus4.inc +++ b/asminc/plus4.inc @@ -37,13 +37,6 @@ KBDREPEAT := $540 KBDREPEATRATE := $541 KBDREPEATDELAY := $542 -; --------------------------------------------------------------------------- -; Kernal routines - -; Direct entries -CLRSCR := $D88B -KBDREAD := $D8C1 - ; --------------------------------------------------------------------------- ; Vector and other locations @@ -90,5 +83,3 @@ TED_RAMSEL := $FF3F ENABLE_ROM := TED_ROMSEL ENABLE_RAM := TED_RAMSEL - - diff --git a/asminc/ser-kernel.inc b/asminc/ser-kernel.inc index 3ddb7f300..546587515 100644 --- a/asminc/ser-kernel.inc +++ b/asminc/ser-kernel.inc @@ -41,15 +41,15 @@ VERSION .byte 1 ; Interface version LIBREF .addr ; Library reference JUMPTAB .struct - INSTALL .addr ; INSTALL routine - UNINSTALL .addr ; UNINSTALL routine - OPEN .addr ; OPEN routine - CLOSE .addr ; CLOSE routine - GET .addr ; GET routine - PUT .addr ; PUT routine - STATUS .addr ; STATUS routine - IOCTL .addr ; IOCTL routine - IRQ .addr ; IRQ routine + SER_INSTALL .addr ; SER_INSTALL routine + SER_UNINSTALL .addr ; SER_UNINSTALL routine + SER_OPEN .addr ; SER_OPEN routine + SER_CLOSE .addr ; SER_CLOSE routine + SER_GET .addr ; SER_GET routine + SER_PUT .addr ; SER_PUT routine + SER_STATUS .addr ; SER_STATUS routine + SER_IOCTL .addr ; SER_IOCTL routine + SER_IRQ .addr ; SER_IRQ routine .endstruct .endstruct @@ -160,4 +160,3 @@ SER_STATUS_DSR = $40 ; NOT data set ready .global _ser_ioctl .global _ser_clear_ptr - diff --git a/asminc/smc.inc b/asminc/smc.inc index 0583f79e0..137c2d49a 100644 --- a/asminc/smc.inc +++ b/asminc/smc.inc @@ -63,7 +63,7 @@ _SMCDesignator: statement ldy #opcode sty _SMCDesignator .else - .error "Invalid usage of macro 'SMC_TransferOpcode'" + .error "Invalid usage of macro 'SMC_TransferOpcode'" .endif .endmacro @@ -75,7 +75,7 @@ _SMCDesignator: statement .elseif .match ({register}, y) ldy _SMCDesignator .else - .error "Invalid usage of macro 'SMC_LoadOpcode'" + .error "Invalid usage of macro 'SMC_LoadOpcode'" .endif .endmacro @@ -87,7 +87,7 @@ _SMCDesignator: statement .elseif .match ({register}, y) sty _SMCDesignator .else - .error "Invalid usage of macro 'SMC_StoreOpcode'" + .error "Invalid usage of macro 'SMC_StoreOpcode'" .endif .endmacro @@ -102,7 +102,7 @@ _SMCDesignator: statement ldy #(<(destination - _SMCDesignator - 2)) sty _SMCDesignator+1 .else - .error "Invalid usage of macro 'SMC_ChangeBranch'" + .error "Invalid usage of macro 'SMC_ChangeBranch'" .endif .endmacro @@ -117,7 +117,7 @@ _SMCDesignator: statement ldy value sty _SMCDesignator+1 .else - .error "Invalid usage of macro 'SMC_TransferValue'" + .error "Invalid usage of macro 'SMC_TransferValue'" .endif .endmacro @@ -129,7 +129,7 @@ _SMCDesignator: statement .elseif .match ({register}, y) ldy _SMCDesignator+1 .else - .error "Invalid usage of macro 'SMC_LoadValue'" + .error "Invalid usage of macro 'SMC_LoadValue'" .endif .endmacro @@ -141,7 +141,7 @@ _SMCDesignator: statement .elseif .match ({register}, y) sty _SMCDesignator+1 .else - .error "Invalid usage of macro 'SMC_StoreValue'" + .error "Invalid usage of macro 'SMC_StoreValue'" .endif .endmacro @@ -169,7 +169,7 @@ SMC_StoreValue label, register ldy value sty _SMCDesignator+2 .else - .error "Invalid usage of macro 'SMC_TransferHighByte'" + .error "Invalid usage of macro 'SMC_TransferHighByte'" .endif .endmacro @@ -181,7 +181,7 @@ SMC_StoreValue label, register .elseif .match ({register}, y) ldy _SMCDesignator+2 .else - .error "Invalid usage of macro 'SMC_LoadHighByte'" + .error "Invalid usage of macro 'SMC_LoadHighByte'" .endif .endmacro @@ -193,7 +193,7 @@ SMC_StoreValue label, register .elseif .match ({register}, y) sty _SMCDesignator+2 .else - .error "Invalid usage of macro 'SMC_StoreHighByte'" + .error "Invalid usage of macro 'SMC_StoreHighByte'" .endif .endmacro @@ -241,7 +241,7 @@ SMC_StoreValue label, register sty _SMCDesignator+2 .endif .else - .error "Invalid usage of macro 'SMC_TransferAddressSingle'" + .error "Invalid usage of macro 'SMC_TransferAddressSingle'" .endif .endmacro diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index df607e375..f2eb42ff4 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -54,9 +54,18 @@ IRQSVY := $23 ; Used to save Y when a BRK call occurs IRQSVP := $24 ; Used to save P when a BRK call occurs ADSCR := $26 +SCRNB := $28 ; Id of the current window + +ADKBD := $2A ; Address ASCII conversion table + PTR_READ_DEST := $2C ; Used for XFREAD and XWRITE only in TELEMON 3.x +ADCLK := $40 ; Address for clock display +TIMEUS := $42 +TIMEUD := $44 + + HRSX := $46 HRSY := $47 @@ -64,6 +73,9 @@ XLPRBI := $48 ; Printer flag (b7) HRSX40 := $49 HRSX6 := $4A + +ADHRS := $4B ; Hires screen address (word) + HRS1 := $4D HRS2 := $4F HRS3 := $51 @@ -72,6 +84,8 @@ HRS5 := $55 HRSFB := $57 +VABKP1 := $58 + ; RS232T ; b0-b3 : speed ; 1111 => 19200 bps (please note that telestrat can't handle this speed without stopping all IRQ except ACIA's one) @@ -103,6 +117,18 @@ RS232T := $59 ; : 11 SPACE SENT, reception not tested RS232C := $5A +INDRS := $5B + +ACC1E := $60 +ACC1M := $61 + +ACC1S := $65 + +FLGMEN := $68 +ADMEN := $69 + +FLSVS := $89 +FLERR := $8B VARLNG := $8C VARAPL := $D0 @@ -195,14 +221,20 @@ XDECAL = $18 XTEXT = $19 XHIRES = $1A +XEFFHI = $1B ; Clear hires screen XFILLM = $1C XMINMA = $1F XVARS = $24 ; Only in TELEMON 3.x, in TELEMON 2.4, it's XNOMFI ($24) XCRLF = $25 ; Jump a line and return to the beginning of the line +XDECAY = $26 XFREAD = $27 ; Only in TELEMON 3.x (bank 7 of Orix) XBINDX = $28 ; Convert a number into hex and displays on channel 0 XDECIM = $29 XHEXA = $2A ; Convert a number into hex + +XEDT = $2D ; Launch editor +XINSER = $2E + XSCELG = $2F ; Search a line in editor mode XOPEN = $30 ; Only in TELEMON 3.x (bank 7 of Orix) XECRPR = $33 ; Displays prompt @@ -212,7 +244,12 @@ XSCRSE = $36 XSCRNE = $39 ; Load charset from rom to ram XCLOSE = $3A ; Only in TELEMON 3.x close file (bank 7 of Orix) XFWRITE = $3B ; Only in TELEMON 3.x write file (bank 7 of Orix) -XWRCLK = $3E ; Update clock + +; Clock primitive +XRECLK = $3C ; Reset clock +XCLCL = $3D ; Close clock +XWRCLK = $3E ; Displays clock in the adress in A & Y registers + XSONPS = $40 ; Send data to PSG register (14 values) XOUPS = $42 ; Send Oups sound into PSG XPLAY = $43 ; Play a sound @@ -222,7 +259,17 @@ XZAP = $46 ; Send Zap sound to PSG XSHOOT = $47 XMKDIR = $4B ; Create a folder. Only available in TELEMON 3.x (bank 7 of Orix) XRM = $4D ; Remove a folder or a file. Only available in TELEMON 3.x (bank 7 of Orix) -XGOKBD = $52 +XGOKBD = $52 + +; 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 +XINIBU = $58 ; Initialize the buffer X +XDEFBU = $59 ; Reset all value of the buffer +XBUSY = $5A ; Test if the buffer is empty + XMALLOC = $5B ; Only in TELEMON 3.x (bank 7 of Orix) XFREE = $62 ; Only in TELEMON 3.x (bank 7 of Orix) XSOUT = $67 ; Send accumulator value (A) to RS232, available in TELEMON 2.4 & 3.x : if RS232 buffer is full, the Oric Telestrat freezes @@ -256,28 +303,83 @@ BUFTRV := $100 ; Page $200 BNKST := $200 ; Used to store signature of 8 bank (length : 8 bytes) TABDRV := $208 + +DRVDEF := $20C FLGTEL := $20D KOROM := $20E ; Used to compute the size of all rom bank. The result is store here. The value is in KB KORAM := $20F ; Used to compute the size of all ram bank. The result is store here. The value is in KB +; Time management TIMED := $210 TIMES := $211 TIMEM := $212 +TIMEH := $213 +FLGCLK := $214 +FLGCLK_FLAG := $215 +FLGCUR := $216 ; Cursor management flag +; screens position managements + +FLGCUR_STATE := $217 ; Cursor state flag + ADSCRL := $218 ADSCRH := $21C SCRX := $220 SCRY := $224 + +SCRDX := $228 +SCRFX := $22C +SCRDY := $230 +SCRFY := $234 +SCRBAL := $238 +SCRBAH := $23C +SCRCT := $240 +SCRCF := $244 +FLGSCR := $248 +CURSCR := $24C + +HARD_COPY_HIRES := $250 ; Hard copy vector + +SCRTXT := $256 +SCRHIR := $25C +SCRTRA := $262 ; 6 bytes lenfth + +; Keyboard management +KBDCOL := $268 ; 8 bytes length +KBDFLG_KEY := $270 ; 0 if no key pressed +KBDVRR := $272 + KBDVRL := $273 FLGKBD := $275 KBDFCT := $276 KBDSHT := $278 + +KBDKEY := $279 KBDCTC := $27E +LPRX := $286 +LPRY := $287 LPRFX := $288 LPRFY := $289 +FLGLPR := $28A + +; Joysticks management +FLGJCK := $28C +JCGVAL := $28D +JCDVAL := $28E +JCKTAB := $29D + + HRSPAT := $2AA ; Hires pattern : it's used to draw pattern for a line or a circle -ADIOB := $2BE +HRSERR := $2AB + +IOTAB0 := $2AE +IOTAB1 := $2B2 +IOTAB2 := $2B6 +IOTAB3 := $2BA +ADIOB := $2BE ; 48 bytes length FLGRST := $2EE CSRND := $2EF VNMI := $2F4 +ADIODB_VECTOR := $2f7 ; 3 bytes length + IRQVECTOR := $2FA VAPLIC := $2FD @@ -310,6 +412,9 @@ MAX_BUFEDT_LENGTH=110 CH376_DATA := $340 CH376_COMMAND := $341 +; RAM overlays buffer +BUFBUF := $c080 + ; --------------------------------------------------------------------------- ; Stratsed vectors ; Stratsed is the main OS for Telestrat @@ -367,5 +472,5 @@ XRWTS := $FFAA ; MACRO .macro BRK_TELEMON value - .byte $00,value + .byte $00,value .endmacro diff --git a/asminc/vic20.inc b/asminc/vic20.inc index 5976981fd..b82874f56 100644 --- a/asminc/vic20.inc +++ b/asminc/vic20.inc @@ -41,13 +41,6 @@ KBDREPEATDELAY := $28c XSIZE = 22 YSIZE = 23 -; --------------------------------------------------------------------------- -; Kernal routines - -; Direct entries -CLRSCR := $E55F -KBDREAD := $E5CF - ; --------------------------------------------------------------------------- ; Vector and other locations diff --git a/cfg/atari-asm-xex.cfg b/cfg/atari-asm-xex.cfg new file mode 100644 index 000000000..f0a6291db --- /dev/null +++ b/cfg/atari-asm-xex.cfg @@ -0,0 +1,24 @@ +FEATURES { + STARTADDRESS: default = $2E00; +} +SYMBOLS { + __STARTADDRESS__: type = export, value = %S; +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; + MAIN: file = %O, define = yes, start = %S, size = $BC20 - %S; +} +FILES { + %O: format = atari; +} +FORMATS { + atari: runad = start; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs + CODE: load = MAIN, type = rw, define = yes; + RODATA: load = MAIN, type = ro optional = yes; + DATA: load = MAIN, type = rw optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; +} diff --git a/cfg/atari-xex.cfg b/cfg/atari-xex.cfg new file mode 100644 index 000000000..5f390e12c --- /dev/null +++ b/cfg/atari-xex.cfg @@ -0,0 +1,56 @@ +# Sample linker configuration for C programs using the Atari binary file support. +# Use with: cl65 -tatari -Catari-c-xex.cfg prog.c -o prog.xex +FEATURES { + STARTADDRESS: default = $2000; +} +SYMBOLS { + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; + __RESERVED_MEMORY__: type = weak, value = $0000; + __SYSCHKHDR__: type = export, value = 0; # Disable system check header + __SYSCHKTRL__: type = export, value = 0; # Disable system check trailer +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; +# "system check" load chunk + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; +# "main program" load chunk + MAIN: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; +} +FILES { + %O: format = atari; +} +FORMATS { + atari: runad = start, + initad = SYSCHKCHNK: __SYSTEM_CHECK__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWBSS: load = MAIN, type = rw, optional = yes; # not zero initialized + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, 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/atarixl-xex.cfg b/cfg/atarixl-xex.cfg new file mode 100644 index 000000000..0b1fe9ca1 --- /dev/null +++ b/cfg/atarixl-xex.cfg @@ -0,0 +1,79 @@ +# Sample linker configuration for C programs using the Atari binary file support. +# Use with: cl65 -tatarixl -Catarixl-c-xex.cfg prog.c -o prog.xex +FEATURES { + STARTADDRESS: default = $2400; +} +SYMBOLS { + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; + __SYSCHKHDR__: type = export, value = 0; # Disable system check header + __SYSCHKTRL__: type = export, value = 0; # Disable system check trailer +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; + +# "system check" load chunk + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + +# "shadow RAM preparation" load chunk + SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + +# "main program" load chunk + MAIN: file = %O, define = yes, start = %S + __LOWBSS_SIZE__, size = $D000 - __STACKSIZE__ - %S - __LOWBSS_SIZE__; + +# memory beneath the ROM preceeding the character generator + HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; + +# address of relocated character generator (same addess as ROM version) + CHARGEN: file = "", define = yes, start = $E000, size = $0400; + +# memory beneath the ROM + HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; + +# UNUSED - hide + UNUSED: file = "", start = $0, size = $10; +} +FILES { + %O: format = atari; +} +FORMATS { + atari: runad = start, + initad = SYSCHKCHNK: __SYSTEM_CHECK__, + initad = SRPREPCHNK: sramprep; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + + SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; + LOWBSS: load = SRPREPCHNK, type = bss, define = yes; # shared btw. SRPREPCHNK and RAM, not zero initialized + SRPREP: load = SRPREPCHNK, type = rw, define = yes; + SHADOW_RAM: load = SRPREPCHNK, run = HIDDEN_RAM, type = rw, define = yes, optional = yes; + SHADOW_RAM2: load = SRPREPCHNK, run = HIDDEN_RAM2, type = rw, define = yes, optional = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, define = yes; + SRPREPHDR: load = UNUSED, type = ro; + SRPREPTRL: load = UNUSED, type = ro; +} +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/geos-apple.cfg b/cfg/geos-apple.cfg index 2c9f6c589..98dcfb5aa 100644 --- a/cfg/geos-apple.cfg +++ b/cfg/geos-apple.cfg @@ -1,15 +1,19 @@ +FEATURES { + STARTADDRESS: default = $4000; +} SYMBOLS { __BACKBUFSIZE__: type = weak, value = $2000; + __HIMEM__: type = weak, value = $C000 - __BACKBUFSIZE__; __OVERLAYSIZE__: type = weak, value = $0000; - __OVERLAYADDR__: type = weak, value = $C000 - __BACKBUFSIZE__ - __OVERLAYSIZE__; - __STACKSIZE__: type = weak, value = $0400; + __OVERLAYADDR__: type = weak, value = __HIMEM__ - __OVERLAYSIZE__; + __STACKSIZE__: type = weak, value = $0400; # 1k stack __STACKADDR__: type = weak, value = $2000 - __STACKSIZE__; } MEMORY { CVT: file = %O, start = $0, size = $20000; ZP: define = yes, start = $80, size = $1A + $06; - EXT: define = yes, start = $0C00, size = __STACKADDR__ - $0C00; - VLIR0: define = yes, start = $4000, size = __OVERLAYADDR__ - $4000; + EXT: define = yes, start = $0C00, size = __STACKADDR__ - __EXT_START__; + VLIR0: define = yes, start = %S, size = __OVERLAYADDR__ - %S; VLIR1: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; VLIR2: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; VLIR3: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index d2e896fa5..4bf33fdf5 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -1,14 +1,18 @@ +FEATURES { + STARTADDRESS: default = $0400; +} SYMBOLS { __BACKBUFSIZE__: type = weak, value = $2000; + __HIMEM__: type = weak, value = $8000 - __BACKBUFSIZE__; __OVERLAYSIZE__: type = weak, value = $0000; - __OVERLAYADDR__: type = weak, value = $8000 - __BACKBUFSIZE__ - __OVERLAYSIZE__; - __STACKSIZE__: type = weak, value = $0400; + __OVERLAYADDR__: type = weak, value = __HIMEM__ - __OVERLAYSIZE__; + __STACKSIZE__: type = weak, value = $0400; # 1k stack __STACKADDR__: type = weak, value = __OVERLAYADDR__ - __STACKSIZE__; } MEMORY { CVT: file = %O, start = $0, size = $40000; ZP: define = yes, start = $58, size = $1A + $06; - VLIR0: define = yes, start = $0400, size = __STACKADDR__ - $0400; + VLIR0: define = yes, start = %S, size = __STACKADDR__ - %S; VLIR1: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; VLIR2: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; VLIR3: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__; diff --git a/cfg/plus4.cfg b/cfg/plus4.cfg index 802f1076e..b7199e008 100644 --- a/cfg/plus4.cfg +++ b/cfg/plus4.cfg @@ -1,13 +1,17 @@ +FEATURES { + STARTADDRESS: default = $1001; +} SYMBOLS { __LOADADDR__: type = import; __EXEHDR__: type = import; __STACKSIZE__: type = weak, value = $0800; # 2k stack + __HIMEM__: type = weak, value = $FD00; } MEMORY { - ZP: file = "", define = yes, start = $0002, size = $001A; - LOADADDR: file = %O, start = $0FFF, size = $0002; - HEADER: file = %O, start = $1001, size = $000C; - MAIN: file = %O, define = yes, start = $100D, size = $ECF3 - __STACKSIZE__; + ZP: file = "", define = yes, start = $0002, size = $001A; + LOADADDR: file = %O, start = %S - 2, size = $0002; + HEADER: file = %O, define = yes, start = %S, size = $000D; + MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __MAIN_START__ - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -15,8 +19,8 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; + ONCE: load = MAIN, type = ro, optional = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg index 14ae30311..db897133e 100644 --- a/cfg/telestrat.cfg +++ b/cfg/telestrat.cfg @@ -2,7 +2,7 @@ SYMBOLS { __ORIXHDR__: type = import; __STACKSIZE__: type = weak, value = $0800; # 2K stack __GRAB__: type = weak, value = 0; # 0=don't grab graphics RAM, 1=grab graphics RAM - __RAMEND__: type = weak, value = $9800 + $1C00 * __GRAB__; + __RAMEND__: type = weak, value = $9800 + $1C00 * __GRAB__; } MEMORY { ZP: file = "", define = yes, start = $00B0, size = $003A; diff --git a/doc/Makefile b/doc/Makefile index 33b5c2686..bb8f551ad 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -46,7 +46,7 @@ clean: $(RM) -r ../html ../info install: - $(if $(PREFIX),,$(error variable `PREFIX' must be set)) + $(if $(PREFIX),,$(error variable "PREFIX" must be set)) ifeq ($(wildcard ../html),../html) $(INSTALL) -d $(DESTDIR)$(htmldir) $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index f61a8a68e..648ee56db 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -32,7 +32,7 @@ more information. Binary format

The standard binary file format generated by the linker for the -Apple ][ target is an file. The default load address is $803. @@ -492,7 +492,7 @@ files show up in a directory as . ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike Windows which uses the file name's suffix (a.k.a. - extension) to specify the file type. For example, Specifying the File Type and Auxiliary Type There are two global variables provided that allow the file type @@ -603,7 +603,7 @@ url="ca65.html" name="assembler manual">. extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ - + The header file . Example A text file cannot be created with just the - standard C functions because they default to the binary type + standard C functions because they default to the binary type . } } - +

@@ -686,14 +686,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 649c6ef9f..d25aa7efe 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -32,7 +32,7 @@ more information. Binary format

The standard binary file format generated by the linker for the -enhanced Apple //e target is an file. The default load address is $803. @@ -493,7 +493,7 @@ files show up in a directory as . ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike Windows which uses the file name's suffix (a.k.a. - extension) to specify the file type. For example, Specifying the File Type and Auxiliary Type There are two global variables provided that allow the file type @@ -609,7 +609,7 @@ url="ca65.html" name="assembler manual">. extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ - + The header file . Example A text file cannot be created with just the - standard C functions because they default to the binary type + standard C functions because they default to the binary type . } } - +

@@ -692,14 +692,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/ar65.sgml b/doc/ar65.sgml index d5e91a3a3..900a0a92b 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -30,17 +30,17 @@ for the cc65 compiler. ar65 is part of this suite. The archiver is called as follows: - Usage: ar65 lib file|module ... - Operations are some of: - r Add modules - d Delete modules - t List library table - v Increase verbosity (put before other operation) - x Extract modules - V Print the archiver version + Usage: ar65 lib file|module ... + Operations are some of: + r Add modules + d Delete modules + t List library table + v Increase verbosity (put before other operation) + x Extract modules + V Print the archiver version -You may add modules to a library using the `r' command (`a' is deprecated). If the library +You may add modules to a library using the - ar65 r mysubs.lib sub1.o sub2.o + ar65 r mysubs.lib sub1.o sub2.o -This will add two modules to the library `mysubs.lib' creating the +This will add two modules to the library 'mysubs.lib' creating the library if necessary. If the library contains modules named sub1.o or sub2.o, they are replaced by the new ones. Modules names in the library are stored without the path, so, using - ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o + ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o -will verbose add two modules named `sub1.o' and `sub2.o' to the library. +will verbose add two modules named 'sub1.o' and 'sub2.o' to the library. -Deleting modules from a library is done with the `d' command. You may not +Deleting modules from a library is done with the - ar65 d mysubs.lib sub1.o + ar65 d mysubs.lib sub1.o -This will delete the module named `sub1.o' from the library, printing an +This will delete the module named 'sub1.o' from the library, printing an error if the library does not contain that module. -The `t' command prints a table of all modules in the library (`l' is deprecated). +The - ar65 tv mysubs.lib + ar65 tv mysubs.lib -Using the `x' command, you may extract modules from the library. The +Using the - ar65 x mysubs.lib sub1.o + ar65 x mysubs.lib sub1.o -The `V' command prints the version number of the assembler. If you send +The - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - - - diff --git a/doc/atari.sgml b/doc/atari.sgml index 2531c8d03..eecd1b803 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -203,6 +203,19 @@ is + +This config file allows writing multi segment binaries easily, without having to +write the header explicitly on each segment. + +It is similar to the This config file can be used to create 8K or 16K cartridges. It's suited both @@ -230,6 +243,18 @@ would need to be split in more parts and the parts to be loaded manually. To write the generated file to a cassette, a utility ( + +This config file shows how to write a binary using the ATARI (xex) file format +support on LD65, this simplifies the memory areas and allows to add new memory +areas easily without writing new headers and trailers. + +Note that the default C library includes the system-check chunk, so in this +linker configuration we suppress the importing of the header and trailer for +this chunk by defining the standard import symbols to a 0 value. For the +initialization address of the system-check chunk, the INITAD is set directly in +the configuration. + default config file ( @@ -253,12 +278,40 @@ The files generated by this config file include the load chunk. It can optionally be left out, see . + + +Similar to the Platform specific header files

Programs containing Atari specific code may use the +... + OS.savmsc = ScreenMemory; + OS.color4 = 14; // white frame + if (OS.stick0 != 15 || OS.ch != 255) // key or stick input? +... + + +Please note that memory location 762/$2FA is called "Atari specific functions

@@ -323,7 +376,7 @@ cc65 supports constructing these display lists by offering defines for the instructions. In conjunction with the "void"-variable extension of cc65, display lists can be created quite comfortable: - + ... unsigned char ScreenMemory[100]; @@ -339,12 +392,13 @@ void DisplayList = DL_CHR20x8x2, DL_BLK4, DL_CHR20x8x2, - DL_JVB + DL_JVB, + &DisplayList }; ... -POKEW(560,(unsigned int)&DisplayList); // SDLSTL +OS.sdlst = &DisplayList; ... - + Please inspect the + #include <atari_screen_charmap.h> char pcScreenMappingString[] = "Hello Atari!"; #include <atari_atascii_charmap.h> char pcAtasciiMappingString[] = "Hello Atari!"; - + delivers correct results, while - + #include <atari_screen_charmap.h> char* pcScreenMappingString = "Hello Atari!"; #include <atari_atascii_charmap.h> char* pcAtasciiMappingString = "Hello Atari!"; - + does not. @@ -417,10 +471,10 @@ For direct keyboard scanning in conjunction with e.g. the OS location "CH" (764/ all keyboard codes are available as defined values on C and assembler side. Example: - + ... while (!kbhit()); - switch (PEEK(764)) + switch (OS.ch) { case KEY_RETURN: ... @@ -430,7 +484,7 @@ Example: ... } ... - + You can find the C defines in the file " -ld65: Error: Missing memory area assignment for segment `MAINHDR' +ld65: Error: Missing memory area assignment for segment 'MAINHDR' The old "HEADER" memory description contained six bytes: $FFFF diff --git a/doc/atari2600.sgml b/doc/atari2600.sgml index 797b1e8be..36c06ad08 100644 --- a/doc/atari2600.sgml +++ b/doc/atari2600.sgml @@ -109,14 +109,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index e33c8a832..fedac4466 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -184,14 +184,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/atmos.sgml b/doc/atmos.sgml index ab7104f9d..3fd61abcf 100644 --- a/doc/atmos.sgml +++ b/doc/atmos.sgml @@ -279,14 +279,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c128.sgml b/doc/c128.sgml index 82c280ef0..1d8734fdf 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -397,14 +397,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c16.sgml b/doc/c16.sgml index 9f81c5115..462f98345 100644 --- a/doc/c16.sgml +++ b/doc/c16.sgml @@ -259,14 +259,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/c64.sgml b/doc/c64.sgml index 37ac0c146..c11867051 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -481,14 +481,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 52e9634ae..211039995 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -36,42 +36,42 @@ development: - The assembler must support macros. Macros are not essential, but they - make some things easier, especially when you use the assembler in the - backend of a compiler. - The assembler must support the newer 65C02 and 65816 CPUs. I have been - thinking about a 65816 backend for the C compiler, and even my old - a816 assembler had support for these CPUs, so this wasn't really a - problem. - The assembler must produce relocatable code. This is necessary for the - compiler support, and it is more convenient. - Conditional assembly must be supported. This is a must for bigger - projects written in assembler (like Elite128). - The assembler must support segments, and it must support more than - three segments (this is the count, most other assemblers support). - Having more than one code segments helps developing code for systems - with a divided ROM area (like the C64). - The linker must be able to resolve arbitrary expressions. It should - be able to get things like + The assembler must support macros. Macros are not essential, but they + make some things easier, especially when you use the assembler in the + backend of a compiler. + The assembler must support the newer 65C02 and 65816 CPUs. I have been + thinking about a 65816 backend for the C compiler, and even my old + a816 assembler had support for these CPUs, so this wasn't really a + problem. + The assembler must produce relocatable code. This is necessary for the + compiler support, and it is more convenient. + Conditional assembly must be supported. This is a must for bigger + projects written in assembler (like Elite128). + The assembler must support segments, and it must support more than + three segments (this is the count, most other assemblers support). + Having more than one code segments helps developing code for systems + with a divided ROM area (like the C64). + The linker must be able to resolve arbitrary expressions. It should + be able to get things like - .import S1, S2 - .export Special - Special = 2*S1 + S2/7 + .import S1, S2 + .export Special + Special = 2*S1 + S2/7 - right. - True lexical nesting for symbols. This is very convenient for larger - assembly projects. - "Cheap" local symbols without lexical nesting for those quick, late - night hacks. - I liked the idea of "options" as Anre Fachats .o65 format has it, so I - introduced the concept into the object file format use by the new cc65 - binutils. - The assembler will be a one pass assembler. There was no real need for - this decision, but I've written several multipass assemblers, and it - started to get boring. A one pass assembler needs much more elaborated - data structures, and because of that it's much more fun:-) - Non-GPLed code that may be used in any project without restrictions or - fear of "GPL infecting" other code. + right. + True lexical nesting for symbols. This is very convenient for larger + assembly projects. + "Cheap" local symbols without lexical nesting for those quick, late + night hacks. + I liked the idea of "options" as Anre Fachats .o65 format has it, so I + introduced the concept into the object file format use by the new cc65 + binutils. + The assembler will be a one pass assembler. There was no real need for + this decision, but I've written several multipass assemblers, and it + started to get boring. A one pass assembler needs much more elaborated + data structures, and because of that it's much more fun:-) + Non-GPLed code that may be used in any project without restrictions or + fear of "GPL infecting" other code.

@@ -151,7 +151,7 @@ Here is a description of all the command line options: Set the default for the CPU type. The option takes a parameter, which may be one of - 6502, 6502X, 65SC02, 65C02, 65816, sweet16, HuC6280, 4510 + 6502, 6502X, 65SC02, 65C02, 65816, sweet16, HuC6280, 4510

@@ -809,23 +809,23 @@ reference (use the n'th label in forward direction). An example will help to understand this: - : lda (ptr1),y ; #1 - cmp (ptr2),y - bne :+ ; -> #2 - tax - beq :+++ ; -> #4 - iny - bne :- ; -> #1 - inc ptr1+1 - inc ptr2+1 - bne :- ; -> #1 + : lda (ptr1),y ; #1 + cmp (ptr2),y + bne :+ ; -> #2 + tax + beq :+++ ; -> #4 + iny + bne :- ; -> #1 + inc ptr1+1 + inc ptr2+1 + bne :- ; -> #1 - : bcs :+ ; #2 -> #3 - ldx #$FF - rts + : bcs :+ ; #2 -> #3 + ldx #$FF + rts - : ldx #$01 ; #3 - : rts ; #4 + : ldx #$01 ; #3 + : rts ; #4 As you can see from the example, unnamed labels will make even short @@ -857,15 +857,15 @@ errors. Because of these problems, the general advice is, - .DEFINE two 2 - .DEFINE version "SOS V2.3" + .DEFINE two 2 + .DEFINE version "SOS V2.3" - four = two * two ; Ok - .byte version ; Ok + four = two * two ; Ok + .byte version ; Ok - .PROC ; Start local scope - two = 3 ; Will give "2 = 3" - invalid! - .ENDPROC + .PROC ; Start local scope + two = 3 ; Will give "2 = 3" - invalid! + .ENDPROC @@ -1241,17 +1241,17 @@ writable. Example: - ; Reverse Subtract with Accumulator - ; A = memory - A - .macro rsb param - .if .asize = 8 - eor #$ff - .else - eor #$ffff - .endif - sec - adc param - .endmacro + ; Reverse Subtract with Accumulator + ; A = memory - A + .macro rsb param + .if .asize = 8 + eor #$ff + .else + eor #$ffff + .endif + sec + adc param + .endmacro See also: @@ -1272,15 +1272,15 @@ writable. .macpack cpu - .if (.cpu .bitand CPU_ISET_65816) - phx - phy - .else - txa - pha - tya - pha - .endif + .if (.cpu .bitand CPU_ISET_65816) + phx + phy + .else + txa + pha + tya + pha + .endif @@ -1305,12 +1305,12 @@ writable. Example: - .macro foo arg1, arg2, arg3 - .if .paramcount <> 3 - .error "Too few parameters for macro foo" - .endif - ... - .endmacro + .macro foo arg1, arg2, arg3 + .if .paramcount <> 3 + .error "Too few parameters for macro foo" + .endif + ... + .endmacro See section . @@ -1417,7 +1417,7 @@ either a string or an expression. .endproc .proc bank_table - .addr banked_func_1 + .addr banked_func_1 .byte <.BANK (banked_func_1) .addr banked_func_2 @@ -1449,7 +1449,7 @@ either a string or an expression. As an example, the - .if .blank({arg}) + .if .blank({arg}) @@ -1465,13 +1465,13 @@ either a string or an expression. Example: - .include .concat ("myheader", ".", "inc") + .include .concat ("myheader", ".", "inc") This is the same as the command - .include "myheader.inc" + .include "myheader.inc" @@ -1483,7 +1483,7 @@ either a string or an expression. otherwise. As an example, the .IFCONST statement may be replaced by - .if .const(a + 3) + .if .const(a + 3) @@ -1513,7 +1513,7 @@ either a string or an expression. Example: - .macro makelabel arg1, arg2 + .macro makelabel arg1, arg2 .ident (.concat (arg1, arg2)): .endmacro @@ -1530,7 +1530,7 @@ either a string or an expression. Syntax: - .LEFT (<int expr>, <token list>) + .LEFT (<int expr>, <token list>) The first integer expression gives the number of tokens to extract from @@ -1545,16 +1545,16 @@ either a string or an expression. (immediate addressing mode), use something like this: - .macro ldax arg - ... - .if (.match (.left (1, {arg}), #)) + .macro ldax arg + ... + .if (.match (.left (1, {arg}), #)) - ; ldax called with immediate operand - ... + ; ldax called with immediate operand + ... - .endif - ... - .endmacro + .endif + ... + .endmacro See also the and - .MATCH(<token list #1>, <token list #2>) + .MATCH(<token list #1>, <token list #2>) Both token list may contain arbitrary tokens with the exception of the @@ -1617,16 +1617,16 @@ either a string or an expression. to check for this and print and error for invalid calls. - .macro asr arg + .macro asr arg - .if (.not .blank(arg)) .and (.not .match ({arg}, a)) - .error "Syntax error" - .endif + .if (.not .blank(arg)) .and (.not .match ({arg}, a)) + .error "Syntax error" + .endif - cmp #$80 ; Bit 7 into carry - lsr a ; Shift carry into bit 7 + cmp #$80 ; Bit 7 into carry + lsr a ; Shift carry into bit 7 - .endmacro + .endmacro The macro will only accept no arguments, or one argument that must be the @@ -1642,14 +1642,14 @@ either a string or an expression. The syntax is - .MAX (<value #1>, <value #2>) + .MAX (<value #1>, <value #2>) Example: ; Reserve space for the larger of two data blocks - savearea: .res .max (.sizeof (foo), .sizeof (bar)) + savearea: .res .max (.sizeof (foo), .sizeof (bar)) See: @@ -1663,7 +1663,7 @@ either a string or an expression. Syntax: - .MID (<int expr>, <int expr>, <token list>) + .MID (<int expr>, <int expr>, <token list>) The first integer expression gives the starting token in the list (the first @@ -1679,16 +1679,16 @@ either a string or an expression. (immediate addressing mode), use something like this: - .macro ldax arg - ... - .if (.match (.mid (0, 1, {arg}), #)) + .macro ldax arg + ... + .if (.match (.mid (0, 1, {arg}), #)) - ; ldax called with immediate operand - ... + ; ldax called with immediate operand + ... - .endif - ... - .endmacro + .endif + ... + .endmacro See also the and - .MIN (<value #1>, <value #2>) + .MIN (<value #1>, <value #2>) Example: ; Reserve space for some data, but 256 bytes maximum - savearea: .res .min (.sizeof (foo), 256) + savearea: .res .min (.sizeof (foo), 256) See: @@ -1724,7 +1724,7 @@ either a string or an expression. the statement may be replaced by - .if .referenced(a) + .if .referenced(a) See: @@ -1737,7 +1737,7 @@ either a string or an expression. Syntax: - .RIGHT (<int expr>, <token list>) + .RIGHT (<int expr>, <token list>) The first integer expression gives the number of tokens to extract from the @@ -1833,12 +1833,12 @@ either a string or an expression. Example: - .macro M Arg - ; Check if the argument string starts with '#' - .if (.strat (Arg, 0) = '#') - ... - .endif - .endmacro + .macro M Arg + ; Check if the argument string starts with '#' + .if (.strat (Arg, 0) = '#') + ... + .endif + .endmacro @@ -1873,10 +1873,10 @@ either a string or an expression. Example: - ; Emulate other assemblers: - .macro section name - .segment .string(name) - .endmacro + ; Emulate other assemblers: + .macro section name + .segment .string(name) + .endmacro @@ -1891,9 +1891,9 @@ either a string or an expression. a leading length byte. - .macro PString Arg - .byte .strlen(Arg), Arg - .endmacro + .macro PString Arg + .byte .strlen(Arg), Arg + .endmacro @@ -1913,15 +1913,15 @@ either a string or an expression. load instructions, the '#' token has to get stripped from the argument: - .macro ldax arg - .if (.match (.mid (0, 1, {arg}), #)) - ; ldax called with immediate operand - lda #<(.right (.tcount ({arg})-1, {arg})) - ldx #>(.right (.tcount ({arg})-1, {arg})) - .else - ... - .endif - .endmacro + .macro ldax arg + .if (.match (.mid (0, 1, {arg}), #)) + ; ldax called with immediate operand + lda #<(.right (.tcount ({arg})-1, {arg})) + ldx #>(.right (.tcount ({arg})-1, {arg})) + .else + ... + .endif + .endmacro @@ -1934,7 +1934,7 @@ either a string or an expression. The syntax is - .XMATCH(<token list #1>, <token list #2>) + .XMATCH(<token list #1>, <token list #2>) Both token list may contain arbitrary tokens with the exception of the @@ -1994,7 +1994,7 @@ Here's a list of all control commands and a description, what they do: Example: - .addr $0D00, $AF13, _Clear + .addr $0D00, $AF13, _Clear See: , - .align 256 + .align 256 Some unexpected behaviour might occur if there are multiple - Msg: .asciiz "Hello world" + Msg: .asciiz "Hello world" This will put the string "Hello world" followed by a binary zero into @@ -2099,7 +2099,7 @@ Here's a list of all control commands and a description, what they do: Example: - .assert * = $8000, error, "Code not at $8000" + .assert * = $8000, error, "Code not at $8000" The example assertion will check that the current location is at $8000, @@ -2131,7 +2131,7 @@ Here's a list of all control commands and a description, what they do: Example: - .autoimport + ; Switch on auto import + .autoimport + ; Switch on auto import .BANKBYTES

@@ -2145,17 +2145,17 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable - TableLookupBank: .bankbytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable + TableLookupBank: .bankbytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 - TableLookupBank: .byte ^TableItem0, ^TableItem1, ^TableItem2, ^TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupBank: .byte ^TableItem0, ^TableItem1, ^TableItem2, ^TableItem3 See also: , @@ -2169,7 +2169,7 @@ Here's a list of all control commands and a description, what they do: so this is a shortcut for - .segment "BSS" + .segment "BSS" See also the command. @@ -2183,8 +2183,8 @@ Here's a list of all control commands and a description, what they do: Example: - .byte "Hello " - .byt "world", $0D, $00 + .byte "Hello " + .byt "world", $0D, $00 @@ -2199,7 +2199,7 @@ Here's a list of all control commands and a description, what they do: Example: - .case - ; Identifiers are not case sensitive + .case - ; Identifiers are not case sensitive @@ -2224,7 +2224,7 @@ Here's a list of all control commands and a description, what they do: "CODE", so this is a shortcut for - .segment "CODE" + .segment "CODE" See also the command. @@ -2260,8 +2260,8 @@ Here's a list of all control commands and a description, what they do: Example: - .condes ModuleInit, constructor - .condes ModInit, 0, 16 + .condes ModuleInit, constructor + .condes ModInit, 0, 16 See the , - .constructor ModuleInit - .constructor ModInit, 16 + .constructor ModuleInit + .constructor ModInit, 16 See the and - .segment "DATA" + .segment "DATA" See also the command. @@ -2323,13 +2323,13 @@ Here's a list of all control commands and a description, what they do: Example: - .dbyt $1234, $4512 + .dbyt $1234, $4512 This will emit the bytes - $12 $34 $45 $12 + $12 $34 $45 $12 into the current segment in that order. @@ -2346,7 +2346,7 @@ Here's a list of all control commands and a description, what they do: Example: - .debuginfo + ; Generate debug info + .debuginfo + ; Generate debug info @@ -2387,7 +2387,7 @@ Here's a list of all control commands and a description, what they do: statement may be replaced by - .if .defined(a) + .if .defined(a) @@ -2404,7 +2404,7 @@ Here's a list of all control commands and a description, what they do: adc foo .endmacro - .if .definedmacro(add) + .if .definedmacro(add) add #$01 .else clc @@ -2434,8 +2434,8 @@ Here's a list of all control commands and a description, what they do: Example: - .destructor ModuleDone - .destructor ModDone, 16 + .destructor ModuleDone + .destructor ModDone, 16 See the and - .dword $12344512, $12FA489 + .dword $12344512, $12FA489 @@ -2595,13 +2595,13 @@ Here's a list of all control commands and a description, what they do: Example: - .if foo = 1 - ... - .elseif bar = 1 - ... - .else - .error "Must define foo or bar!" - .endif + .if foo = 1 + ... + .elseif bar = 1 + ... + .else + .error "Must define foo or bar!" + .endif See also: , @@ -2634,7 +2634,7 @@ Here's a list of all control commands and a description, what they do: Examples: - .export foo + .export foo .export bar: far .export foobar: far = foo * bar .export baz := foobar, zap: far = baz - bar @@ -2657,7 +2657,7 @@ Here's a list of all control commands and a description, what they do: Examples: - .exportzp foo, bar + .exportzp foo, bar .exportzp baz := $02 @@ -2672,7 +2672,7 @@ Here's a list of all control commands and a description, what they do: Example: - .faraddr DrawCircle, DrawRectangle, DrawHexagon + .faraddr DrawCircle, DrawRectangle, DrawHexagon See: @@ -2690,13 +2690,13 @@ Here's a list of all control commands and a description, what they do: Example: - .if foo = 1 - ... - .elseif bar = 1 - ... - .else - .fatal "Must define foo or bar!" - .endif + .if foo = 1 + ... + .elseif bar = 1 + ... + .else + .fatal "Must define foo or bar!" + .endif See also: , @@ -2713,7 +2713,7 @@ Here's a list of all control commands and a description, what they do: enabled it, so using - .FEATURE xxx + .FEATURE xxx will enable the feature until end of assembly is reached. @@ -2730,7 +2730,7 @@ Here's a list of all control commands and a description, what they do: at_in_identifiers - Accept the at character (`@') as a valid character in identifiers. The + Accept the at character ('@') as a valid character in identifiers. The at character is not allowed to start an identifier, even with this feature enabled. @@ -2765,13 +2765,13 @@ Here's a list of all control commands and a description, what they do: dollar_in_identifiers - Accept the dollar sign (`$') as a valid character in identifiers. The + Accept the dollar sign ('$') as a valid character in identifiers. The dollar character is not allowed to start an identifier, even with this feature enabled. dollar_is_pc - The dollar sign may be used as an alias for the star (`*'), which + The dollar sign may be used as an alias for the star ('*'), which gives the value of the current PC in expressions. Note: Assignment to the pseudo variable is not allowed. @@ -2789,7 +2789,7 @@ Here's a list of all control commands and a description, what they do: leading_dot_in_identifiers - Accept the dot (`.') as the first character of an identifier. This may be + Accept the dot ('.') as the first character of an identifier. This may be used for example to create macro names that start with a dot emulating control directives of other assemblers. Note however, that none of the reserved keywords built into the assembler, that starts with a dot, may be @@ -2825,12 +2825,29 @@ Here's a list of all control commands and a description, what they do: pc_assignment - Allow assignments to the PC symbol (`*' or `$' if command (which is usually not needed, so just removing the lines with the assignments may also be an option when porting code written for older assemblers). + string_escapes + + Allow C-style backslash escapes within string constants to embed + special characters. The following escapes are accepted: + + \\ backslash ($5C) + \' single quote ($27) + \" double quote ($22) + \t tab ($09) + \r carriage return ($0D) + \n newline ($0A) + \xNN ($NN) + + + Note that string escapes are converted to platform-specific characters in + the same way that other characters are converted. + ubiquitous_idents Allow the use of instructions names as names for macros and symbols. This @@ -2860,7 +2877,7 @@ Here's a list of all control commands and a description, what they do: assembler, the features - labels_without_colons, pc_assignment, loose_char_term + labels_without_colons, pc_assignment, loose_char_term may be helpful. They do not make ca65 completely compatible, so you may not @@ -2880,9 +2897,9 @@ Here's a list of all control commands and a description, what they do: The command is followed by one of the keywords - author - comment - compiler + author + comment + compiler a comma and a string. The option is written into the object file @@ -2893,9 +2910,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .fileopt comment, "Code stolen from my brother" - .fileopt compiler, "BASIC 2.0" - .fopt author, "J. R. User" + .fileopt comment, "Code stolen from my brother" + .fileopt compiler, "BASIC 2.0" + .fopt author, "J. R. User" @@ -2911,7 +2928,7 @@ Here's a list of all control commands and a description, what they do: Example: - .forceimport needthisone, needthistoo + .forceimport needthisone, needthistoo See: @@ -2928,7 +2945,7 @@ Here's a list of all control commands and a description, what they do: Example: - .global foo, bar + .global foo, bar @@ -2944,7 +2961,7 @@ Here's a list of all control commands and a description, what they do: Example: - .globalzp foo, bar + .globalzp foo, bar .HIBYTES

@@ -2957,14 +2974,14 @@ Here's a list of all control commands and a description, what they do: .lobytes $1234, $2345, $3456, $4567 - .hibytes $fedc, $edcb, $dcba, $cba9 + .hibytes $fedc, $edcb, $dcba, $cba9 which is equivalent to .byte $34, $45, $56, $67 - .byte $fe, $ed, $dc, $cb + .byte $fe, $ed, $dc, $cb Example: @@ -2972,15 +2989,15 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 See also: , @@ -3035,13 +3052,13 @@ Here's a list of all control commands and a description, what they do: Example: - .macro arg1, arg2 - .ifblank arg2 - lda #arg1 - .else - lda #arg2 - .endif - .endmacro + .macro arg1, arg2 + .ifblank arg2 + lda #arg1 + .else + lda #arg2 + .endif + .endmacro See also: @@ -3083,12 +3100,12 @@ Here's a list of all control commands and a description, what they do: Example: - .macro arg1, arg2 - lda #arg1 - .ifnblank arg2 - lda #arg2 - .endif - .endmacro + .macro arg1, arg2 + lda #arg1 + .ifnblank arg2 + lda #arg2 + .endif + .endmacro See also: @@ -3154,11 +3171,11 @@ Here's a list of all control commands and a description, what they do: Example: - .ifref ToHex ; If someone used this subroutine - ToHex: tay ; Define subroutine - lda HexTab,y - rts - .endif + .ifref ToHex ; If someone used this subroutine + ToHex: tay ; Define subroutine + lda HexTab,y + rts + .endif See also: @@ -3173,7 +3190,7 @@ Here's a list of all control commands and a description, what they do: Example: - .import foo + .import foo .import bar: zeropage @@ -3189,7 +3206,7 @@ Here's a list of all control commands and a description, what they do: Example: - .importzp foo, bar + .importzp foo, bar See: @@ -3207,14 +3224,14 @@ Here's a list of all control commands and a description, what they do: Example: - ; Include whole file - .incbin "sprites.dat" + ; Include whole file + .incbin "sprites.dat" - ; Include file starting at offset 256 - .incbin "music.dat", $100 + ; Include file starting at offset 256 + .incbin "music.dat", $100 - ; Read 100 bytes starting at offset 200 - .incbin "graphics.dat", 200, 100 + ; Read 100 bytes starting at offset 200 + .incbin "graphics.dat", 200, 100 @@ -3225,7 +3242,7 @@ Here's a list of all control commands and a description, what they do: Example: - .include "subs.inc" + .include "subs.inc" @@ -3250,8 +3267,8 @@ Here's a list of all control commands and a description, what they do: Example: - .interruptor IrqHandler - .interruptor Handler, 16 + .interruptor IrqHandler + .interruptor Handler, 16 See the command and the separate @@ -3267,12 +3284,12 @@ Here's a list of all control commands and a description, what they do: Example: - .if .not .ismnemonic(ina) - .macro ina - clc - adc #$01 - .endmacro - .endif + .if .not .ismnemonic(ina) + .macro ina + clc + adc #$01 + .endmacro + .endif @@ -3289,10 +3306,10 @@ Here's a list of all control commands and a description, what they do: Example: - .linecont + ; Allow line continuations + .linecont + ; Allow line continuations - lda \ - #$20 ; This is legal now + lda \ + #$20 ; This is legal now @@ -3310,7 +3327,7 @@ Here's a list of all control commands and a description, what they do: Example: - .list on ; Enable listing output + .list on ; Enable listing output @@ -3325,9 +3342,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .listbytes unlimited ; List all bytes - .listbytes 12 ; List the first 12 bytes - .incbin "data.bin" ; Include large binary file + .listbytes unlimited ; List all bytes + .listbytes 12 ; List the first 12 bytes + .incbin "data.bin" ; Include large binary file @@ -3341,14 +3358,14 @@ Here's a list of all control commands and a description, what they do: .lobytes $1234, $2345, $3456, $4567 - .hibytes $fedc, $edcb, $dcba, $cba9 + .hibytes $fedc, $edcb, $dcba, $cba9 which is equivalent to .byte $34, $45, $56, $67 - .byte $fe, $ed, $dc, $cb + .byte $fe, $ed, $dc, $cb Example: @@ -3356,15 +3373,15 @@ Here's a list of all control commands and a description, what they do: .define MyTable TableItem0, TableItem1, TableItem2, TableItem3 - TableLookupLo: .lobytes MyTable - TableLookupHi: .hibytes MyTable + TableLookupLo: .lobytes MyTable + TableLookupHi: .hibytes MyTable which is equivalent to TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3 - TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 + TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3 See also: , @@ -3405,15 +3422,15 @@ Here's a list of all control commands and a description, what they do: Example: - .localchar '?' + .localchar '?' - Clear: lda #$00 ; Global label - ?Loop: sta Mem,y ; Local label - dey - bne ?Loop ; Ok - rts - Sub: ... ; New global label - bne ?Loop ; ERROR: Unknown identifier! + Clear: lda #$00 ; Global label + ?Loop: sta Mem,y ; Local label + dey + bne ?Loop ; Ok + rts + Sub: ... ; New global label + bne ?Loop ; ERROR: Unknown identifier! @@ -3437,10 +3454,10 @@ Here's a list of all control commands and a description, what they do: Example: - .macpack longbranch ; Include macro package + .macpack longbranch ; Include macro package - cmp #$20 ; Set condition codes - jne Label ; Jump long on condition + cmp #$20 ; Set condition codes + jne Label ; Jump long on condition Macro packages are explained in more detail in section - .macro ldax arg ; Define macro ldax + .macro ldax arg ; Define macro ldax lda arg ldx arg+1 @@ -3487,7 +3504,7 @@ Here's a list of all control commands and a description, what they do: Example: - .org $7FF ; Emit code starting at $7FF + .org $7FF ; Emit code starting at $7FF @@ -3500,7 +3517,7 @@ Here's a list of all control commands and a description, what they do: Example: - .out "This code was written by the codebuster(tm)" + .out "This code was written by the codebuster(tm)" See also: , @@ -3552,9 +3569,9 @@ Here's a list of all control commands and a description, what they do: Examples: - .pagelength 66 ; Use 66 lines per listing page + .pagelength 66 ; Use 66 lines per listing page - .pagelength unlimited ; Unlimited page length + .pagelength unlimited ; Unlimited page length @@ -3617,15 +3634,15 @@ Here's a list of all control commands and a description, what they do: Example: - .proc Clear ; Define Clear subroutine, start new level - lda #$00 - L1: sta Mem,y ; L1 is local and does not cause a - ; duplicate symbol error if used in other - ; places - dey - bne L1 ; Reference local symbol - rts - .endproc ; Leave lexical level + .proc Clear ; Define Clear subroutine, start new level + lda #$00 + L1: sta Mem,y ; L1 is local and does not cause a + ; duplicate symbol error if used in other + ; places + dey + bne L1 ; Reference local symbol + rts + .endproc ; Leave lexical level See: / and - .macro Crypt Arg - .repeat .strlen(Arg), I - .byte .strat(Arg, I) ^ $55 - .endrep - .endmacro + .macro Crypt Arg + .repeat .strlen(Arg), I + .byte .strat(Arg, I) ^ $55 + .endrep + .endmacro See: @@ -3722,8 +3739,8 @@ Here's a list of all control commands and a description, what they do: Example: - ; Reserve 12 bytes of memory with value $AA - .res 12, $AA + ; Reserve 12 bytes of memory with value $AA + .res 12, $AA @@ -3733,7 +3750,7 @@ Here's a list of all control commands and a description, what they do: "RODATA", so this is a shortcut for - .segment "RODATA" + .segment "RODATA" The RODATA segment is a segment that is used by the compiler for @@ -3761,11 +3778,11 @@ Here's a list of all control commands and a description, what they do: Example: - .scope Error ; Start new scope named Error + .scope Error ; Start new scope named Error None = 0 ; No error File = 1 ; File error Parse = 2 ; Parse error - .endscope ; Close lexical level + .endscope ; Close lexical level ... lda #Error::File ; Use symbol from scope Error @@ -3799,7 +3816,7 @@ Here's a list of all control commands and a description, what they do: page and direct (short) addressing is possible for data in this segment. Beware: Only labels in a segment with the zeropage attribute are marked - as reachable by short addressing. The `*' (PC counter) operator will + as reachable by short addressing. The '*' (PC counter) operator will work as in other segments and will create absolute variable values. Please note that a segment cannot have two different address sizes. A @@ -3808,10 +3825,10 @@ Here's a list of all control commands and a description, what they do: Examples: - .segment "ROM2" ; Switch to ROM2 segment - .segment "ZP2": zeropage ; New direct segment - .segment "ZP2" ; Ok, will use last attribute - .segment "ZP2": absolute ; Error, redecl mismatch + .segment "ROM2" ; Switch to ROM2 segment + .segment "ZP2": zeropage ; New direct segment + .segment "ZP2" ; Ok, will use last attribute + .segment "ZP2": absolute ; Error, redecl mismatch See: , - .smart ; Be smart - .smart - ; Stop being smart + .smart ; Be smart + .smart - ; Stop being smart See: , @@ -3942,17 +3959,17 @@ Here's a list of all control commands and a description, what they do: Example: - .macro jne target - .local L1 - .ifndef target - .warning "Forward jump in jne, cannot optimize!" - beq L1 - jmp target - L1: - .else - ... - .endif - .endmacro + .macro jne target + .local L1 + .ifndef target + .warning "Forward jump in jne, cannot optimize!" + beq L1 + jmp target + L1: + .else + ... + .endif + .endmacro See also: , @@ -3968,7 +3985,7 @@ Here's a list of all control commands and a description, what they do: Example: - .word $0D00, $AF13, _Clear + .word $0D00, $AF13, _Clear @@ -4289,41 +4306,41 @@ different: - Macros defined with may not - span more than a line. You may use line continuation (see ) to spread the definition over - more than one line for increased readability, but the macro itself - may not contain an end-of-line token. + Macros defined with may not + span more than a line. You may use line continuation (see ) to spread the definition over + more than one line for increased readability, but the macro itself + may not contain an end-of-line token. - Macros defined with share - the name space with classic macros, but they are detected and replaced - at the scanner level. While classic macros may be used in every place, - where a mnemonic or other directive is allowed, style macros are allowed anywhere in a line. So - they are more versatile in some situations. + Macros defined with share + the name space with classic macros, but they are detected and replaced + at the scanner level. While classic macros may be used in every place, + where a mnemonic or other directive is allowed, style macros are allowed anywhere in a line. So + they are more versatile in some situations. - style macros may take - parameters. While classic macros may have empty parameters, this is - not true for style macros. - For this macro type, the number of actual parameters must match - exactly the number of formal parameters. + style macros may take + parameters. While classic macros may have empty parameters, this is + not true for style macros. + For this macro type, the number of actual parameters must match + exactly the number of formal parameters. - To make this possible, formal parameters are enclosed in braces when - defining the macro. If there are no parameters, the empty braces may - be omitted. + To make this possible, formal parameters are enclosed in braces when + defining the macro. If there are no parameters, the empty braces may + be omitted. - Since style macros may not - contain end-of-line tokens, there are things that cannot be done. They - may not contain several processor instructions for example. So, while - some things may be done with both macro types, each type has special - usages. The types complement each other. + Since style macros may not + contain end-of-line tokens, there are things that cannot be done. They + may not contain several processor instructions for example. So, while + some things may be done with both macro types, each type has special + usages. The types complement each other. - Parentheses work differently from C macros. - The common practice of wrapping C macros in parentheses may cause - unintended problems here, such as accidentally implying an - indirect addressing mode. While the definition of a macro requires - parentheses around its argument list, when invoked they should not be - included. + Parentheses work differently from C macros. + The common practice of wrapping C macros in parentheses may cause + unintended problems here, such as accidentally implying an + indirect addressing mode. While the definition of a macro requires + parentheses around its argument list, when invoked they should not be + included. @@ -4467,14 +4484,14 @@ Currently defined macroes are: .macro add Arg ; add without carry - clc - adc Arg - .endmacro + clc + adc Arg + .endmacro .macro sub Arg ; subtract without borrow - sec - sbc Arg - .endmacro + sec + sbc Arg + .endmacro .macro bge Arg ; branch on greater-than or equal bcs Arg @@ -4514,14 +4531,14 @@ definition for the " - .macro jeq Target - .if .def(Target) .and ((*+2)-(Target) <= 127) - beq Target - .else - bne *+5 - jmp Target - .endif - .endmacro + .macro jeq Target + .if .def(Target) .and ((*+2)-(Target) <= 127) + beq Target + .else + bne *+5 + jmp Target + .endif + .endmacro All macros expand to a short branch, if the label is already defined (back @@ -4532,7 +4549,7 @@ jump to the actual branch target. The package defines the following macros: - jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc + jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc @@ -4963,14 +4980,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cbm510.sgml b/doc/cbm510.sgml index 600a1fe90..012a7b596 100644 --- a/doc/cbm510.sgml +++ b/doc/cbm510.sgml @@ -244,7 +244,7 @@ The default drivers, Realtime clock

-The realtime clock functions use the CIA1 TOD clock. As that clock only stores +The realtime clock functions use the CIA2 TOD clock. As that clock only stores the time but not the date, the date set by - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cbm610.sgml b/doc/cbm610.sgml index 68b1060ad..37a445dd1 100644 --- a/doc/cbm610.sgml +++ b/doc/cbm610.sgml @@ -304,14 +304,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/chrcvt65.sgml b/doc/chrcvt65.sgml index 0a2fc2f76..a631a0004 100644 --- a/doc/chrcvt65.sgml +++ b/doc/chrcvt65.sgml @@ -102,14 +102,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/cl65.sgml b/doc/cl65.sgml index ef7309eec..0291f2eb3 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -44,7 +44,7 @@ Short options: -o name Name the output file -r Enable register variables -t sys Set the target system - -u sym Force an import of symbol `sym' + -u sym Force an import of symbol 'sym' -v Verbose mode -vm Verbose map file -C name Use linker config file @@ -90,7 +90,7 @@ Long options: --debug Debug mode --debug-info Add debug info --feature name Set an emulation feature - --force-import sym Force an import of symbol `sym' + --force-import sym Force an import of symbol 'sym' --help Help (this text) --include-dir dir Set a compiler include directory path --ld-args options Pass options to the linker @@ -236,14 +236,14 @@ package, it tries to be smart about several things. - If you don't give a target system on the command line, cl65 - defaults to the C64. + If you don't give a target system on the command line, cl65 + defaults to the C64. When linking, cl65 will supply the name of the library file for the target system to the linker; so, you don't have to do that. - If the final step is the linker, and the name of the output file was - not explicitly given, cl65 will use the name of the first input file + If the final step is the linker, and the name of the output file was + not explicitly given, cl65 will use the name of the first input file without the extension, provided that the name of that file has an extension. So, you don't need to give the executable name in most cases; just give the name of your "main" file as the first input file. @@ -284,24 +284,24 @@ assembler file (irq.s) will need the following separate steps to compile into an executable named morse: - cc65 -g -Oi -t c64 morse.c - ca65 -g morse.s - ca65 -g irq.s - ld65 -o morse -t c64 c64.o morse.o irq.o c64.lib + cc65 -g -Oi -t c64 morse.c + ca65 -g morse.s + ca65 -g irq.s + ld65 -o morse -t c64 c64.o morse.o irq.o c64.lib When using cl65, this is simplified to - cl65 -g -Oi morse.c irq.s + cl65 -g -Oi morse.c irq.s As a general rule, you may use cl65 instead of cc65 at most times, especially in makefiles to build object files directly from C files. Use - .c.o: - cl65 -g -Oi $< + .c.o: + cl65 -g -Oi $< to do this. @@ -323,14 +323,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/co65.sgml b/doc/co65.sgml index 06bdbe191..865aed2bb 100644 --- a/doc/co65.sgml +++ b/doc/co65.sgml @@ -285,7 +285,7 @@ segment. Use the assembler to generate an object file from the assembler output. - co65 --code-label _c64_hi c64-hi.tgi + co65 --code-label _c64_hi c64-hi.tgi ca65 c64-hi.s @@ -293,7 +293,7 @@ Next, change your C code to declare a variable that is actually the address of the driver: - extern void c64_hi[]; + extern void c64_hi[]; Instead of loading and unloading the driver, change the code to install and @@ -329,14 +329,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/coding.sgml b/doc/coding.sgml index 5897837c4..dc07c091a 100644 --- a/doc/coding.sgml +++ b/doc/coding.sgml @@ -127,17 +127,17 @@ and predecrement operators if you don't need the resulting value. That means, use - ... - ++i; - ... + ... + ++i; + ... instead of - ... - i++; - ... + ... + i++; + ... @@ -148,24 +148,24 @@ The compiler produces optimized code, if the value of a pointer is a constant. So, to access direct memory locations, use - #define VDC_STATUS 0xD601 - *(char*)VDC_STATUS = 0x01; + #define VDC_STATUS 0xD601 + *(char*)VDC_STATUS = 0x01; That will be translated to - lda #$01 - sta $D601 + lda #$01 + sta $D601 The constant value detection works also for struct pointers and arrays, if the subscript is a constant. So - #define VDC ((unsigned char*)0xD600) - #define STATUS 0x01 - VDC[STATUS] = 0x01; + #define VDC ((unsigned char*)0xD600) + #define STATUS 0x01 + VDC[STATUS] = 0x01; will also work. @@ -182,14 +182,14 @@ Initialization of local variables when declaring them gives shorter and faster code. So, use - int i = 1; + int i = 1; instead of - int i; - i = 1; + int i; + i = 1; But beware: To maximize your savings, don't mix uninitialized and initialized @@ -201,18 +201,18 @@ variables, you force the compiler to allocate space for the uninitialized variables each time, it parses an initialized one. So do this: - int i, j; - int a = 3; - int b = 0; + int i, j; + int a = 3; + int b = 0; instead of - int i; - int a = 3; - int j; - int b = 0; + int i; + int a = 3; + int j; + int b = 0; The latter will work, but will create larger and slower code. @@ -228,17 +228,17 @@ common cases. Don't use - char* a; - char b, c; - char b = *(a + c); + char* a; + char b, c; + char b = *(a + c); Use - char* a; - char b, c; - char b = a[c]; + char* a; + char b, c; + char b = a[c]; instead. diff --git a/doc/creativision.sgml b/doc/creativision.sgml index a701ae1ce..f7e5de8b1 100644 --- a/doc/creativision.sgml +++ b/doc/creativision.sgml @@ -168,14 +168,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/debugging.sgml b/doc/debugging.sgml index 7f2c3af5a..8b09db384 100644 --- a/doc/debugging.sgml +++ b/doc/debugging.sgml @@ -109,7 +109,7 @@ Load your program, then enter the monitor and use the " - ll "hello.lbl" + ll "hello.lbl" You will get lots of warnings and even a few errors. You may ignore safely all @@ -120,7 +120,7 @@ After loading the labels, they are used by VICE in the disassembler listing, and you may use them whereever you need to specify an address. Try - d ._main + d ._main as an example (note that VICE needs a leading dot before all labels, and that @@ -134,14 +134,14 @@ Load your program, then enter the monitor and use the " - sl hello.sym + sl hello.sym After loading the labels, they are used by Oricutron in the disassembler listing, and you may use them whereever you need to specify an address. Try - d ._main + d ._main as an example (note that VICE needs a leading dot before all labels, and that diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 0d294d886..bfd687b6f 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3386,7 +3386,7 @@ used in presence of a prototype. / - - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/geos.sgml b/doc/geos.sgml index cb849c389..ec9d66b1a 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -68,19 +68,19 @@ programs. The software needed: . + can get it from: . . - The VICE package contains the . + The VICE package contains the . + object files from a PC to a 1541. There's also one important ability of this + tool - it automatically un-converts .cvt files into GEOS native format on + disk image files. Check out: . . + other Commodore IEC bus drives. It can be a replacement for Star Commander if + you only want to transfer files to a disk and unconvert using GEOS program for + this purpose. Check out: .

VICE and cc65 are portable - they run on variety of platforms - DOS, Win32 and UNIX. GEOSLib only @@ -188,6 +188,14 @@ are covered by new names, but I tried to keep them in the naming convention.

This section covers the drawing package of GEOS along with text output routines. +SetNewMode +

+ +This function is intended for use by GEOS 128 only, and will exhibit undefined behavior on the +C64. It will toggle between the 40 column screen mode and the 80 column screen mode. Many C128 GEOS +programs implement a "Switch 40/80" submenu option under the SetPattern

BitOtherClip

Similar to the previous one with some extension. File and Disk @@ -1444,9 +1452,9 @@ void example = { Which will be compiled to following string of bytes: _example: - .byte 3 - .word 3 - .byte 0 + .byte 3 + .word 3 + .byte 0 As you see this way it is possible to define data of any type in any order. You must remember to cast each member to proper type. @@ -1466,21 +1474,21 @@ just in the content. Here is how a single descriptor looks like: void myMenu = { - (char)top, (char)bottom, // this is the size of the menubox - (unsigned)left, (unsigned)right, // counting all items in the current descriptor - (char)number_of_items | type_of_menu, // number of following items ORed with - // type of this menu, it can be either - // HORIZONTAL or VERTICAL if you will have also bit 6 set then menu won't be closed - // after moving mouse pointer outside the menubox. You can have at most 31 items. + (char)top, (char)bottom, // this is the size of the menubox + (unsigned)left, (unsigned)right, // counting all items in the current descriptor + (char)number_of_items | type_of_menu, // number of following items ORed with + // type of this menu, it can be either + // HORIZONTAL or VERTICAL if you will have also bit 6 set then menu won't be closed + // after moving mouse pointer outside the menubox. You can have at most 31 items. This is followed by - ... - "menuitemname", (char)item_type, (unsigned)pointer, - "nextitemname", (char)item_type, (unsigned)pointer, - ... - "lastitemname", (char)item_type, (unsigned)pointer }; - // Note that there isn't ending const dlgBoxStr example = { - DB_DEFPOS (pattern_of_shadow), - ... // commands - DB_END }; + DB_DEFPOS (pattern_of_shadow), + ... // commands + DB_END }; And the own size and position would be: const dlgBoxStr example = { - DB_SETPOS (pattern, top, bottom, left, right) - ... // commands - DB_END }; + DB_SETPOS (pattern, top, bottom, left, right) + ... // commands + DB_END }; Commands @@ -1531,9 +1539,9 @@ The next element of the - ... - DB_ICON(OK, DBI_X_0, DBI_Y_0), - ... + ... + DB_ICON(OK, DBI_X_0, DBI_Y_0), + ... Note that the position is counted from top left corner of window, not entire screen and that the 'x' position is counted in cards (8-pixel) and not in pixels. This is also true for all following commands. @@ -1547,13 +1555,13 @@ where the address of the text is stored. This is useful for information windows is variable. Consider following: char text = "foo"; - ... - r15=(unsigned)text; // in code just before call to DoDlgBox - ... - DB_VARSTR (TXT_LN_X, TXT_LN_1_Y, &r15), - ... + ... + r15=(unsigned)text; // in code just before call to DoDlgBox + ... + DB_VARSTR (TXT_LN_X, TXT_LN_1_Y, &r15), + ... -will cause the word ``foo'' to appear in the window, but you may store the pointer to any text in +will cause the word ''foo'' to appear in the window, but you may store the pointer to any text in const graphicStr example = { - MOVEPENTO(0,0), - NEWPATTERN(0), - RECTANGLETO(319,199) - GSTR_END }; + MOVEPENTO(0,0), + NEWPATTERN(0), + RECTANGLETO(319,199) + GSTR_END }; InitRam table @@ -1615,17 +1623,17 @@ It is possible to intercept events and hook into the GEOS Kernal using vectors. void_func oldVector; void NewVectorHandler(void) { - // do something and at the end call the old vector routine - oldVector(); + // do something and at the end call the old vector routine + oldVector(); } void hook_into_system(void) { - oldVector = mouseVector; - mouseVector = NewVectorHandler; + oldVector = mouseVector; + mouseVector = NewVectorHandler; } void remove_hook(void) { - mouseVector = oldVector; + mouseVector = oldVector; }

@@ -1647,10 +1655,10 @@ That little example above intercepts - diff --git a/doc/grc65.sgml b/doc/grc65.sgml index fb90fe23f..aec112f6b 100644 --- a/doc/grc65.sgml +++ b/doc/grc65.sgml @@ -381,11 +381,11 @@ HEADER APPLICATION "MyFirstApp" "Class Name" "V1.0" ; file named MyFirstApp with the Class-string "Class Name V1.0" { ; Not all fields are required, default and current values will be used. - author "Maciej Witkowiak" ; always in quotes! - info "Information text" ; always in quotes! -; date yy mm dd hh ss ; always 5 fields! -; dostype seq ; can be: PRG, SEQ, USR (only all UPPER- or lower-case) -; structure seq ; can be: SEQ, VLIR (only UPPER- or lower-case) - mode c64only ; can be: any, 40only, 80only, c64only + author "Maciej Witkowiak" ; always in quotes! + info "Information text" ; always in quotes! +; date yy mm dd hh ss ; always 5 fields! +; dostype seq ; can be: PRG, SEQ, USR (only all UPPER- or lower-case) +; structure seq ; can be: SEQ, VLIR (only UPPER- or lower-case) + mode c64only ; can be: any, 40only, 80only, c64only } diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 9cbb5aad8..3f159b39b 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -24,21 +24,21 @@ It complements the features that are built into the ca65 macroassembler: - Accept any number of segments to form an executable module. + Accept any number of segments to form an executable module. - Resolve arbitrary expressions stored in the object files. + Resolve arbitrary expressions stored in the object files. - In case of errors, use the meta information stored in the object files - to produce helpful error messages. In case of undefined symbols, - expression range errors, or symbol type mismatches, ld65 is able to - tell you the exact location in the original assembler source, where - the symbol was referenced. + In case of errors, use the meta information stored in the object files + to produce helpful error messages. In case of undefined symbols, + expression range errors, or symbol type mismatches, ld65 is able to + tell you the exact location in the original assembler source, where + the symbol was referenced. - Flexible output. The output of ld65 is highly configurable by a config - file. Some more-common platforms are supported by default configurations - that may be activated by naming the target system. The output - generation was designed with different output formats in mind, so - adding other formats shouldn't be a great problem. + Flexible output. The output of ld65 is highly configurable by a config + file. Some more-common platforms are supported by default configurations + that may be activated by naming the target system. The output + generation was designed with different output formats in mind, so + adding other formats shouldn't be a great problem. @@ -66,7 +66,7 @@ Short options: -m name Create a map file -o name Name the default output file -t sys Set the target system - -u sym Force an import of symbol `sym' + -u sym Force an import of symbol 'sym' -v Verbose mode -vm Verbose map file @@ -76,7 +76,7 @@ Long options: --dbgfile name Generate debug information --define sym=val Define a symbol --end-group End a library group - --force-import sym Force an import of symbol `sym' + --force-import sym Force an import of symbol 'sym' --help Help (this text) --lib file Link this library --lib-path path Specify a library search path @@ -487,7 +487,7 @@ There are of course more attributes for a memory section than just start and size. Start and size are mandatory attributes, that means, each memory area defined -The only other available output format is the o65 format specified by Andre +There are two other available formats, one is the o65 format specified by Andre Fachat (see the ). It is defined like this: @@ -904,7 +904,20 @@ name="6502 binary relocation format specification">). It is defined like this: } -The necessary o65 attributes are defined in a special section labeled +The other format available is the Atari (xex) segmented file format, this is +the standard format used by Atari DOS 2.0 and upward file managers in the Atari +8-bit computers, and it is defined like this: + + + FILES { + %O: format = atari; + } + + +In the Atari segmented file format, the linker will write each . @@ -925,6 +938,30 @@ has several attributes that may be defined here. } +The Atari file format has two attributes: + + + + RUNAD = symbol + + Specify a symbol as the run address of the binary, the loader will call this + address after all the file is loaded in memory. If the attribute is omitted, + no run address is included in the file. + + INITAD = memory_area : symbol + + Specify a symbol as the initialization address for the given memory area. + The binary loader will call this address just after the memory area is loaded + into memory, before continuing loading the rest of the file. + + + + + + FORMATS { + atari: runad = _start; + } + The FEATURES section

@@ -1126,14 +1163,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/library.sgml b/doc/library.sgml index b2f880051..8800c5496 100644 --- a/doc/library.sgml +++ b/doc/library.sgml @@ -228,14 +228,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/lynx.sgml b/doc/lynx.sgml index de9951b9a..0eef70535 100644 --- a/doc/lynx.sgml +++ b/doc/lynx.sgml @@ -337,14 +337,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/nes.sgml b/doc/nes.sgml index 14fcac559..3f8f74183 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -179,17 +179,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - - - diff --git a/doc/od65.sgml b/doc/od65.sgml index aab7522d9..633f7b164 100644 --- a/doc/od65.sgml +++ b/doc/od65.sgml @@ -200,15 +200,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. - diff --git a/doc/osi.sgml b/doc/osi.sgml index 081d7cfbb..eeaee4a97 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -217,14 +217,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/pet.sgml b/doc/pet.sgml index 61d6eb7a7..eb13d9fb9 100644 --- a/doc/pet.sgml +++ b/doc/pet.sgml @@ -242,14 +242,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/plus4.sgml b/doc/plus4.sgml index da9171a6f..11468bb33 100644 --- a/doc/plus4.sgml +++ b/doc/plus4.sgml @@ -260,14 +260,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 14741dd31..0739ea2f1 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -27,19 +27,19 @@ binary needs to be compiled with - Usage: sim65 [options] file [arguments] - Short options: - -h Help (this text) - -c Print amount of executed CPU cycles - -v Increase verbosity - -V Print the simulator version number - -x Exit simulator after cycles + Usage: sim65 [options] file [arguments] + Short options: + -h Help (this text) + -c Print amount of executed CPU cycles + -v Increase verbosity + -V Print the simulator version number + -x Exit simulator after cycles - Long options: - --help Help (this text) - --cycles Print amount of executed CPU cycles - --verbose Increase verbosity - --version Print the simulator version number + Long options: + --help Help (this text) + --cycles Print amount of executed CPU cycles + --verbose Increase verbosity + --version Print the simulator version number @@ -89,7 +89,7 @@ Example output for the command sim65 --verbose --verbose samples/gunzip65 -Loaded `samples/gunzip65' at $0200-$151F +Loaded 'samples/gunzip65' at $0200-$151F PVWrite ($0001, $13C9, $000F) GZIP file name:PVWrite ($0001, $151F, $0001) @@ -120,14 +120,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/smc.sgml b/doc/smc.sgml index aec0d3d0b..e277c5008 100644 --- a/doc/smc.sgml +++ b/doc/smc.sgml @@ -470,7 +470,7 @@ SMC instructions. Example: - SMC_OperateOnValue ASL, LoadMask ; shift mask to left + SMC_OperateOnValue ASL, LoadMask ; shift mask to left ... SMC LoadMask, { LDA #$20 } @@ -555,14 +555,14 @@ allowing reuse of some instructions. 5: SMC StoreAccuFirstSection, { sta SMC_AbsAdr, Y } 6: ... 7: RestoreCodeBranchBaseAdr: - 8: SMC FirstIncHighByte, { SMC_OperateOnHighByte inc, StoreAccuFirstSection } ; code will be overwritten to 'beq RestoreCode' (*) + 8: SMC FirstIncHighByte, { SMC_OperateOnHighByte inc, StoreAccuFirstSection } ; code will be overwritten to 'beq RestoreCode' (*) 9: ... -10: SMC_TransferOpcode FirstIncHighByte, OPC_BEQ , x ; change code marked above with (*) -11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative address to 'RestoreCode' +10: SMC_TransferOpcode FirstIncHighByte, OPC_BEQ , x ; change code marked above with (*) +11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative address to 'RestoreCode' 12: ... 13: restoreCode: -14: SMC_TransferOpcode FirstIncHighByte, OPC_INC_abs , x ; restore original code... -15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of address) +14: SMC_TransferOpcode FirstIncHighByte, OPC_INC_abs , x ; restore original code... +15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of address) 16: ... diff --git a/doc/sp65.sgml b/doc/sp65.sgml index 82b308025..255d7a552 100644 --- a/doc/sp65.sgml +++ b/doc/sp65.sgml @@ -403,14 +403,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 641a7e807..2570cfb9c 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -148,14 +148,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index 8d8aa23d2..e52b183d0 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -16,9 +16,9 @@ An overview over the Telestrat (Telemon 2.4 & Telemon 3.x : http://orix.oric.org Overview

-This file contains an overview of the Telestrat runtime system as it comes with the -cc65 C compiler. It describes the memory layout, Telestrat-specific header files, -available drivers, and any pitfalls specific to that platform. +This file contains an overview of the Telestrat runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Telestrat-specific +header files, available drivers, and any pitfalls specific to that platform. Please note that Telestrat-specific functions are just mentioned here, they are described in detail in the separate . Even functions marked as "platform dependent" may be available on more than one platform. Please see the function reference for more information. +Oric Telestrat is the last Oric computer (Released in 1986, mainly in France). +This computer is an Atmos with extra hardware: RS232, cardridge(banking system), +joysticks (2 ports) or mouse (on joystick port), FDC. + +Video chip, CPU, keyboard management, tape hardware are the same than Atmos. + +Telestrat can start in Atmos mode with Atmos Cardridge (which is only the atmos +Basic 1.1 ROM). + +Telestrat can start in Sedoric (Atmos OS) and Atmos mode with Stratoric Cardridge. +This Cardridge has 3 banks of 16KB of rom with: + +a Sedoric ROM. +a Basic 1.1 ROM (Atmos). +a Basic 1.0 ROM (Oric-1). + + +The main Telestrat's configuration is the Telemon/Hyperbasic Cardridge inserted +with Stratsed in floppy drive. + +Anyway, there is no way to load a tape file in Telemon/Hyperbasic mode without +alternative program. + +There is also no software to write a Stratsed dsk file on PC. + +This Telestrat target build an Orix binary file. But, in the future, it will be possible +to build a Stratsed disk. Orix uses the same systems calls than Telemon mode. + +That is why if you need to do software for telestrat target, you have the choice to: + +use cc65 Atmos target and start Telestrat in Atmos mode: A tape file is required. +use cc65 Atmos target and start Telestrat in Stratoric mode: A dsk file or tape file is required. +use cc65 Telestrat target and start Telestrat in Orix mode (see ). +use cc65 Telestrat target, remove Orix header from binary, code a dsk tool for Stratsed, +add Stratsed header on your binary,insert your binary on floppy disk (this solution will be possible is the future). + + +Telestrat (from cardridge) can handle 8 banks (from $C000 to $FFFF): Bank 0 is the overlay ram. Others banks can be ROM or RAM. + Binary format

The standard binary output format generated the linker for the Telestrat target is a machine language program with a 20 bytes header described +name="here" url="http://orix.oric.org/orix-header/"> This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine +in Telemon, there is no way to load a binary easily. -Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. +Stratsed (the Telestrat operating system) handles files management. Stratsed +is loaded to memory from floppy disk. Stratsed vector are declared in asminc/telestrat.inc. +But, reverse engineering is required to find how theses vectors works. Please, note that +Stratsed is located in overlay memory (bank 0) There is no tool to insert a binary in a Stratsed floppy disk. @@ -44,7 +88,9 @@ The only way to load a binary (for Telemon 2.4) is to: remove the 20 bytes header download -use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts) +use Floppybuilder in OSDK to insert the binary with the tool (please read +FloppyBuilder manual to learn how to insert your binary and how to start Microdisc boot sector +when Telestrat starts) Please note also, that the binary converted into TAP file, will not produce @@ -58,7 +104,7 @@ If you know the Stratsed disk format, please contact the author of this doc. In the standard setup, cc65-generated programs use the memory from $0801 to $9800; so, nearly 37K of memory (including the stack) is -available. ROM calls are possible without further precautions. +available. ROM calls are possible with BRK feature. Special locations: @@ -107,6 +153,14 @@ structures; accessing the struct fields will access the chip registers. Access to the VIA (Versatile Interface Adapter) chip is available via the + Access to the VIA2 (Versatile Interface Adapter) chip is available via the + + Access to the 6551 ACIA chip is available via the +

@@ -114,14 +168,15 @@ structures; accessing the struct fields will access the chip registers. TGI

-TGI drivers is available on Oric Telestrat with some functions : +TGI drivers is available on Oric Telestrat with some functions: -tgi_done -tgi_install -tgi_init tgi_clear +tgi_done +tgi_init +tgi_install tgi_line +tgi_outtext tgi_setpixel @@ -129,19 +184,26 @@ TGI drivers is available on Oric Telestrat with some functions : Extended memory drivers

No extended memory drivers are currently available for the Telestrat. - +This feature could be done because telestrat can manage RAM inserted in his +port cardridge. Joystick drivers

-telemon 2.4 & 3.0 manages joysticks but it had been handled yet. +Telemon 2.4 & 3.0 manages joysticks but it had been handled yet. This means that +joysticks driver could be written easily. + +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. Mouse drivers

Telestrat manages also mouse, but it had been no handled yet in this version. +Telestrat mouse is really difficult to find. RS232 device drivers

-Telestrat has a RS232 port, but it's not usable in cc65. +Telestrat has a RS232 port, but it's not usable in cc65. It is possible to use +RS232 port with Telemon calls (see XSOUT primitive for example) Limitations

@@ -150,9 +212,7 @@ Telestrat has a RS232 port, but it's not usable in cc65. 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, -Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, -fclose). +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). fclose @@ -176,14 +236,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/doc/using-make.sgml b/doc/using-make.sgml index 7986e1dc9..e324b7484 100644 --- a/doc/using-make.sgml +++ b/doc/using-make.sgml @@ -86,8 +86,8 @@ clean: Invoking the sample Makefile

@@ -119,7 +119,7 @@ The recommended way to use GNU Make on Windows is to install it as part of a Cygwin environment. For more information see the Cygwin home page: - + If however installing Cygwin shouldn't be an option for one or the other reason then the sample Makefile may be invoked from the Windows Command Prompt (cmd.exe) by downloading the following programs: @@ -132,17 +132,17 @@ by downloading the following programs: Target-specific Variable Values

- + The very limited resources of the cc65 target machines now and then require manual optimization of the build process by compiling individual source files with different compiler options. GNU Make offers -perfectly suited for doing so. For example placing the code of the two modules +perfectly suited for doing so. For example placing the code of the two modules foo.o bar.o: CFLAGS += --code-name FOOBAR - + diff --git a/doc/vic20.sgml b/doc/vic20.sgml index 6f98c6920..e292e0a1a 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -264,14 +264,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 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. - Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - This notice may not be removed or altered from any source - distribution. + 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. + Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + This notice may not be removed or altered from any source + distribution. diff --git a/include/6502.h b/include/6502.h index 642a608a8..4a27b706e 100644 --- a/include/6502.h +++ b/include/6502.h @@ -55,6 +55,7 @@ typedef unsigned size_t; #define CPU_65CE02 5 #define CPU_HUC6280 6 #define CPU_2A0x 7 +#define CPU_45GS02 8 unsigned char getcpu (void); /* Detect the CPU the program is running on */ diff --git a/include/_antic.h b/include/_antic.h index 2aac3fccf..717f7f820 100644 --- a/include/_antic.h +++ b/include/_antic.h @@ -5,9 +5,20 @@ /* Internal include file, do not use directly */ /* */ /* */ +/* "ANTIC, Alphanumeric Television Interface Controller, is responsible for */ +/* the generation of playfield graphics which is delivered as a datastream */ +/* to the related CTIA/GTIA chip. The CTIA/GTIA provides the coloring of the */ +/* playfield graphics, and is responsible for adding overlaid sprite */ +/* (referred to as "Player/Missile graphics" by Atari). Atari advertised it */ +/* as a true microprocessor, in that it has an instruction set to run */ +/* programs (called display lists) to process data. ANTIC has no capacity */ +/* for writing back computed values to memory, it merely reads data from */ +/* memory and processes it for output to the screen, therefore it is not */ +/* Turing complete." - Wikipedia article on "ANTIC" (with edits) */ /* */ /* (C) 2000 Freddy Offenga */ /* 24-Jan-2011: Christian Krueger: Added defines for Antic instruction set */ +/* 2019-01-16: Bill Kendrick : More defines for registers */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -33,66 +44,211 @@ #ifndef __ANTIC_H #define __ANTIC_H -/* Define a structure with the antic register offsets */ +/*****************************************************************************/ +/* Define a structure with the ANTIC coprocessor's register offsets */ +/*****************************************************************************/ + struct __antic { - unsigned char dmactl; /* direct memory access control */ - unsigned char chactl; /* character mode control */ + unsigned char dmactl; /* (W) direct memory access control */ + unsigned char chactl; /* (W) character mode control */ unsigned char dlistl; /* display list pointer low-byte */ unsigned char dlisth; /* display list pointer high-byte */ - unsigned char hscrol; /* horizontal scroll enable */ - unsigned char vscrol; /* vertical scroll enable */ + unsigned char hscrol; /* (W) horizontal scroll enable */ + unsigned char vscrol; /* (W) vertical scroll enable */ unsigned char unuse0; /* unused */ - unsigned char pmbase; /* msb of p/m base address */ + unsigned char pmbase; /* (W) msb of p/m base address (for when DMACTL has player and/or missile DMA enabled) */ unsigned char unuse1; /* unused */ - unsigned char chbase; /* character base address */ - unsigned char wsync; /* wait for horizontal synchronization */ - unsigned char vcount; /* vertical line counter */ - unsigned char penh; /* light pen horizontal position */ - unsigned char penv; /* light pen vertical position */ - unsigned char nmien; /* non-maskable interrupt enable */ - unsigned char nmires; /* nmi reset/status */ + unsigned char chbase; /* (W) msb of character set base address */ + unsigned char wsync; /* (W) wait for horizontal synchronization */ + unsigned char vcount; /* (R) vertical line counter */ + unsigned char penh; /* (R) light pen horizontal position */ + unsigned char penv; /* (R) light pen vertical position */ + unsigned char nmien; /* (W) non-maskable interrupt enable */ + union { + /* (W) ("NMIRES") nmi reset -- clears the interrupt request register; + ** resets all of the NMI status together + */ + unsigned char nmires; + + /* (R) ("NMIST") nmi status -- holds cause for the NMI interrupt */ + unsigned char nmist; + }; }; -/* antic instruction set */ +/*****************************************************************************/ +/* DMACTL register options */ +/*****************************************************************************/ -/* absolute instructions (non mode lines) */ +/* Initialized to 0x22: DMA fetch, normal playfield, no PMG DMA, double-line PMGs */ + +/* Playfield modes: */ +#define DMACTL_PLAYFIELD_NONE 0x00 +#define DMACTL_PLAYFIELD_NARROW 0x01 /* e.g., 32 bytes per scanline with thick borders */ +#define DMACTL_PLAYFIELD_NORMAL 0x02 /* e.g., 40 bytes per scanline with normal borders */ +#define DMACTL_PLAYFIELD_WIDE 0x03 /* e.g., 48 bytes per scanline with no borders (overscan) */ + +/* Other options: */ + +/* If not set, GTIA's GRAFP0 thru GRAFP3, and/or GRAFM registers are used for +** player & missile shapes, respectively. (Modify the registers during the horizontal blank +** (Display List Interrupt), a la "racing the beam" on an Atari VCS/2600, ) +** if set, ANTIC's PMBASE will be used to fetch shapes from memory via DMA. +*/ +#define DMACTL_DMA_MISSILES 0x04 +#define DMACTL_DMA_PLAYERS 0x08 + +/* Unless set, PMGs (as fetched via DMA) will be double-scanline resolution */ +#define DMACTL_PMG_SINGLELINE 0x10 + +/* Unless set, ANTIC operation is disabled, since it cannot fetch +** Display List instructions +*/ +#define DMACTL_DMA_FETCH 0x20 + + +/*****************************************************************************/ +/* CHACTL register options */ +/*****************************************************************************/ + +/* Initialized to 2 (CHACTL_CHAR_NORMAL | CHACTL_INV_PRESENT) */ + +/* Inverted (upside-down) characters */ +#define CHACTL_CHAR_NORMAL 0x00 +#define CHACTL_CHAR_INVERTED 0x04 + +/* Inverse (reverse-video) characters */ +#define CHACTL_INV_TRANS 0x00 /* chars with high-bit shown */ +#define CHACTL_INV_OPAQUE 0x01 /* chars with high-bit appear as space */ +#define CHACTL_INV_PRESENT 0x02 /* chars with high-bit are reverse-video */ + + +/*****************************************************************************/ +/* Values for NMIEN (enabling interrupts) & NMIST (cause for the interrupt) */ +/*****************************************************************************/ + +/* Display List Interrupts +** Called on a modeline when "DL_DLI" bit is set the ANTIC instruction, +** and jumps through VDSLST vector. +*/ +#define NMIEN_DLI 0x80 + +/* Vertical Blank Interrupt +** Called during every vertical blank; see SYSVBV, VVBLKI, CRITIC, and VVBLKD, +** as well as the SETVBV routine. +*/ +#define NMIEN_VBI 0x40 + +/* [Reset] key pressed */ +#define NMIEN_RESET 0x20 + + +/*****************************************************************************/ +/* ANTIC instruction set */ +/*****************************************************************************/ + +/* Absolute instructions (non mode lines) */ #define DL_JMP ((unsigned char) 1) #define DL_JVB ((unsigned char) 65) -#define DL_BLK1 ((unsigned char) 0) -#define DL_BLK2 ((unsigned char) 16) -#define DL_BLK3 ((unsigned char) 32) +#define DL_BLK1 ((unsigned char) 0) /* 1 blank scanline */ +#define DL_BLK2 ((unsigned char) 16) /* 2 blank scanlines */ +#define DL_BLK3 ((unsigned char) 32) /* ...etc. */ #define DL_BLK4 ((unsigned char) 48) #define DL_BLK5 ((unsigned char) 64) #define DL_BLK6 ((unsigned char) 80) #define DL_BLK7 ((unsigned char) 96) #define DL_BLK8 ((unsigned char) 112) -/* absolute instructions (mode lines) */ -#define DL_CHR40x8x1 ((unsigned char) 2) /* monochrome, 40 character & 8 scanlines per mode line (GR. 0) */ -#define DL_CHR40x10x1 ((unsigned char) 3) /* monochrome, 40 character & 10 scanlines per mode line */ -#define DL_CHR40x8x4 ((unsigned char) 4) /* colour, 40 character & 8 scanlines per mode line (GR. 12) */ -#define DL_CHR40x16x4 ((unsigned char) 5) /* colour, 40 character & 16 scanlines per mode line (GR. 13) */ -#define DL_CHR20x8x2 ((unsigned char) 6) /* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */ -#define DL_CHR20x16x2 ((unsigned char) 7) /* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */ -#define DL_MAP40x8x4 ((unsigned char) 8) /* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */ -#define DL_MAP80x4x2 ((unsigned char) 9) /* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */ -#define DL_MAP80x4x4 ((unsigned char) 10) /* colour, 80 pixel & 4 scanlines per mode line (GR.5) */ -#define DL_MAP160x2x2 ((unsigned char) 11) /* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */ -#define DL_MAP160x1x2 ((unsigned char) 12) /* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */ -#define DL_MAP160x2x4 ((unsigned char) 13) /* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */ -#define DL_MAP160x1x4 ((unsigned char) 14) /* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */ -#define DL_MAP320x1x1 ((unsigned char) 15) /* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */ +/* Absolute instructions (mode lines) */ -/* modifiers on mode lines */ -#define DL_HSCROL(x) ((unsigned char)((x) | 16)) -#define DL_VSCROL(x) ((unsigned char)((x) | 32)) -#define DL_LMS(x) ((unsigned char)((x) | 64)) +/* Note: Actual width varies (e.g., 40 vs 32 vs 48) depending on +** normal vs narrow vs wide (overscan) playfield setting; see DMACTL +*/ + +/* Character modes (text, tile graphics, etc.) */ + +/* monochrome, 40 character & 8 scanlines per mode line (aka Atari BASIC GRAPHICS 0 via OS's CIO routines) */ +#define DL_CHR40x8x1 ((unsigned char) 2) + +/* monochrome, 40 character & 10 scanlines per mode line (like GR. 0, with descenders) */ +#define DL_CHR40x10x1 ((unsigned char) 3) + +/* colour, 40 character & 8 scanlines per mode line (GR. 12) */ +#define DL_CHR40x8x4 ((unsigned char) 4) + +/* colour, 40 character & 16 scanlines per mode line (GR. 13) */ +#define DL_CHR40x16x4 ((unsigned char) 5) + +/* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */ +#define DL_CHR20x8x2 ((unsigned char) 6) + +/* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */ +#define DL_CHR20x16x2 ((unsigned char) 7) + + +/* Bitmap modes */ + +/* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */ +#define DL_MAP40x8x4 ((unsigned char) 8) + +/* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */ +#define DL_MAP80x4x2 ((unsigned char) 9) + +/* colour, 80 pixel & 4 scanlines per mode line (GR.5) */ +#define DL_MAP80x4x4 ((unsigned char) 10) + +/* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */ +#define DL_MAP160x2x2 ((unsigned char) 11) + +/* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */ +#define DL_MAP160x1x2 ((unsigned char) 12) + +/* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */ +#define DL_MAP160x2x4 ((unsigned char) 13) + +/* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */ +#define DL_MAP160x1x4 ((unsigned char) 14) + +/* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */ +#define DL_MAP320x1x1 ((unsigned char) 15) + + +/* Equivalents, for people familiar with Atari 8-bit OS */ + +#define DL_GRAPHICS0 DL_CHR40x8x1 +#define DL_GRAPHICS1 DL_CHR20x8x2 +#define DL_GRAPHICS2 DL_CHR20x16x2 +#define DL_GRAPHICS3 DL_MAP40x8x4 +#define DL_GRAPHICS4 DL_MAP80x4x2 +#define DL_GRAPHICS5 DL_MAP80x4x4 +#define DL_GRAPHICS6 DL_MAP160x2x2 +#define DL_GRAPHICS7 DL_MAP160x2x4 +#define DL_GRAPHICS8 DL_MAP320x1x1 +#define DL_GRAPHICS9 DL_MAP320x1x1 /* N.B.: GRAPHICS 9, 10, and 11 also involve GTIA's PRIOR register */ +#define DL_GRAPHICS10 DL_MAP320x1x1 +#define DL_GRAPHICS11 DL_MAP320x1x1 +#define DL_GRAPHICS12 DL_CHR40x8x4 /* N.B.: Atari 400/800 OS didn't have GRAPHICS 12 or 13 */ +#define DL_GRAPHICS13 DL_CHR40x16x4 +#define DL_GRAPHICS14 DL_MAP160x1x2 +#define DL_GRAPHICS15 DL_MAP160x1x4 + +/* Atari 400/800 OS didn't have GRAPHICS 14 or 15, so they were known by "6+" and "7+" */ +#define DL_GRAPHICS6PLUS DL_GRAPHICS14 +#define DL_GRAPHICS7PLUS DL_GRAPHICS15 + +/* Neither Atari 400/800 nor XL OS supported 10-scanline (descenders) text mode via CIO */ +#define DL_GRAPHICS0_DESCENDERS DL_CHR40x10x1 + +/* Modifiers to mode lines */ +#define DL_HSCROL(x) ((unsigned char)((x) | 16)) /* enable smooth horizontal scrolling on this line; see HSCROL */ +#define DL_VSCROL(x) ((unsigned char)((x) | 32)) /* enable smooth vertical scrolling on this line; see VSCROL */ +#define DL_LMS(x) ((unsigned char)((x) | 64)) /* Load Memory Scan (next two bytes must be the LSB/MSB of the data to load) */ + +/* General modifier */ +#define DL_DLI(x) ((unsigned char)((x) | 128)) /* enable Display List Interrupt on this mode line */ -/* general modifier */ -#define DL_DLI(x) ((unsigned char)((x) | 128)) /* End of _antic.h */ #endif /* #ifndef __ANTIC_H */ diff --git a/include/_atarios.h b/include/_atarios.h new file mode 100644 index 000000000..c15a99439 --- /dev/null +++ b/include/_atarios.h @@ -0,0 +1,660 @@ +/*****************************************************************************/ +/* */ +/* _atarios.h */ +/* */ +/* Internal include file, do not use directly */ +/* */ +/* */ +/* 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 __ATARIOS_H +#define __ATARIOS_H + + +/* IOCB Command Codes */ + +#define IOCB_OPEN 0x03 /* open */ +#define IOCB_GETREC 0x05 /* get record */ +#define IOCB_GETCHR 0x07 /* get character(s) */ +#define IOCB_PUTREC 0x09 /* put record */ +#define IOCB_PUTCHR 0x0B /* put character(s) */ +#define IOCB_CLOSE 0x0C /* close */ +#define IOCB_STATIS 0x0D /* status */ +#define IOCB_SPECIL 0x0E /* special */ +#define IOCB_DRAWLN 0x11 /* draw line */ +#define IOCB_FILLIN 0x12 /* draw line with right fill */ +#define IOCB_RENAME 0x20 /* rename disk file */ +#define IOCB_DELETE 0x21 /* delete disk file */ +#define IOCB_LOCKFL 0x23 /* lock file (set to read-only) */ +#define IOCB_UNLOCK 0x24 /* unlock file */ +#define IOCB_POINT 0x25 /* point sector */ +#define IOCB_NOTE 0x26 /* note sector */ +#define IOCB_GETFL 0x27 /* get file length */ +#define IOCB_CHDIR_MYDOS 0x29 /* change directory (MyDOS) */ +#define IOCB_MKDIR 0x2A /* make directory (MyDOS/SpartaDOS) */ +#define IOCB_RMDIR 0x2B /* remove directory (SpartaDOS) */ +#define IOCB_CHDIR_SPDOS 0x2C /* change directory (SpartaDOS) */ +#define IOCB_GETCWD 0x30 /* get current directory (MyDOS/SpartaDOS) */ +#define IOCB_FORMAT 0xFE /* format */ + + +/* Device control block */ + +struct __dcb { + unsigned char ddevic; /* device id */ + unsigned char dunit; /* unit number */ + unsigned char dcomnd; /* command */ + unsigned char dstats; /* command type / status return */ + void *dbuf; /* pointer to buffer */ + unsigned char dtimlo; /* device timeout in seconds */ + unsigned char dunuse; /* - unused - */ + unsigned int dbyt; /* # of bytes to transfer */ + union { + struct { + unsigned char daux1; /* 1st command auxiliary byte */ + unsigned char daux2; /* 2nd command auxiliary byte */ + }; + unsigned int daux; /* auxiliary as word */ + }; +}; + +typedef struct __dcb dcb_t; + + +/* I/O control block */ + +struct __iocb { + unsigned char handler; /* handler index number (0xff free) */ + unsigned char drive; /* device number (drive) */ + unsigned char command; /* command */ + unsigned char status; /* status of last operation */ + void* buffer; /* pointer to buffer */ + void* put_byte; /* pointer to device's PUT BYTE routine */ + unsigned int buflen; /* length of buffer */ + unsigned char aux1; /* 1st auxiliary byte */ + unsigned char aux2; /* 2nd auxiliary byte */ + unsigned char aux3; /* 3rd auxiliary byte */ + unsigned char aux4; /* 4th auxiliary byte */ + unsigned char aux5; /* 5th auxiliary byte */ + unsigned char spare; /* spare byte */ +}; + +typedef struct __iocb iocb_t; + + +/* DOS 2.x zeropage variables */ + +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 */ +}; + +typedef struct __dos2x dos2x_t; + + +/* A single device handler formed by it's routines */ + +struct __devhdl { + void *open; /* address of OPEN routine -1 */ + void *close; /* address of CLOSE routine -1 */ + void *get; /* address of GET BYTE routine -1 */ + void *put; /* address of PUT BYTE routine -1 */ + void *status; /* address of GET STATUS routine -1 */ + void *special; /* address od SPECIAL routine -1 */ + void (*init)(void); /* init routine (JMP INIT) */ + void *reserved; /* unused */ +}; + +typedef struct __devhdl devhdl_t; + + +/* List of device handlers, as managed in HATABS */ + +struct __hatabs { + unsigned char id; /* ATASCII code of handler e.g. 'C','D','E','K','P','S','R' */ + devhdl_t* devhdl; /* Pointer to routines of device */ +}; + +typedef struct __hatabs hatabs_t; + + +/* Floating point register */ + +struct __fpreg { +#ifdef OS_REV2 + unsigned char fr; + unsigned char frm[5]; /* 5-byte register mantissa */ +#else + unsigned char fr[6]; /* 6 bytes for single register */ +#endif +}; + +typedef struct __fpreg fpreg_t; + +enum { /* enum for access of floating point registers */ + FPIDX_R0 = 0, /* (to use as index) */ + FPIDX_RE = 1, + FPIDX_R1 = 2, + FPIDX_R2 = 3 +}; + + +/* Define a structure with atari os register offsets */ + +struct __os { + + // --- Zero-Page --- + +#ifdef OSA + unsigned char* linzbs; // = $00/$01 LINBUG RAM (WILL BE REPLACED BY MONITOR RAM) +#else + unsigned char linflg; // = $00 LNBUG FLAG (0 = NOT LNBUG) + unsigned char ngflag; // = $01 MEMORY STATUS (0 = FAILURE) +#endif + unsigned char* casini; // = $02/$03 CASSETTE INIT LOCATION + unsigned char* ramlo; // = $04/$05 RAM POINTER FOR MEMORY TEST + +#ifdef OSA + unsigned char tramsz; // = $06 FLAG FOR LEFT CARTRIDGE + unsigned char tstdat; // = $07 FLAG FOR RIGHT CARTRIDGE +#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 + + unsigned char warmst; // = $08 WARM START 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 + + // Cleared upon Coldstart or Warmstart + + unsigned char pokmsk; // = $10 SYSTEM MASK FOR POKEY IRQ ENABLE + unsigned char brkkey; // = $11 BREAK KEY FLAG + unsigned char rtclok[3]; // = $12-$14 REAL TIME CLOCK (IN 16 MSEC UNITS) + unsigned char* bufadr; // = $15/$16 INDIRECT BUFFER ADDRESS REGISTER + 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 + 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 + unsigned char abufpt[4]; // = $1C-$1F ACMI BUFFER POINTER AREA +#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 + unsigned char cretry; // = $36 NUMBER OF COMMAND FRAME RETRIES + unsigned char dretry; // = $37 NUMBER OF DEVICE RETRIES +#else + unsigned int ltemp; // = $36/$37 LOADER TEMPORARY +#endif + unsigned char bufrfl; // = $38 DATA BUFFER FULL FLAG + unsigned char recvdn; // = $39 RECEIVE DONE FLAG + unsigned char xmtdon; // = $3A TRANSMISSION DONE FLAG + unsigned char chksnt; // = $3B CHECKSUM SENT FLAG + unsigned char nocksm; // = $3C NO CHECKSUM FOLLOWS DATA FLAG + 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 + unsigned char ckey; // = $4A FLAG SET WHEN GAME START PRESSED + unsigned char cassbt; // = $4B CASSETTE BOOT FLAG +#else + void* zchain; // = $4A/$4B HANDLER LINKAGE CHAIN POINTER +#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) + unsigned char rmargn; // = $53 RIGHT MARGIN (NORMALLY 39 IF NO XEP80 IS USED) + unsigned char rowcrs; // = $54 1CURSOR ROW + unsigned int colcrs; // = $55/$56 CURSOR COLUMN + unsigned char dindex; // = $57 DISPLAY MODE + unsigned char* savmsc; // = $58/$59 SAVED MEMORY SCAN COUNTER + unsigned char oldrow; // = $5A PRIOR ROW + 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 + unsigned char newrow; // = $60 POINT DRAW GOES TO + unsigned int newcol; // = $61/$62 COLUMN DRAW GOES TO +#else + unsigned char* fkdef; // = $60/$61 FUNCTION KEY DEFINITION TABLE + unsigned char palnts; // = $62 PAL/NTSC INDICATOR (0 // = NTSC) +#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 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 + unsigned char colinc; // = $7A COLINC +#else + unsigned char* keydef; // = $79/$7A 2-BYTE KEY DEFINITION TABLE ADDRESS +#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 + unsigned char eexp; // = $ED VALUE OF EXP +#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 + 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 + unsigned char cix; // = $F2 CURRENT INPUT INDEX + 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 { + 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 + + // --- Page 1 --- + + unsigned char stack[0x100]; // STACK + + // --- Page 2 --- + + void (*vdslst)(void); // = $0200/$0201 DISPLAY LIST NMI VECTOR + void (*vprced)(void); // = $0202/$0203 PROCEED LINE IRQ VECTOR + void (*vinter)(void); // = $0204/$0205 INTERRUPT LINE IRQ VECTOR + void (*vbreak)(void); // = $0206/$0207 SOFTWARE BREAK (00) INSTRUCTION IRQ VECTOR + void (*vkeybd)(void); // = $0208/$0209 POKEY KEYBOARD IRQ VECTOR + void (*vserin)(void); // = $020A/$020B POKEY SERIAL INPUT READY IRQ + void (*vseror)(void); // = $020C/$020D POKEY SERIAL OUTPUT READY IRQ + void (*vseroc)(void); // = $020E/$020F POKEY SERIAL OUTPUT COMPLETE IRQ + void (*vtimr1)(void); // = $0210/$0201 POKEY TIMER 1 IRQ + void (*vtimr2)(void); // = $0212/$0203 POKEY TIMER 2 IRQ + void (*vtimr4)(void); // = $0214/$0205 POKEY TIMER 4 IRQ + void (*vimirq)(void); // = $0216/$0207 IMMEDIATE IRQ VECTOR + unsigned int cdtmv1; // = $0218/$0210 COUNT DOWN TIMER 1 + unsigned int cdtmv2; // = $021A/$021B COUNT DOWN TIMER 2 + unsigned int cdtmv3; // = $021C/$021D COUNT DOWN TIMER 3 + unsigned int cdtmv4; // = $021E/$021F COUNT DOWN TIMER 4 + unsigned int cdtmv5; // = $0220/$0221 COUNT DOWN TIMER 5 + void (*vvblki)(void); // = $0222/$0223 IMMEDIATE VERTICAL BLANK NMI VECTOR + void (*vvblkd)(void); // = $0224/$0224 DEFERRED VERTICAL BLANK NMI VECTOR + void (*cdtma1)(void); // = $0226/$0227 COUNT DOWN TIMER 1 JSR ADDRESS + void (*cdtma2)(void); // = $0228/$0229 COUNT DOWN TIMER 2 JSR ADDRESS + unsigned char cdtmf3; // = $022A COUNT DOWN TIMER 3 FLAG + unsigned char srtimr; // = $022B SOFTWARE REPEAT TIMER + unsigned char cdtmf4; // = $022C COUNT DOWN TIMER 4 FLAG + unsigned char intemp; // = $022D IAN'S TEMP + unsigned char cdtmf5; // = $022E COUNT DOWN TIMER FLAG 5 + unsigned char sdmctl; // = $022F SAVE DMACTL REGISTER + union { + struct { + unsigned char sdlstl; // = $0230 SAVE DISPLAY LIST LOW 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 + unsigned char _spare_1; // = $0233 No OS use. +#else + unsigned char lcount; // = $0233 ##1200xl## 1-byte relocating loader record +#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 + unsigned char spare2[2]; // = $0238/$0239 No OS use. +#else + void (*vpirq)(void); // = $0238/$0239 ##rev2## 2-byte parallel device IRQ vector +#endif + unsigned char cdevic; // = $023A COMMAND FRAME BUFFER - DEVICE + unsigned char ccomnd; // = $023B COMMAND + union { + struct { + unsigned char caux1; // = $023C COMMAND AUX BYTE 1 + unsigned char caux2; // = $023D COMMAND AUX BYTE 2 + }; + unsigned int caux; // = $023C/$023D (same as above as word) + }; + unsigned char temp; // = $023E TEMPORARY RAM CELL + unsigned char errflg; // = $023F ERROR FLAG - ANY DEVICE ERROR EXCEPT TIME OUT + unsigned char dflags; // = $0240 DISK FLAGS FROM SECTOR ONE + 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 + unsigned char spare3; // = $0245 No OS use. +#else + unsigned char reclen; // = $0245 ##1200xl## 1-byte relocating loader record length +#endif + unsigned char dsktim; // = $0246 DISK TIME OUT REGISTER +#ifdef OSA + unsigned char linbuf[40]; // = $0247-$026E ##old## CHAR LINE BUFFER +#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 + unsigned int reladr; // = $024A/$024B ##rev2## 2-byte relocating loader relative adr. + unsigned char pptmpa; // = $024C ##rev2## 1-byte parallel device handler temporary + unsigned char pptmpx; // = $024D ##rev2## 1-byte parallel device handler temporary + unsigned char _reserved_1[29]; // = $024E-$026A RESERVED + unsigned char chsalt; // = $026B ##1200xl## 1-byte character set alternate + 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 + unsigned char gprior; // = $026F GLOBAL PRIORITY CELL + unsigned char paddl0; // = $0270 1-BYTE POTENTIOMETER 0 + unsigned char paddl1; // = $0271 1-BYTE POTENTIOMETER 1 + unsigned char paddl2; // = $0272 1-BYTE POTENTIOMETER 2 + unsigned char paddl3; // = $0273 1-BYTE POTENTIOMETER 3 + unsigned char paddl4; // = $0274 1-BYTE POTENTIOMETER 4 + unsigned char paddl5; // = $0275 1-BYTE POTENTIOMETER 5 + unsigned char paddl6; // = $0276 1-BYTE POTENTIOMETER 6 + unsigned char paddl7; // = $0277 1-BYTE POTENTIOMETER 7 + unsigned char stick0; // = $0278 1-byte joystick 0 + unsigned char stick1; // = $0279 1-byte joystick 1 + unsigned char stick2; // = $027A 1-byte joystick 2 + unsigned char stick3; // = $027B 1-byte joystick 3 + unsigned char ptrig0; // = $027C 1-BYTE PADDLE TRIGGER 0 + unsigned char ptrig1; // = $027D 1-BYTE PADDLE TRIGGER 1 + unsigned char ptrig2; // = $027E 1-BYTE PADDLE TRIGGER 2 + unsigned char ptrig3; // = $027F 1-BYTE PADDLE TRIGGER 3 + unsigned char ptrig4; // = $0280 1-BYTE PADDLE TRIGGER 4 + unsigned char ptrig5; // = $0281 1-BYTE PADDLE TRIGGER 5 + unsigned char ptrig6; // = $0281 1-BYTE PADDLE TRIGGER 6 + unsigned char ptrig7; // = $0283 1-BYTE PADDLE TRIGGER 7 + unsigned char strig0; // = $0284 1-BYTE JOYSTICK TRIGGER 0 + 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 + unsigned char cstat; // = $0288 ##old## cassette status register +#else + unsigned char hibyte; // = $0288 ##1200xl## 1-byte relocating loader high byte +#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 + 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 + 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 + unsigned char tmpx1; // = $029C ##old## 1--byte temporary register +#else + unsigned char cretry; // = $029C ##1200xl## 1-byte number of command frame retries +#endif + unsigned char hold3; // = $029D 1-byte temporary + unsigned char subtmp; // = $029E 1-byte temporary + unsigned char hold2; // = $029F 1-byte (not used) + unsigned char dmask; // = $02A0 1-byte display (pixel location) mask + unsigned char tmplbt; // = $02A1 1-byte (not used) + unsigned char escflg; // = $02A2 ESCAPE FLAG + unsigned char tabmap[15]; // = $02A3-$02B1 15-byte (120 bit) tab stop bit map + unsigned char logmap[4]; // = $02B2-$02B5 LOGICAL LINE START BIT MAP + unsigned char invflg; // = $02B6 INVERSE VIDEO FLAG (TOGGLED BY ATARI KEY) + unsigned char filflg; // = $02B7 RIGHT FILL FLAG FOR DRAW + unsigned char tmprow; // = $02B8 1-byte temporary row + 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 + unsigned char hold5; // = $02BD ##old## DITTO +#else + unsigned char dretry; // = $02BD ##1200xl## 1-byte number of device retries +#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 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 + unsigned char _spare_2[23]; // = $02C9-$02DF No OS use. +#else + union { + unsigned char parmbl[6]; // = $02C9 ##rev2## 6-byte relocating loader parameter + 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 { + unsigned char oldpar[6]; // = $02CF ##rev2## 6-byte relocating loader parameter + 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 + unsigned char keyrep; // = $02DA ##1200xl## 1-byte auto-repeat rate + unsigned char noclik; // = $02DB ##1200xl## 1-byte key click disable + unsigned char helpfg; // = $02DC ##1200xl## 1-byte HELP key flag (0 = no HELP) + 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 { + unsigned char glbabs[4]; // = $02E0-$02E3 byte global variables for non-DOS users + 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 + unsigned char _spare_3; // = $02E9 No OS use. +#else + unsigned char hndlod; // = $02E9 ##1200xl## 1-byte user load flag +#endif + unsigned char dvstat[4]; // = $02EA-$02ED STATUS BUFFER + union { + unsigned int cbaud; // = $02EE/$02EF 2-byte cassette baud rate + 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 + unsigned char _spare_4[5]; // = $02F5-$02F9 No OS use. +#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 + 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 + 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 + unsigned char addcor; // = $030E ##old## ADDITION CORRECTION +#else + unsigned char jmpers; // = $030E ##1200xl## 1-byte jumper options +#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 + unsigned char _spare_5; // = $0313 unused + unsigned char temp2; // = $0314 ##old## TEMPORARY STORAGE REGISTER +#else + unsigned char temp2; // = $0313 ##1200xl## 1-byte temporary + unsigned char ptimot; // = $0314 ##1200xl## 1-byte printer timeout +#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 + hatabs_t hatabs[12]; // = $031A-$033D handler address table + unsigned int zeropad; // = $033E/$033F zero padding +#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 + unsigned char pupbt2; // = $033E ##1200xl## 1-byte power-up validation byte 2 + unsigned char pupbt3; // = $033F ##1200xl## 1-byte power-up validation byte 3 +#endif + + iocb_t iocb[8]; // = $0340-$03BF 8 I/O Control Blocks + unsigned char prnbuf[40]; // = $03C0-$3E7 PRINTER BUFFER +#ifdef OSA + unsigned char _spare_6[151]; // = $03E8-$047F unused +#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 + unsigned char cartck; // = $03EB ##1200xl## 1-byte cartridge equivalence check + unsigned char derrf; // = $03EC ##rev2## 1-byte screen OPEN error flag + unsigned char acmvar[11]; // = $03ED-$03F7 ##1200xl## reserved for ACMI, not cleared upon reset + unsigned char basicf; // = $03F8 ##rev2## 1-byte BASIC switch flag + unsigned char mintlk; // = $03F9 ##1200xl## 1-byte ACMI module interlock + unsigned char gintlk; // = $03FA ##1200xl## 1-byte cartridge interlock + void* chlink; // = $03FB/$03FC ##1200xl## 2-byte loaded handler chain link + unsigned char casbuf[131]; // = $03FD-$047F CASSETTE BUFFER +#endif + + // --- Page 4 --- + + unsigned char usarea[128]; // = $0480 128 bytes reserved for application + + // --- Page 5 --- + + unsigned char _spare_7[126]; // = $0500-$057D reserved for FP package / unused + unsigned char lbpr1; // = $057E LBUFF PREFIX 1 + unsigned char lbpr2; // = $057F LBUFF PREFIX 2 + unsigned char lbuff[128]; // = $0580-$05FF 128-byte line buffer +}; + + +/* Define a structure with the zero page atari basic register offsets */ + +struct __basic { + void* lowmem; // = $80/$81 POINTER TO BASIC'S LOW MEMORY + void* vntp; // = $82/$83 BEGINNING ADDRESS OF THE VARIABLE NAME TABLE + void* vntd; // = $84/$85 POINTER TO THE ENDING ADDRESS OF THE VARIABLE NAME TABLE PLUS ONE + void* vvtp; // = $86/$87 ADDRESS FOR THE VARIABLE VALUE TABLE + void* stmtab; // = $88/$89 ADDRESS OF THE STATEMENT TABLE + void* stmcur; // = $8A/$8B CURRENT BASIC STATEMENT POINTER + 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 + + unsigned char _internal_2[0xC3-0xBB-1]; // INTERNAL DATA + + unsigned char errsav; // = $C3 NUMBER OF THE ERROR CODE + + unsigned char _internal_3[0xC9-0xC3-1]; // INTERNAL DATA + + unsigned char ptabw; // = $C9 NUMBER OF COLUMNS BETWEEN TAB STOPS + unsigned char loadflg; // = $CA LIST PROTECTION + + unsigned char _internal_4[0xD4-0xCA-1]; // INTERNAL DATA + + unsigned int binint; // = $D4/$D5 USR-CALL RETURN VALUE +}; + +#endif diff --git a/include/_gtia.h b/include/_gtia.h index 0542efa2f..ae3e69445 100644 --- a/include/_gtia.h +++ b/include/_gtia.h @@ -4,9 +4,16 @@ /* */ /* Internal include file, do not use directly */ /* */ +/* "GTIA, Graphic Television Interface Adaptor, is a custom chip used in the */ +/* Atari 8-bit family of computers and in the Atari 5200 console. In these */ +/* systems, GTIA chip works together with ANTIC to produce video display. */ +/* ANTIC generates the playfield graphics (text and bitmap) while GTIA */ +/* provides the color for the playfield and adds overlay objects known as */ +/* player/missile graphics (sprites)" - Wikipedia article on "GTIA" */ /* */ /* */ /* (C) 2000 Freddy Offenga */ +/* 2019-01-16: Bill Kendrick : More defines for registers */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -32,26 +39,32 @@ #ifndef __GTIA_H #define __GTIA_H -/* Define a structure with the gtia register offsets */ +/*****************************************************************************/ +/* Define a structure with the GTIA register offsets for write (W) */ +/*****************************************************************************/ + struct __gtia_write { - unsigned char hposp0; /* 0x00: horizontal position player 0 */ - unsigned char hposp1; /* 0x01: horizontal position player 1 */ - unsigned char hposp2; /* 0x02: horizontal position player 2 */ - unsigned char hposp3; /* 0x03: horizontal position player 3 */ - unsigned char hposm0; /* 0x04: horizontal position missile 0 */ - unsigned char hposm1; /* 0x05: horizontal position missile 1 */ - unsigned char hposm2; /* 0x06: horizontal position missile 2 */ - unsigned char hposm3; /* 0x07: horizontal position missile 3 */ + unsigned char hposp0; /* 0x00: horizontal position of player 0 */ + unsigned char hposp1; /* 0x01: horizontal position of player 1 */ + unsigned char hposp2; /* 0x02: horizontal position of player 2 */ + unsigned char hposp3; /* 0x03: horizontal position of player 3 */ + unsigned char hposm0; /* 0x04: horizontal position of missile 0 */ + unsigned char hposm1; /* 0x05: horizontal position of missile 1 */ + unsigned char hposm2; /* 0x06: horizontal position of missile 2 */ + unsigned char hposm3; /* 0x07: horizontal position of missile 3 */ + unsigned char sizep0; /* 0x08: size of player 0 */ unsigned char sizep1; /* 0x09: size of player 1 */ unsigned char sizep2; /* 0x0A: size of player 2 */ unsigned char sizep3; /* 0x0B: size of player 3 */ unsigned char sizem; /* 0x0C: size of missiles */ - unsigned char grafp0; /* 0x0D: graphics shape player 0 */ + + unsigned char grafp0; /* 0x0D: graphics shape player 0 (used when ANTIC is not instructed to use DMA; see DMACTL) */ unsigned char grafp1; /* 0x0E: graphics shape player 1 */ unsigned char grafp2; /* 0x0F: graphics shape player 2 */ unsigned char grafp3; /* 0x10: graphics shape player 3 */ unsigned char grafm; /* 0x11: graphics shape missiles */ + unsigned char colpm0; /* 0x12: color player and missile 0 */ unsigned char colpm1; /* 0x13: color player and missile 1 */ unsigned char colpm2; /* 0x14: color player and missile 2 */ @@ -61,14 +74,177 @@ struct __gtia_write { unsigned char colpf2; /* 0x18: color playfield 2 */ unsigned char colpf3; /* 0x19: color playfield 3 */ unsigned char colbk; /* 0x1A: color background */ + unsigned char prior; /* 0x1B: priority selection */ - unsigned char vdelay; /* 0x1C: vertical delay */ + + unsigned char vdelay; + /* 0x1C: vertical delay -- one-line resolution movement of + ** vertical position of an object when two line resolution display is enabled + */ + unsigned char gractl; /* 0x1D: stick/paddle latch, p/m control */ + unsigned char hitclr; /* 0x1E: clear p/m collision */ unsigned char consol; /* 0x1F: builtin speaker */ }; -/* Define a structure with the gtia register offsets */ + +/*****************************************************************************/ +/* (W) Values for SIZEP0-SIZEP3 and SIZEM registers: */ +/*****************************************************************************/ + +#define PMG_SIZE_NORMAL 0x0 /* one color clock per pixel */ +#define PMG_SIZE_DOUBLE 0x1 /* two color clocks per pixel */ +#define PMG_SIZE_QUAD 0x2 /* four color clocks per pixel */ + + +/* COLPM0-COLPM3, COLPF0-COLPF3, COLBK color registers */ + +/*****************************************************************************/ +/* Color definitions */ +/*****************************************************************************/ + +/* Make a GTIA color value */ +#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) + +/* Luminance values go from 0 (black) to 7 (white) */ + +/* Hue values */ +/* (These can vary depending on TV standard (NTSC vs PAL), +** tint potentiometer settings, TV tint settings, emulator palette, etc.) +*/ +#define HUE_GREY 0 +#define HUE_GOLD 1 +#define HUE_GOLDORANGE 2 +#define HUE_REDORANGE 3 +#define HUE_ORANGE 4 +#define HUE_MAGENTA 5 +#define HUE_PURPLE 6 +#define HUE_BLUE 7 +#define HUE_BLUE2 8 +#define HUE_CYAN 9 +#define HUE_BLUEGREEN 10 +#define HUE_BLUEGREEN2 11 +#define HUE_GREEN 12 +#define HUE_YELLOWGREEN 13 +#define HUE_YELLOW 14 +#define HUE_YELLOWRED 15 + +/* Color defines, similar to c64 colors (untested) */ +/* Note that the conio color implementation is monochrome +** (bgcolor and textcolor are only placeholders) +*/ +/* Use the defines with the setcolor() or _atari_xxxcolor() functions */ +#define COLOR_BLACK _gtia_mkcolor(HUE_GREY,0) +#define COLOR_WHITE _gtia_mkcolor(HUE_GREY,7) +#define COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1) +#define COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3) +#define COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4) +#define COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2) +#define COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2) +#define COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7) +#define COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5) +#define COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2) +#define COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6) +#define COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2) +#define COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3) +#define COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6) +#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6) +#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5) + +/* TGI color defines */ +#define TGI_COLOR_BLACK COLOR_BLACK +#define TGI_COLOR_WHITE COLOR_WHITE +#define TGI_COLOR_RED COLOR_RED +#define TGI_COLOR_CYAN COLOR_CYAN +#define TGI_COLOR_VIOLET COLOR_VIOLET +#define TGI_COLOR_GREEN COLOR_GREEN +#define TGI_COLOR_BLUE COLOR_BLUE +#define TGI_COLOR_YELLOW COLOR_YELLOW +#define TGI_COLOR_ORANGE COLOR_ORANGE +#define TGI_COLOR_BROWN COLOR_BROWN +#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED +#define TGI_COLOR_GRAY1 COLOR_GRAY1 +#define TGI_COLOR_GRAY2 COLOR_GRAY2 +#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN +#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE +#define TGI_COLOR_GRAY3 COLOR_GRAY3 + + +/*****************************************************************************/ +/* (W) PRIOR register values */ +/*****************************************************************************/ + +#define PRIOR_P03_PF03 0x01 /* Players 0-3, then Playfields 0-3, then background */ +#define PRIOR_P01_PF03_P23 0x02 /* Players 0-1, then Playfields 0-3, then Players 2-3, then background */ +#define PRIOR_PF03_P03 0x04 /* Playfields 0-3, then Players 0-3, then background */ +#define PRIOR_PF01_P03_PF23 0x08 /* Playfields 0-1, then Players 0-3, then Playfields 2-3, then background */ + +#define PRIOR_5TH_PLAYER 0x10 /* Four missiles combine to be a 5th player (uses COLPF3) */ + +/* Causes overlap of players 0 & 1 and of players 2 & 3 to result in a third color, +** the logical OR of the two players' colors, and other overlaps (e.g., players 0 and 2) +** to result in black (0x00). +*/ +#define PRIOR_OVERLAP_3RD_COLOR 0x20 + + +/*****************************************************************************/ +/* (W) GTIA special graphics mode options for GPRIOR */ +/*****************************************************************************/ + +/* Pixels are 2 color clocks wide, and one scanline tall +** (so 80x192 in normal playfield width). +** May be used with both bitmap and character modelines. +*/ + +/* 16 shade shades of the background (COLBK) hue; +** Note: brightnesses other than 0 (darkest) in COLBK cause additional effects +*/ +#define PRIOR_GFX_MODE_9 0x40 + +/* 9 color palette mode; +** COLPM0 (acts as background) thru COLPM3, followed by COLPF0 thru COLPF3, and COLBK +*/ +#define PRIOR_GFX_MODE_10 0x80 + +/* 16 hues of the background (COLBK) brightness; +** Note: hues other than 0 (greys) in COLBK caus additional effects +*/ +#define PRIOR_GFX_MODE_11 0xC0 + + +/*****************************************************************************/ +/* (W) VDELAY register values */ +/*****************************************************************************/ + +#define VDELAY_MISSILE0 0x01 +#define VDELAY_MISSILE1 0x02 +#define VDELAY_MISSILE2 0x04 +#define VDELAY_MISSILE3 0x08 +#define VDELAY_PLAYER0 0x10 +#define VDELAY_PLAYER1 0x20 +#define VDELAY_PLAYER2 0x40 +#define VDELAY_PLAYER3 0x80 + + +/*****************************************************************************/ +/* (W) GRACTL register values */ +/*****************************************************************************/ + +#define GRACTL_MISSLES 0x01 /* enable missiles */ +#define GRACTL_PLAYERS 0x02 /* enable players */ + +/* "Latch" triggers; once pressed, will give a continuous +** pressed input until this bit is cleared +*/ +#define GRACTL_LATCH_TRIGGER_INPUTS 0x04 + + +/*****************************************************************************/ +/* Define a structure with the GTIA register offsets for read (R) */ +/*****************************************************************************/ + struct __gtia_read { unsigned char m0pf; /* 0x00: missile 0 to playfield collision */ unsigned char m1pf; /* 0x01: missile 1 to playfield collision */ @@ -86,15 +262,41 @@ struct __gtia_read { unsigned char p1pl; /* 0x0D: player 1 to player collision */ unsigned char p2pl; /* 0x0E: player 2 to player collision */ unsigned char p3pl; /* 0x0F: player 3 to player collision */ - unsigned char trig0; /* 0x10: joystick trigger 0 */ + + unsigned char trig0; /* 0x10: joystick trigger 0 (0=pressed, 1=released) */ unsigned char trig1; /* 0x11: joystick trigger 1 */ unsigned char trig2; /* 0x12: joystick trigger 2 */ unsigned char trig3; /* 0x13: joystick trigger 3 */ + unsigned char pal; /* 0x14: pal/ntsc flag */ + unsigned char unused[10]; + unsigned char consol; /* 0x1F: console buttons */ }; + +/*****************************************************************************/ +/* (R) PAL register possible values */ +/*****************************************************************************/ + +/* Note: This only tells you whether the GTIA is PAL or NTSC; some NTSC +** systems are modded with PAL ANTIC chips; testing VCOUNT limits can be +** done to check for that. Seems like it's not possible to test for SECAM +*/ + +#define TV_STD_PAL 0x1 +#define TV_STD_NTSC 0xE + + +/*****************************************************************************/ +/* Macros for reading console keys (Start/Select/Option) via CONSOL register */ +/*****************************************************************************/ + +#define CONSOL_START(x) !((unsigned char)((x) & 1)) /* true if Start pressed */ +#define CONSOL_SELECT(x) !((unsigned char)((x) & 2)) /* true if Select pressed */ +#define CONSOL_OPTION(x) !((unsigned char)((x) & 4)) /* true if Option pressed */ + + /* End of _gtia.h */ #endif /* #ifndef __GTIA_H */ - diff --git a/include/_pia.h b/include/_pia.h index 867c8f8a5..4b71ecfd4 100644 --- a/include/_pia.h +++ b/include/_pia.h @@ -4,6 +4,10 @@ /* */ /* Internal include file, do not use directly */ /* */ +/* The Peripheral Interface Adapter (PIA) chip (a 6520 or 6820) provides */ +/* parallel I/O interfacing; it was used in Atari 400/800 and Commodore PET */ +/* family of computers, for joystick and some interrupts. */ +/* Sources; various + Wikpedia article on "Peripheral Interface Adapter". */ /* */ /* */ /* (C) 2000 Freddy Offenga */ @@ -34,7 +38,7 @@ #define __PIA_H -/* Define a structure with the pia register offsets */ +/* Define a structure with the PIA register offsets */ struct __pia { unsigned char porta; /* port A data r/w */ unsigned char portb; /* port B data r/w */ @@ -42,10 +46,7 @@ struct __pia { unsigned char pbctl; /* port B control */ }; - +/* (Some specific register values for Atari defined in atari.h) */ /* End of _pia.h */ #endif - - - diff --git a/include/_pokey.h b/include/_pokey.h index fed8628b6..88d6949aa 100644 --- a/include/_pokey.h +++ b/include/_pokey.h @@ -4,9 +4,17 @@ /* */ /* Internal include file, do not use directly */ /* */ +/* POKEY, Pot Keyboard Integrated Circuit, is a digital I/O chip designed */ +/* for the Atari 8-bit family of home computers; it combines functions for */ +/* sampling (ADC) potentiometers (such as game paddles) and scan matrices of */ +/* switches (such as a computer keyboard) as well as sound generation. */ +/* It produces four voices of distinctive square wave sound, either as clear */ +/* tones or modified with a number of distortion settings. - Wikipedia */ +/* "POKEY" article. */ /* */ /* */ /* (C) 2000 Freddy Offenga */ +/* 2019-01-16: Bill Kendrick : More defines for registers */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -35,7 +43,10 @@ -/* Define a structure with the pokey register offsets */ +/*****************************************************************************/ +/* Define a structure with the POKEY register offsets for write (W) */ +/*****************************************************************************/ + struct __pokey_write { unsigned char audf1; /* audio channel #1 frequency */ unsigned char audc1; /* audio channel #1 control */ @@ -47,13 +58,122 @@ struct __pokey_write { unsigned char audc4; /* audio channel #4 control */ unsigned char audctl; /* audio control */ unsigned char stimer; /* start pokey timers */ - unsigned char skrest; /* reset serial port status reg. */ - unsigned char potgo; /* start paddle scan sequence */ + + unsigned char skrest; + /* reset serial port status reg.; + ** Reset BITs 5 - 7 of the serial port status register (SKCTL) to "1" + */ + + unsigned char potgo; /* start paddle scan sequence (see "ALLPOT") */ unsigned char unuse1; /* unused */ unsigned char serout; /* serial port data output */ unsigned char irqen; /* interrupt request enable */ unsigned char skctl; /* serial port control */ }; + + +/*****************************************************************************/ +/* (W) AUDC1-4 register values */ +/*****************************************************************************/ + +/* Meaningful values for the distortion bits. +** The first process is to divide the clock value by the frequency, +** then mask the output using the polys in the order below; +** finally, the result is divided by two. +*/ +#define AUDC_POLYS_5_17 0x00 +#define AUDC_POLYS_5 0x20 /* Same as 0x60 */ +#define AUDC_POLYS_5_4 0x40 +#define AUDC_POLYS_17 0x80 +#define AUDC_POLYS_NONE 0xA0 /* Same as 0xE0 */ +#define AUDC_POLYS_4 0xC0 + +/* When set, the volume value in AUDC1-4 bits 0-3 is sent directly to the speaker; +** it is not modulated with the frequency specified in the AUDF1-4 registers. +** (See "De Re Atari" Chapter 7: Sound) +*/ +#define AUDC_VOLUME_ONLY 0x10 + + +/*****************************************************************************/ +/* (W) AUDCTL register values */ +/*****************************************************************************/ + +#define AUDCTL_CLOCKBASE_15HZ 0x01 /* Switch main clock base from 64 KHz to 15 KHz */ +#define AUDCTL_HIGHPASS_CHAN2 0x02 /* Insert high pass filter into channel two, clocked by channel four */ +#define AUDCTL_HIGHPASS_CHAN1 0x04 /* Insert high pass filter into channel one, clocked by channel two */ +#define AUDCTL_JOIN_CHAN34 0x08 /* Join channels four and three (16 bit) */ +#define AUDCTL_JOIN_CHAN12 0x10 /* Join channels two and one (16 bit) */ +#define AUDCTL_CLOCK_CHAN3_179MHZ 0x20 /* Clock channel three with 1.79 MHz */ +#define AUDCTL_CLOCK_CHAN1_179MHZ 0x40 /* Clock channel one with 1.79 MHz */ +#define AUDCTL_9BIT_POLY 0x80 /* Makes the 17 bit poly counter into nine bit poly (see also: RANDOM) */ + + +/*****************************************************************************/ +/* (W) IRQEN register values */ +/*****************************************************************************/ + +#define IRQEN_TIMER_1 0x01 /* The POKEY timer one interrupt is enabled */ +#define IRQEN_TIMER_2 0x02 /* The POKEY timer two interrupt is enabled */ +#define IRQEN_TIMER_4 0x04 /* The POKEY timer four interrupt is enabled */ +#define IRQEN_SERIAL_TRANS_FINISHED 0x08 /* The serial out transmission finished interrupt is enabled */ +#define IRQEN_SERIAL_OUT_DATA_REQUIRED 0x10 /* The serial output data required interrupt is enabled */ +#define IRQEN_SERIAL_IN_DATA_READY 0x20 /* The serial input data ready interrupt is enabled. */ +#define IRQEN_OTHER_KEY 0x40 /* The "other key" interrupt is enabled */ +#define IRQEN_BREAK_KEY 0x80 /* The BREAK key is enabled */ + + +/*****************************************************************************/ +/* (W) SKCTL register values */ +/*****************************************************************************/ + +#define SKCTL_KEYBOARD_DEBOUNCE 0x01 /* Enable keyboard debounce circuits */ +#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 +** one frame time (228 scan lines). Not as accurate as the normal pot scan +*/ +#define SKCTL_FAST_POT_SCAN 0x04 + +/* POKEY two-tone mode +** Serial output is transmitted as a two-tone signal rather than a logic true/false. +*/ +#define SKCTL_TWO_TONE_MODE 0x08 + +/* Force break (serial output to zero) */ +#define SKCTL_FORCE_BREAK 0x80 + + +/* Bits 4, 5, and 6 of SKCTL set Serial Mode Control: */ + +/* Trans. & Receive rates set by external clock; Also internal clock phase reset to zero. */ +#define SKCTL_SER_MODE_TX_EXT_RX_EXT 0x00 + +/* Trans. rate set by external clock; Receive asynch. (ch. 4) (CH3 and CH4). */ +#define SKCTL_SER_MODE_TX_EXT_RX_ASYNC 0x10 + +/* Trans. & Receive rates set by Chan. 4; Chan. 4 output on Bi-Direct. clock line. */ +#define SKCTL_SER_MODE_TX_CH4_RX_CH4_BIDIR 0x20 + +/* N.B.: Bit combination 0,1,1 not useful */ + +/* Trans. rate set by Chan. 4; Receive rate set by external clock. */ +#define SKCTL_SER_MODE_TX_CH4_RX_EXT 0x40 + +/* N.B.: Bit combination 1,0,1 not useful */ + +/* Trans. rate set by Chan. 2; Receive rate set by Chan. 4; Chan. 4 out on Bi-Direct. clock line. */ +#define SKCTL_SER_MODE_TX_CH2_RX_CH4_BIDIR 0x60 + +/* Trans. rate set by Chan. 2; Receive asynch. (chan 3 & 4); Bi-Direct. clock not used (tri-state condition). */ +#define SKCTL_SER_MODE_TX_CH4_RX_ASYNC 0x70 + + +/*****************************************************************************/ +/* Define a structure with the POKEY register offsets for read (R) */ +/*****************************************************************************/ + struct __pokey_read { unsigned char pot0; /* paddle 0 value */ unsigned char pot1; /* paddle 1 value */ @@ -63,7 +183,7 @@ struct __pokey_read { unsigned char pot5; /* paddle 5 value */ unsigned char pot6; /* paddle 6 value */ unsigned char pot7; /* paddle 7 value */ - unsigned char allpot; /* eight paddle port status */ + unsigned char allpot; /* eight paddle port status (see "POTGO") */ unsigned char kbcode; /* keyboard code */ unsigned char random; /* random number generator */ unsigned char unuse2; /* unused */ @@ -74,6 +194,27 @@ struct __pokey_read { }; +/*****************************************************************************/ +/* (R) SKSTAT register values */ +/*****************************************************************************/ + +#define SKSTAT_SERIN_SHIFTREG_BUSY 0x02 /* Serial input shift register busy */ +#define SKSTAT_LASTKEY_PRESSED 0x04 /* the last key is still pressed */ +#define SKSTAT_SHIFTKEY_PRESSED 0x08 /* the [Shift] key is pressed */ +#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. */ + + +/* KBCODE, internal keyboard codes for Atari 8-bit computers, +** are #defined as "KEY_..." in "atari.h". +** Note some keys are not read via KBCODE: +** - Reset +** - Start, Select, and Option; see CONSOL in "gtia.h" +** - Break +*/ + + /* End of _pokey.h */ #endif /* #ifndef __POKEY_H */ - diff --git a/include/_tia.h b/include/_tia.h index c89c04d6c..67c08ea18 100644 --- a/include/_tia.h +++ b/include/_tia.h @@ -11,60 +11,60 @@ /* TIA write / read registers */ struct __tia { union { - unsigned char vsync; - unsigned char cxm0p; + unsigned char vsync; + unsigned char cxm0p; }; union { - unsigned char vblank; - unsigned char cxm1p; + unsigned char vblank; + unsigned char cxm1p; }; union { - unsigned char wsync; - unsigned char cxp0fb; + unsigned char wsync; + unsigned char cxp0fb; }; union { - unsigned char rsync; - unsigned char cxp1fb; + unsigned char rsync; + unsigned char cxp1fb; }; union { - unsigned char nusiz0; - unsigned char cxm0fb; + unsigned char nusiz0; + unsigned char cxm0fb; }; union { - unsigned char nusiz1; - unsigned char cxm1fb; + unsigned char nusiz1; + unsigned char cxm1fb; }; union { - unsigned char colup0; - unsigned char cxblpf; + unsigned char colup0; + unsigned char cxblpf; }; union { - unsigned char colup1; - unsigned char cxppmm; + unsigned char colup1; + unsigned char cxppmm; }; union { - unsigned char colupf; - unsigned char inpt0; + unsigned char colupf; + unsigned char inpt0; }; union { - unsigned char colubk; - unsigned char inpt1; + unsigned char colubk; + unsigned char inpt1; }; union { - unsigned char ctrlpf; - unsigned char inpt2; + unsigned char ctrlpf; + unsigned char inpt2; }; union { - unsigned char refp0; - unsigned char inpt3; + unsigned char refp0; + unsigned char inpt3; }; union { - unsigned char refp1; - unsigned char inpt4; + unsigned char refp1; + unsigned char inpt4; }; union { - unsigned char pf0; - unsigned char inpt5; + unsigned char pf0; + unsigned char inpt5; }; unsigned char pf1; unsigned char pf2; diff --git a/include/atari.h b/include/atari.h index 0ca2dc577..a0d4a3d27 100644 --- a/include/atari.h +++ b/include/atari.h @@ -6,9 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2018 Mark Keates */ +/* (C) 2000-2019 Mark Keates */ /* Freddy Offenga */ /* Christian Groessler */ +/* Bill Kendrick */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -36,15 +37,16 @@ #define _ATARI_H - /* Check for errors */ #if !defined(__ATARI__) # error This module may only be used when compiling for the Atari! #endif +/*****************************************************************************/ +/* Character codes */ +/*****************************************************************************/ -/* Character codes */ #define CH_DELCHR 0xFE /* delete char under the cursor */ #define CH_ENTER 0x9B #define CH_ESC 0x1B @@ -86,70 +88,11 @@ #define CH_HLINE 0x12 #define CH_VLINE 0x7C -/* color defines */ -/* make GTIA color value */ -#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) +/*****************************************************************************/ +/* Masks for joy_read */ +/*****************************************************************************/ -/* luminance values go from 0 (black) to 7 (white) */ - -/* hue values */ -#define HUE_GREY 0 -#define HUE_GOLD 1 -#define HUE_GOLDORANGE 2 -#define HUE_REDORANGE 3 -#define HUE_ORANGE 4 -#define HUE_MAGENTA 5 -#define HUE_PURPLE 6 -#define HUE_BLUE 7 -#define HUE_BLUE2 8 -#define HUE_CYAN 9 -#define HUE_BLUEGREEN 10 -#define HUE_BLUEGREEN2 11 -#define HUE_GREEN 12 -#define HUE_YELLOWGREEN 13 -#define HUE_YELLOW 14 -#define HUE_YELLOWRED 15 - -/* Color defines, similar to c64 colors (untested) */ -/* Note that the conio color implementation is monochrome (bgcolor and textcolor are only placeholders) */ -/* Use the defines with the setcolor() or _atari_xxxcolor() functions */ -#define COLOR_BLACK _gtia_mkcolor(HUE_GREY,0) -#define COLOR_WHITE _gtia_mkcolor(HUE_GREY,7) -#define COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1) -#define COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3) -#define COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4) -#define COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2) -#define COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2) -#define COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7) -#define COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5) -#define COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2) -#define COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6) -#define COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2) -#define COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3) -#define COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6) -#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6) -#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5) - -/* TGI color defines */ -#define TGI_COLOR_BLACK COLOR_BLACK -#define TGI_COLOR_WHITE COLOR_WHITE -#define TGI_COLOR_RED COLOR_RED -#define TGI_COLOR_CYAN COLOR_CYAN -#define TGI_COLOR_VIOLET COLOR_VIOLET -#define TGI_COLOR_GREEN COLOR_GREEN -#define TGI_COLOR_BLUE COLOR_BLUE -#define TGI_COLOR_YELLOW COLOR_YELLOW -#define TGI_COLOR_ORANGE COLOR_ORANGE -#define TGI_COLOR_BROWN COLOR_BROWN -#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED -#define TGI_COLOR_GRAY1 COLOR_GRAY1 -#define TGI_COLOR_GRAY2 COLOR_GRAY2 -#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN -#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE -#define TGI_COLOR_GRAY3 COLOR_GRAY3 - -/* Masks for joy_read */ #define JOY_UP_MASK 0x01 #define JOY_DOWN_MASK 0x02 #define JOY_LEFT_MASK 0x04 @@ -159,7 +102,11 @@ #define JOY_FIRE_MASK JOY_BTN_1_MASK #define JOY_FIRE(v) ((v) & JOY_FIRE_MASK) -/* Keyboard values returned by kbcode / CH */ + +/*****************************************************************************/ +/* Keyboard values returned by kbcode / CH */ +/*****************************************************************************/ + #define KEY_NONE ((unsigned char) 0xFF) #define KEY_0 ((unsigned char) 0x32) @@ -220,15 +167,26 @@ #define KEY_INVERSE ((unsigned char) 0x27) #define KEY_HELP ((unsigned char) 0x11) +/* Function keys only exist on the 1200XL model. */ #define KEY_F1 ((unsigned char) 0x03) #define KEY_F2 ((unsigned char) 0x04) #define KEY_F3 ((unsigned char) 0x13) #define KEY_F4 ((unsigned char) 0x14) +/* N.B. Cannot read Ctrl key alone */ #define KEY_CTRL ((unsigned char) 0x80) + +/* N.B. Cannot read Shift key alone via KBCODE; +** instead, check "Shfit key press" bit of SKSTAT register. +** Also, no way to tell left Shift from right Shift. +*/ #define KEY_SHIFT ((unsigned char) 0x40) -/* Composed keys */ + +/* Composed keys +** (Other combinations are possible, including Shift+Ctrl+key, +** though not all such combinations are available.) +*/ #define KEY_EXCLAMATIONMARK (KEY_1 | KEY_SHIFT) #define KEY_QUOTE (KEY_2 | KEY_SHIFT) @@ -256,18 +214,29 @@ #define KEY_LEFT (KEY_PLUS | KEY_CTRL) #define KEY_RIGHT (KEY_ASTERISK | KEY_CTRL) -/* color register functions */ + +/*****************************************************************************/ +/* Color register functions */ +/*****************************************************************************/ + extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace); extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value); extern unsigned char __fastcall__ _getcolor (unsigned char color_reg); -/* other screen functions */ +/*****************************************************************************/ +/* Other screen functions */ +/*****************************************************************************/ + extern int __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */ extern void __fastcall__ _scroll (signed char numlines); /* numlines > 0 scrolls up */ /* numlines < 0 scrolls down */ -/* misc. functions */ + +/*****************************************************************************/ +/* Misc. functions */ +/*****************************************************************************/ + extern unsigned char get_ostype(void); /* get ROM version */ extern unsigned char get_tv(void); /* get TV system */ extern void _save_vecs(void); /* save system vectors */ @@ -275,7 +244,11 @@ extern void _rest_vecs(void); /* restore system vectors */ extern char *_getdefdev(void); /* get default floppy device */ extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ -/* global variables */ + +/*****************************************************************************/ +/* Global variables */ +/*****************************************************************************/ + extern unsigned char _dos_type; /* the DOS flavour */ #ifndef __ATARIXL__ extern void atr130_emd[]; @@ -329,7 +302,11 @@ extern void atrx15_tgi[]; extern void atrx15p2_tgi[]; #endif -/* get_ostype return value defines (for explanation, see ostype.s) */ + +/*****************************************************************************/ +/* get_ostype return value defines (for explanation, see ostype.s) */ +/*****************************************************************************/ + /* masks */ #define AT_OS_TYPE_MAIN 7 #define AT_OS_TYPE_MINOR (7 << 3) @@ -352,11 +329,19 @@ extern void atrx15p2_tgi[]; #define AT_OS_XLXE_3 3 #define AT_OS_XLXE_4 4 -/* get_tv return values */ + +/*****************************************************************************/ +/* get_tv return values */ +/*****************************************************************************/ + #define AT_NTSC 0 #define AT_PAL 1 -/* valid _dos_type values */ + +/*****************************************************************************/ +/* valid _dos_type values */ +/*****************************************************************************/ + #define SPARTADOS 0 #define REALDOS 1 #define BWDOS 2 @@ -366,7 +351,15 @@ extern void atrx15p2_tgi[]; #define MYDOS 6 #define NODOS 255 -/* Define hardware */ + +/*****************************************************************************/ +/* Define hardware and where they're mapped in memory */ +/*****************************************************************************/ + +#include <_atarios.h> +#define OS (*(struct __os*)0x0000) +#define BASIC (*(struct __basic*)0x0080) + #include <_gtia.h> #define GTIA_READ (*(struct __gtia_read*)0xD000) #define GTIA_WRITE (*(struct __gtia_write*)0xD000) @@ -383,65 +376,119 @@ extern void atrx15p2_tgi[]; #include <_antic.h> #define ANTIC (*(struct __antic*)0xD400) -/* device control block */ -struct __dcb { - unsigned char device; /* device id */ - unsigned char unit; /* unit number */ - unsigned char command; /* command */ - unsigned char status; /* command type / status return */ - void *buffer; /* pointer to buffer */ - unsigned char timeout; /* device timeout in seconds */ - unsigned char unused; - unsigned int xfersize; /* # of bytes to transfer */ - unsigned char aux1; /* 1st command auxiliary byte */ - unsigned char aux2; /* 2nd command auxiliary byte */ -}; -#define DCB (*(struct __dcb *)0x300) -/* I/O control block */ -struct __iocb { - unsigned char handler; /* handler index number (0xff free) */ - unsigned char drive; /* device number (drive) */ - unsigned char command; /* command */ - unsigned char status; /* status of last operation */ - void *buffer; /* pointer to buffer */ - void *put_byte; /* pointer to device's PUT BYTE routine */ - unsigned int buflen; /* length of buffer */ - unsigned char aux1; /* 1st auxiliary byte */ - unsigned char aux2; /* 2nd auxiliary byte */ - unsigned char aux3; /* 3rd auxiliary byte */ - unsigned char aux4; /* 4th auxiliary byte */ - unsigned char aux5; /* 5th auxiliary byte */ - unsigned char spare; /* spare byte */ -}; -#define ZIOCB (*(struct __iocb *)0x20) /* zero page IOCB */ -#define IOCB (*(struct __iocb *)0x340) /* system IOCB buffers */ +/*****************************************************************************/ +/* PIA PORTA and PORTB register bits */ +/*****************************************************************************/ -/* IOCB Command Codes */ -#define IOCB_OPEN 0x03 /* open */ -#define IOCB_GETREC 0x05 /* get record */ -#define IOCB_GETCHR 0x07 /* get character(s) */ -#define IOCB_PUTREC 0x09 /* put record */ -#define IOCB_PUTCHR 0x0B /* put character(s) */ -#define IOCB_CLOSE 0x0C /* close */ -#define IOCB_STATIS 0x0D /* status */ -#define IOCB_SPECIL 0x0E /* special */ -#define IOCB_DRAWLN 0x11 /* draw line */ -#define IOCB_FILLIN 0x12 /* draw line with right fill */ -#define IOCB_RENAME 0x20 /* rename disk file */ -#define IOCB_DELETE 0x21 /* delete disk file */ -#define IOCB_LOCKFL 0x23 /* lock file (set to read-only) */ -#define IOCB_UNLOCK 0x24 /* unlock file */ -#define IOCB_POINT 0x25 /* point sector */ -#define IOCB_NOTE 0x26 /* note sector */ -#define IOCB_GETFL 0x27 /* get file length */ -#define IOCB_CHDIR_MYDOS 0x29 /* change directory (MyDOS) */ -#define IOCB_MKDIR 0x2A /* make directory (MyDOS/SpartaDOS) */ -#define IOCB_RMDIR 0x2B /* remove directory (SpartaDOS) */ -#define IOCB_CHDIR_SPDOS 0x2C /* change directory (SpartaDOS) */ -#define IOCB_GETCWD 0x30 /* get current directory (MyDOS/SpartaDOS) */ -#define IOCB_FORMAT 0xFE /* format */ +/* See also: "JOY_xxx_MASK" in "atari.h" */ +/* Paddle 0-3 triggers (per PORTA bits) */ +#define PORTA_PTRIG3 0x80 +#define PORTA_PTRIG2 0x40 +#define PORTA_PTRIG1 0x08 +#define PORTA_PTRIG0 0x04 + + +/* On the Atari 400/800, PORTB is the same as PORTA, but for controller ports 3 & 4. */ + +/* Paddle 4-7 triggers (per PORTB bits); only 400/800 had four controller ports */ +#define PORTB_PTRIG7 0x80 +#define PORTB_PTRIG6 0x40 +#define PORTB_PTRIG5 0x08 +#define PORTB_PTRIG4 0x04 + + +/* On the XL series of computers, PORTB has been changed to a memory and +** LED control (1200XL model only) register (read/write): +*/ + +/* If set, the built-in OS is enabled, and occupies the address range $C000-$FFFF +** (except that the area $D000-$D7FF will only access the hardware registers.) +** If clear, RAM is enabled in this area (again, save for the hole.) +*/ +#define PORTB_OSROM 0x01 + +/* If set, RAM is enabled for the address range $A000-$BFFF. +** If clear, the built-in BASIC ROM is enabled at this address. +** And if there is a cartridge installed in the computer, it makes no difference. +*/ +#define PORTB_BASICROM 0x02 + +/* If set, the corresponding LED is turned off. If clear, the LED will be on. +** (1200XL only) +*/ +#define PORTB_LED1 0x04 +#define PORTB_LED2 0x08 + + +/* On the XE series of computers, PORTB is a bank-selected memory control register (read/write): */ + +/* These bits determine which memory bank is visible to the CPU and/or ANTIC chip +** when their Bank Switch bit is set. There are four possible banks of 16KB each. +*/ +#define PORTB_BANKSELECT1 0x00 +#define PORTB_BANKSELECT2 0x04 +#define PORTB_BANKSELECT3 0x08 +#define PORTB_BANKSELECT4 0x0C + +/* If set, the CPU and/or ANTIC chip will access bank-switched memory mapped to the +** address range $4000-$7FFF. +** If clear, the CPU and/or ANTIC will see normal memory in this region. +*/ +#define PORTB_BANKSWITCH_CPU 0x10 +#define PORTB_BANKSWITCH_ANTIC 0x20 + +/* If set, RAM is enabled for the address range $5000-$57FF. +** If clear, the self-test ROM (physically located at $D000-$D7FF, under the hardware registers) +** is remapped to this memory area. +*/ +#define PORTB_SELFTEST 0x80 + + +/*****************************************************************************/ +/* PACTL and PBCTL register bits */ +/*****************************************************************************/ + +/* (W) Peripheral PA1/PB1 interrupt (IRQ) ("peripheral proceed line available") enable. +** One equals enable. Set by the OS but available to the user; reset on powerup. +** (PxCTL_IRQ_STATUS (R) bit will get set upon interrupt occurance) +*/ +#define PxCTL_IRQ_ENABLE 0x01 /* bit 0 */ + +/* Note: Bit 1 is always set to */ + +/* (W) Controls PORTA/PORTB addressing +** 1 = PORTA/PORTB register; read/write to controller port +** 0 = direction control register; write to direction controls +** (allows setting data flow; write 0s & 1s to PORTA/PORTB bits +** to set which port's pins are read (input), or write (output), +** respectively) +*/ +#define PxCTL_ADDRESSING 0x04 /* bit 2 */ + +/* (W) Peripheral motor control line; Turn the cassette on or off +** (PACTL-specific register bit) +** 0 = on +** 1 = off +*/ +#define PACTL_MOTOR_CONTROL 0x08 /* bit 3 */ + +/* Peripheral command identification (serial bus command line) +** (PBCTL-specific register bit) +*/ +#define PBCTL_PERIPH_CMD_IDENT 0x08 /* bit 3 */ + +/* Note: Bits 4 & 5 are always set to 1 */ + +/* Note: Bit 6 is always set to 0 */ + +/* (R) Peripheral interrupt (IRQ) status bit. +** Set by Peripherals (PORTA / PORTB). Reset by reading from PORTA / PORTB. +** PACTL's is interrupt status of PROCEED +** PBCTL's is interrupt status of SIO +*/ +#define PxCTL_IRQ_STATUS 0x80 /* End of atari.h */ diff --git a/include/atari5200.h b/include/atari5200.h index 12c2bb349..67c11c1df 100644 --- a/include/atari5200.h +++ b/include/atari5200.h @@ -46,47 +46,6 @@ /* the addresses of the static drivers */ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */ -/* make GTIA color value */ -#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) - -/* luminance values go from 0 (black) to 7 (white) */ - -/* hue values */ -#define HUE_GREY 0 -#define HUE_GOLD 1 -#define HUE_GOLDORANGE 2 -#define HUE_REDORANGE 3 -#define HUE_ORANGE 4 -#define HUE_MAGENTA 5 -#define HUE_PURPLE 6 -#define HUE_BLUE 7 -#define HUE_BLUE2 8 -#define HUE_CYAN 9 -#define HUE_BLUEGREEN 10 -#define HUE_BLUEGREEN2 11 -#define HUE_GREEN 12 -#define HUE_YELLOWGREEN 13 -#define HUE_YELLOW 14 -#define HUE_YELLOWRED 15 - -/* Color defines, similar to c64 colors (untested) */ -#define COLOR_BLACK _gtia_mkcolor(HUE_GREY,0) -#define COLOR_WHITE _gtia_mkcolor(HUE_GREY,7) -#define COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1) -#define COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3) -#define COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4) -#define COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2) -#define COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2) -#define COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7) -#define COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5) -#define COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2) -#define COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6) -#define COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2) -#define COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3) -#define COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6) -#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6) -#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5) - /* Masks for joy_read */ #define JOY_UP_MASK 0x01 #define JOY_DOWN_MASK 0x02 diff --git a/include/c64.h b/include/c64.h index eb10600d6..b1cd2e2c4 100644 --- a/include/c64.h +++ b/include/c64.h @@ -137,6 +137,7 @@ /* The addresses of the static drivers */ +extern void c64_65816_emd[]; extern void c64_c256k_emd[]; extern void c64_dqbb_emd[]; extern void c64_georam_emd[]; diff --git a/include/cbm_petscii_charmap.h b/include/cbm_petscii_charmap.h new file mode 100644 index 000000000..ebf478f19 --- /dev/null +++ b/include/cbm_petscii_charmap.h @@ -0,0 +1,297 @@ +/*****************************************************************************/ +/* */ +/* cbm_petscii_charmap.h */ +/* */ +/* CBM system standard string mapping (ISO-8859-1 -> PetSCII) */ +/* */ +/* */ +/* 2019-03-10, Greg King */ +/* */ +/* 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 must not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +/* No include guard here! Multiple use in one file might be intentional. */ + +#pragma warn (remap-zero, push, off) + +#pragma charmap (0x00, 0x00) +#pragma charmap (0x01, 0x01) +#pragma charmap (0x02, 0x02) +#pragma charmap (0x03, 0x03) +#pragma charmap (0x04, 0x04) +#pragma charmap (0x05, 0x05) +#pragma charmap (0x06, 0x06) +#pragma charmap (0x07, 0x07) +#pragma charmap (0x08, 0x14) +#pragma charmap (0x09, 0x09) +#pragma charmap (0x0A, 0x0D) +#pragma charmap (0x0B, 0x11) +#pragma charmap (0x0C, 0x93) +#pragma charmap (0x0D, 0x0A) +#pragma charmap (0x0E, 0x0E) +#pragma charmap (0x0F, 0x0F) +#pragma charmap (0x10, 0x10) +#pragma charmap (0x11, 0x0B) +#pragma charmap (0x12, 0x12) +#pragma charmap (0x13, 0x13) +#pragma charmap (0x14, 0x08) +#pragma charmap (0x15, 0x15) +#pragma charmap (0x16, 0x16) +#pragma charmap (0x17, 0x17) +#pragma charmap (0x18, 0x18) +#pragma charmap (0x19, 0x19) +#pragma charmap (0x1A, 0x1A) +#pragma charmap (0x1B, 0x1B) +#pragma charmap (0x1C, 0x1C) +#pragma charmap (0x1D, 0x1D) +#pragma charmap (0x1E, 0x1E) +#pragma charmap (0x1F, 0x1F) + +#pragma charmap (0x20, 0x20) +#pragma charmap (0x21, 0x21) +#pragma charmap (0x22, 0x22) +#pragma charmap (0x23, 0x23) +#pragma charmap (0x24, 0x24) +#pragma charmap (0x25, 0x25) +#pragma charmap (0x26, 0x26) +#pragma charmap (0x27, 0x27) +#pragma charmap (0x28, 0x28) +#pragma charmap (0x29, 0x29) +#pragma charmap (0x2A, 0x2A) +#pragma charmap (0x2B, 0x2B) +#pragma charmap (0x2C, 0x2C) +#pragma charmap (0x2D, 0x2D) +#pragma charmap (0x2E, 0x2E) +#pragma charmap (0x2F, 0x2F) +#pragma charmap (0x30, 0x30) +#pragma charmap (0x31, 0x31) +#pragma charmap (0x32, 0x32) +#pragma charmap (0x33, 0x33) +#pragma charmap (0x34, 0x34) +#pragma charmap (0x35, 0x35) +#pragma charmap (0x36, 0x36) +#pragma charmap (0x37, 0x37) +#pragma charmap (0x38, 0x38) +#pragma charmap (0x39, 0x39) +#pragma charmap (0x3A, 0x3A) +#pragma charmap (0x3B, 0x3B) +#pragma charmap (0x3C, 0x3C) +#pragma charmap (0x3D, 0x3D) +#pragma charmap (0x3E, 0x3E) +#pragma charmap (0x3F, 0x3F) + +#pragma charmap (0x40, 0x40) +#pragma charmap (0x41, 0xC1) +#pragma charmap (0x42, 0xC2) +#pragma charmap (0x43, 0xC3) +#pragma charmap (0x44, 0xC4) +#pragma charmap (0x45, 0xC5) +#pragma charmap (0x46, 0xC6) +#pragma charmap (0x47, 0xC7) +#pragma charmap (0x48, 0xC8) +#pragma charmap (0x49, 0xC9) +#pragma charmap (0x4A, 0xCA) +#pragma charmap (0x4B, 0xCB) +#pragma charmap (0x4C, 0xCC) +#pragma charmap (0x4D, 0xCD) +#pragma charmap (0x4E, 0xCE) +#pragma charmap (0x4F, 0xCF) +#pragma charmap (0x50, 0xD0) +#pragma charmap (0x51, 0xD1) +#pragma charmap (0x52, 0xD2) +#pragma charmap (0x53, 0xD3) +#pragma charmap (0x54, 0xD4) +#pragma charmap (0x55, 0xD5) +#pragma charmap (0x56, 0xD6) +#pragma charmap (0x57, 0xD7) +#pragma charmap (0x58, 0xD8) +#pragma charmap (0x59, 0xD9) +#pragma charmap (0x5A, 0xDA) +#pragma charmap (0x5B, 0x5B) +#pragma charmap (0x5C, 0xBF) +#pragma charmap (0x5D, 0x5D) +#pragma charmap (0x5E, 0x5E) +#pragma charmap (0x5F, 0xA4) + +#pragma charmap (0x60, 0xAD) +#pragma charmap (0x61, 0x41) +#pragma charmap (0x62, 0x42) +#pragma charmap (0x63, 0x43) +#pragma charmap (0x64, 0x44) +#pragma charmap (0x65, 0x45) +#pragma charmap (0x66, 0x46) +#pragma charmap (0x67, 0x47) +#pragma charmap (0x68, 0x48) +#pragma charmap (0x69, 0x49) +#pragma charmap (0x6A, 0x4A) +#pragma charmap (0x6B, 0x4B) +#pragma charmap (0x6C, 0x4C) +#pragma charmap (0x6D, 0x4D) +#pragma charmap (0x6E, 0x4E) +#pragma charmap (0x6F, 0x4F) +#pragma charmap (0x70, 0x50) +#pragma charmap (0x71, 0x51) +#pragma charmap (0x72, 0x52) +#pragma charmap (0x73, 0x53) +#pragma charmap (0x74, 0x54) +#pragma charmap (0x75, 0x55) +#pragma charmap (0x76, 0x56) +#pragma charmap (0x77, 0x57) +#pragma charmap (0x78, 0x58) +#pragma charmap (0x79, 0x59) +#pragma charmap (0x7A, 0x5A) +#pragma charmap (0x7B, 0xB3) +#pragma charmap (0x7C, 0xDD) +#pragma charmap (0x7D, 0xAB) +#pragma charmap (0x7E, 0xB1) +#pragma charmap (0x7F, 0xDF) + +#pragma charmap (0x80, 0x80) +#pragma charmap (0x81, 0x81) +#pragma charmap (0x82, 0x82) +#pragma charmap (0x83, 0x83) +#pragma charmap (0x84, 0x84) +#pragma charmap (0x85, 0x85) +#pragma charmap (0x86, 0x86) +#pragma charmap (0x87, 0x87) +#pragma charmap (0x88, 0x88) +#pragma charmap (0x89, 0x89) +#pragma charmap (0x8A, 0x8A) +#pragma charmap (0x8B, 0x8B) +#pragma charmap (0x8C, 0x8C) +#pragma charmap (0x8D, 0x8D) +#pragma charmap (0x8E, 0x8E) +#pragma charmap (0x8F, 0x8F) +#pragma charmap (0x90, 0x90) +#pragma charmap (0x91, 0x91) +#pragma charmap (0x92, 0x92) +#pragma charmap (0x93, 0x0C) +#pragma charmap (0x94, 0x94) +#pragma charmap (0x95, 0x95) +#pragma charmap (0x96, 0x96) +#pragma charmap (0x97, 0x97) +#pragma charmap (0x98, 0x98) +#pragma charmap (0x99, 0x99) +#pragma charmap (0x9A, 0x9A) +#pragma charmap (0x9B, 0x9B) +#pragma charmap (0x9C, 0x9C) +#pragma charmap (0x9D, 0x9D) +#pragma charmap (0x9E, 0x9E) +#pragma charmap (0x9F, 0x9F) + +#pragma charmap (0xA0, 0xA0) +#pragma charmap (0xA1, 0xA1) +#pragma charmap (0xA2, 0xA2) +#pragma charmap (0xA3, 0xA3) +#pragma charmap (0xA4, 0xA4) +#pragma charmap (0xA5, 0xA5) +#pragma charmap (0xA6, 0xA6) +#pragma charmap (0xA7, 0xA7) +#pragma charmap (0xA8, 0xA8) +#pragma charmap (0xA9, 0xA9) +#pragma charmap (0xAA, 0xAA) +#pragma charmap (0xAB, 0xAB) +#pragma charmap (0xAC, 0xAC) +#pragma charmap (0xAD, 0xAD) +#pragma charmap (0xAE, 0xAE) +#pragma charmap (0xAF, 0xAF) +#pragma charmap (0xB0, 0xB0) +#pragma charmap (0xB1, 0xB1) +#pragma charmap (0xB2, 0xB2) +#pragma charmap (0xB3, 0xB3) +#pragma charmap (0xB4, 0xB4) +#pragma charmap (0xB5, 0xB5) +#pragma charmap (0xB6, 0xB6) +#pragma charmap (0xB7, 0xB7) +#pragma charmap (0xB8, 0xB8) +#pragma charmap (0xB9, 0xB9) +#pragma charmap (0xBA, 0xBA) +#pragma charmap (0xBB, 0xBB) +#pragma charmap (0xBC, 0xBC) +#pragma charmap (0xBD, 0xBD) +#pragma charmap (0xBE, 0xBE) +#pragma charmap (0xBF, 0xBF) + +#pragma charmap (0xC0, 0x60) +#pragma charmap (0xC1, 0x61) +#pragma charmap (0xC2, 0x62) +#pragma charmap (0xC3, 0x63) +#pragma charmap (0xC4, 0x64) +#pragma charmap (0xC5, 0x65) +#pragma charmap (0xC6, 0x66) +#pragma charmap (0xC7, 0x67) +#pragma charmap (0xC8, 0x68) +#pragma charmap (0xC9, 0x69) +#pragma charmap (0xCA, 0x6A) +#pragma charmap (0xCB, 0x6B) +#pragma charmap (0xCC, 0x6C) +#pragma charmap (0xCD, 0x6D) +#pragma charmap (0xCE, 0x6E) +#pragma charmap (0xCF, 0x6F) +#pragma charmap (0xD0, 0x70) +#pragma charmap (0xD1, 0x71) +#pragma charmap (0xD2, 0x72) +#pragma charmap (0xD3, 0x73) +#pragma charmap (0xD4, 0x74) +#pragma charmap (0xD5, 0x75) +#pragma charmap (0xD6, 0x76) +#pragma charmap (0xD7, 0x77) +#pragma charmap (0xD8, 0x78) +#pragma charmap (0xD9, 0x79) +#pragma charmap (0xDA, 0x7A) +#pragma charmap (0xDB, 0x7B) +#pragma charmap (0xDC, 0x7C) +#pragma charmap (0xDD, 0x7D) +#pragma charmap (0xDE, 0x7E) +#pragma charmap (0xDF, 0x7F) + +#pragma charmap (0xE0, 0xE0) +#pragma charmap (0xE1, 0xE1) +#pragma charmap (0xE2, 0xE2) +#pragma charmap (0xE3, 0xE3) +#pragma charmap (0xE4, 0xE4) +#pragma charmap (0xE5, 0xE5) +#pragma charmap (0xE6, 0xE6) +#pragma charmap (0xE7, 0xE7) +#pragma charmap (0xE8, 0xE8) +#pragma charmap (0xE9, 0xE9) +#pragma charmap (0xEA, 0xEA) +#pragma charmap (0xEB, 0xEB) +#pragma charmap (0xEC, 0xEC) +#pragma charmap (0xED, 0xED) +#pragma charmap (0xEE, 0xEE) +#pragma charmap (0xEF, 0xEF) +#pragma charmap (0xF0, 0xF0) +#pragma charmap (0xF1, 0xF1) +#pragma charmap (0xF2, 0xF2) +#pragma charmap (0xF3, 0xF3) +#pragma charmap (0xF4, 0xF4) +#pragma charmap (0xF5, 0xF5) +#pragma charmap (0xF6, 0xF6) +#pragma charmap (0xF7, 0xF7) +#pragma charmap (0xF8, 0xF8) +#pragma charmap (0xF9, 0xF9) +#pragma charmap (0xFA, 0xFA) +#pragma charmap (0xFB, 0xFB) +#pragma charmap (0xFC, 0xFC) +#pragma charmap (0xFD, 0xFD) +#pragma charmap (0xFE, 0xFE) +#pragma charmap (0xFF, 0xFF) + +#pragma warn (remap-zero, pop) diff --git a/include/cbm_screen_charmap.h b/include/cbm_screen_charmap.h new file mode 100644 index 000000000..76e0d7d7b --- /dev/null +++ b/include/cbm_screen_charmap.h @@ -0,0 +1,311 @@ +/*****************************************************************************/ +/* */ +/* cbm_screen_charmap.h */ +/* */ +/* (c) Copyright 2019, Gerhard W. Gruber (sparhawk@gmx.at) */ +/* */ +/* When using CBM mode, this include converts character literals */ +/* from ASCII to screen-code mapping, so you can write directly */ +/* to the screen memory. */ +/* */ +/* If this include is used, no additional macroes are needed. */ +/* */ +/*****************************************************************************/ + +/* No include guard here! Multiple use in one file may be intentional. */ + +#pragma warn (remap-zero, push, off) + +// Char $00 -> c + 128 +#pragma charmap (0x00, 0x80) + +// Char $01 ... $1A -> c + 128 + 64 (control alphabet) +#pragma charmap (0x01, 0xC1) +#pragma charmap (0x02, 0xC2) +#pragma charmap (0x03, 0xC3) +#pragma charmap (0x04, 0xC4) +#pragma charmap (0x05, 0xC5) +#pragma charmap (0x06, 0xC6) +#pragma charmap (0x07, 0xC7) +#pragma charmap (0x08, 0xC8) +#pragma charmap (0x09, 0xC9) +#pragma charmap (0x0A, 0xCA) +#pragma charmap (0x0B, 0xCB) +#pragma charmap (0x0C, 0xCC) +#pragma charmap (0x0D, 0xCD) +#pragma charmap (0x0E, 0xCE) +#pragma charmap (0x0F, 0xCF) +#pragma charmap (0x10, 0xD0) +#pragma charmap (0x11, 0xD1) +#pragma charmap (0x12, 0xD2) +#pragma charmap (0x13, 0xD3) +#pragma charmap (0x14, 0xD4) +#pragma charmap (0x15, 0xD5) +#pragma charmap (0x16, 0xD6) +#pragma charmap (0x17, 0xD7) +#pragma charmap (0x18, 0xD8) +#pragma charmap (0x19, 0xD9) +#pragma charmap (0x1A, 0xDA) + +// Char $1B ... $1F -> c + 128 +#pragma charmap (0x1B, 0x9B) +#pragma charmap (0x1C, 0x9C) +#pragma charmap (0x1D, 0x9D) +#pragma charmap (0x1E, 0x9E) +#pragma charmap (0x1F, 0x9F) + +// Char $20 ... $3F -> c +#pragma charmap (0x20, 0x20) +#pragma charmap (0x21, 0x21) +#pragma charmap (0x22, 0x22) +#pragma charmap (0x23, 0x23) +#pragma charmap (0x24, 0x24) +#pragma charmap (0x25, 0x25) +#pragma charmap (0x26, 0x26) +#pragma charmap (0x27, 0x27) +#pragma charmap (0x28, 0x28) +#pragma charmap (0x29, 0x29) +#pragma charmap (0x2A, 0x2A) +#pragma charmap (0x2B, 0x2B) +#pragma charmap (0x2C, 0x2C) +#pragma charmap (0x2D, 0x2D) +#pragma charmap (0x2E, 0x2E) +#pragma charmap (0x2F, 0x2F) +#pragma charmap (0x30, 0x30) +#pragma charmap (0x31, 0x31) +#pragma charmap (0x32, 0x32) +#pragma charmap (0x33, 0x33) +#pragma charmap (0x34, 0x34) +#pragma charmap (0x35, 0x35) +#pragma charmap (0x36, 0x36) +#pragma charmap (0x37, 0x37) +#pragma charmap (0x38, 0x38) +#pragma charmap (0x39, 0x39) +#pragma charmap (0x3A, 0x3A) +#pragma charmap (0x3B, 0x3B) +#pragma charmap (0x3C, 0x3C) +#pragma charmap (0x3D, 0x3D) +#pragma charmap (0x3E, 0x3E) +#pragma charmap (0x3F, 0x3F) + +// Char $40 -> c - 64 +#pragma charmap (0x40, 0x00) + +// Char $41 ... $5A -> c (upper-case alphabet) +#pragma charmap (0x41, 0x41) +#pragma charmap (0x42, 0x42) +#pragma charmap (0x43, 0x43) +#pragma charmap (0x44, 0x44) +#pragma charmap (0x45, 0x45) +#pragma charmap (0x46, 0x46) +#pragma charmap (0x47, 0x47) +#pragma charmap (0x48, 0x48) +#pragma charmap (0x49, 0x49) +#pragma charmap (0x4A, 0x4A) +#pragma charmap (0x4B, 0x4B) +#pragma charmap (0x4C, 0x4C) +#pragma charmap (0x4D, 0x4D) +#pragma charmap (0x4E, 0x4E) +#pragma charmap (0x4F, 0x4F) +#pragma charmap (0x50, 0x50) +#pragma charmap (0x51, 0x51) +#pragma charmap (0x52, 0x52) +#pragma charmap (0x53, 0x53) +#pragma charmap (0x54, 0x54) +#pragma charmap (0x55, 0x55) +#pragma charmap (0x56, 0x56) +#pragma charmap (0x57, 0x57) +#pragma charmap (0x58, 0x58) +#pragma charmap (0x59, 0x59) +#pragma charmap (0x5A, 0x5A) + +// Char $5B ... $5F -> c - 64 +#pragma charmap (0x5B, 0x1B) +#pragma charmap (0x5C, 0x1C) +#pragma charmap (0x5D, 0x1D) +#pragma charmap (0x5E, 0x1E) +#pragma charmap (0x5F, 0x1F) + +// Char $60 -> c - 32 +#pragma charmap (0x60, 0x40) + +// Char $61 ... $7A -> c - 32 - 64 (lower-case alphabet) +#pragma charmap (0x61, 0x01) +#pragma charmap (0x62, 0x02) +#pragma charmap (0x63, 0x03) +#pragma charmap (0x64, 0x04) +#pragma charmap (0x65, 0x05) +#pragma charmap (0x66, 0x06) +#pragma charmap (0x67, 0x07) +#pragma charmap (0x68, 0x08) +#pragma charmap (0x69, 0x09) +#pragma charmap (0x6A, 0x0A) +#pragma charmap (0x6B, 0x0B) +#pragma charmap (0x6C, 0x0C) +#pragma charmap (0x6D, 0x0D) +#pragma charmap (0x6E, 0x0E) +#pragma charmap (0x6F, 0x0F) +#pragma charmap (0x70, 0x10) +#pragma charmap (0x71, 0x11) +#pragma charmap (0x72, 0x12) +#pragma charmap (0x73, 0x13) +#pragma charmap (0x74, 0x14) +#pragma charmap (0x75, 0x15) +#pragma charmap (0x76, 0x16) +#pragma charmap (0x77, 0x17) +#pragma charmap (0x78, 0x18) +#pragma charmap (0x79, 0x19) +#pragma charmap (0x7A, 0x1A) + +// Char $7B ... $7F -> c - 32 +#pragma charmap (0x7B, 0x5B) +#pragma charmap (0x7C, 0x5C) +#pragma charmap (0x7D, 0x5D) +#pragma charmap (0x7E, 0x5E) +#pragma charmap (0x7F, 0x5F) + +// Char $80 -> c + 64 +#pragma charmap (0x80, 0xC0) + +// Char $81 ... $9A -> c (control alphabet) +#pragma charmap (0x81, 0x81) +#pragma charmap (0x82, 0x82) +#pragma charmap (0x83, 0x83) +#pragma charmap (0x84, 0x84) +#pragma charmap (0x85, 0x85) +#pragma charmap (0x86, 0x86) +#pragma charmap (0x87, 0x87) +#pragma charmap (0x88, 0x88) +#pragma charmap (0x89, 0x89) +#pragma charmap (0x8A, 0x8A) +#pragma charmap (0x8B, 0x8B) +#pragma charmap (0x8C, 0x8C) +#pragma charmap (0x8D, 0x8D) +#pragma charmap (0x8E, 0x8E) +#pragma charmap (0x8F, 0x8F) +#pragma charmap (0x90, 0x90) +#pragma charmap (0x91, 0x91) +#pragma charmap (0x92, 0x92) +#pragma charmap (0x93, 0x93) +#pragma charmap (0x94, 0x94) +#pragma charmap (0x95, 0x95) +#pragma charmap (0x96, 0x96) +#pragma charmap (0x97, 0x97) +#pragma charmap (0x98, 0x98) +#pragma charmap (0x99, 0x99) +#pragma charmap (0x9A, 0x9A) + +// Char $9B ... $9F -> c + 64 +#pragma charmap (0x9B, 0xDB) +#pragma charmap (0x9C, 0xDC) +#pragma charmap (0x9D, 0xDD) +#pragma charmap (0x9E, 0xDE) +#pragma charmap (0x9F, 0xDF) + +// Char $A0 ... $BF -> c - 64 +#pragma charmap (0xA0, 0x60) +#pragma charmap (0xA1, 0x61) +#pragma charmap (0xA2, 0x62) +#pragma charmap (0xA3, 0x63) +#pragma charmap (0xA4, 0x64) +#pragma charmap (0xA5, 0x65) +#pragma charmap (0xA6, 0x66) +#pragma charmap (0xA7, 0x67) +#pragma charmap (0xA8, 0x68) +#pragma charmap (0xA9, 0x69) +#pragma charmap (0xAA, 0x6A) +#pragma charmap (0xAB, 0x6B) +#pragma charmap (0xAC, 0x6C) +#pragma charmap (0xAD, 0x6D) +#pragma charmap (0xAE, 0x6E) +#pragma charmap (0xAF, 0x6F) +#pragma charmap (0xB0, 0x70) +#pragma charmap (0xB1, 0x71) +#pragma charmap (0xB2, 0x72) +#pragma charmap (0xB3, 0x73) +#pragma charmap (0xB4, 0x74) +#pragma charmap (0xB5, 0x75) +#pragma charmap (0xB6, 0x76) +#pragma charmap (0xB7, 0x77) +#pragma charmap (0xB8, 0x78) +#pragma charmap (0xB9, 0x79) +#pragma charmap (0xBA, 0x7A) +#pragma charmap (0xBB, 0x7B) +#pragma charmap (0xBC, 0x7C) +#pragma charmap (0xBD, 0x7D) +#pragma charmap (0xBE, 0x7E) +#pragma charmap (0xBF, 0x7F) + +// Char $C0 ... $DF -> c - 128 +#pragma charmap (0xC0, 0x40) + +// Char $C1 ... $DA -> c - 128 - 64 (lower-case alphabet) +#pragma charmap (0xC1, 0x01) +#pragma charmap (0xC2, 0x02) +#pragma charmap (0xC3, 0x03) +#pragma charmap (0xC4, 0x04) +#pragma charmap (0xC5, 0x05) +#pragma charmap (0xC6, 0x06) +#pragma charmap (0xC7, 0x07) +#pragma charmap (0xC8, 0x08) +#pragma charmap (0xC9, 0x09) +#pragma charmap (0xCA, 0x0A) +#pragma charmap (0xCB, 0x0B) +#pragma charmap (0xCC, 0x0C) +#pragma charmap (0xCD, 0x0D) +#pragma charmap (0xCE, 0x0E) +#pragma charmap (0xCF, 0x0F) +#pragma charmap (0xD0, 0x10) +#pragma charmap (0xD1, 0x11) +#pragma charmap (0xD2, 0x12) +#pragma charmap (0xD3, 0x13) +#pragma charmap (0xD4, 0x14) +#pragma charmap (0xD5, 0x15) +#pragma charmap (0xD6, 0x16) +#pragma charmap (0xD7, 0x17) +#pragma charmap (0xD8, 0x18) +#pragma charmap (0xD9, 0x19) +#pragma charmap (0xDA, 0x1A) + +// Char $DB ... $DF -> c - 128 +#pragma charmap (0xDB, 0x5B) +#pragma charmap (0xDC, 0x5C) +#pragma charmap (0xDD, 0x5D) +#pragma charmap (0xDE, 0x5E) +#pragma charmap (0xDF, 0x5F) + +// Char $E0 ... $FF -> c - 128 +#pragma charmap (0xE0, 0x60) +#pragma charmap (0xE1, 0x61) +#pragma charmap (0xE2, 0x62) +#pragma charmap (0xE3, 0x63) +#pragma charmap (0xE4, 0x64) +#pragma charmap (0xE5, 0x65) +#pragma charmap (0xE6, 0x66) +#pragma charmap (0xE7, 0x67) +#pragma charmap (0xE8, 0x68) +#pragma charmap (0xE9, 0x69) +#pragma charmap (0xEA, 0x6A) +#pragma charmap (0xEB, 0x6B) +#pragma charmap (0xEC, 0x6C) +#pragma charmap (0xED, 0x6D) +#pragma charmap (0xEE, 0x6E) +#pragma charmap (0xEF, 0x6F) +#pragma charmap (0xF0, 0x70) +#pragma charmap (0xF1, 0x71) +#pragma charmap (0xF2, 0x72) +#pragma charmap (0xF3, 0x73) +#pragma charmap (0xF4, 0x74) +#pragma charmap (0xF5, 0x75) +#pragma charmap (0xF6, 0x76) +#pragma charmap (0xF7, 0x77) +#pragma charmap (0xF8, 0x78) +#pragma charmap (0xF9, 0x79) +#pragma charmap (0xFA, 0x7A) +#pragma charmap (0xFB, 0x7B) +#pragma charmap (0xFC, 0x7C) +#pragma charmap (0xFD, 0x7D) +#pragma charmap (0xFE, 0x7E) +#pragma charmap (0xFF, 0x7F) + +#pragma warn (remap-zero, pop) diff --git a/include/geos/ggraph.h b/include/geos/ggraph.h index 35e02c198..ec9fb0fa1 100644 --- a/include/geos/ggraph.h +++ b/include/geos/ggraph.h @@ -45,6 +45,10 @@ void __fastcall__ BitOtherClip(void *proc1, void *proc2, char skipl, void __fastcall__ GraphicsString(char *myGfxString); +#ifdef __GEOS_CBM__ +void SetNewMode(void); +#endif + /* VIC colour constants */ #define BLACK 0 #define WHITE 1 diff --git a/libsrc/Makefile b/libsrc/Makefile index 0d0cd320b..0ebec46b1 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -93,7 +93,7 @@ INSTALL = install define INSTALL_recipe -$(if $(PREFIX),,$(error variable `PREFIX' must be set)) +$(if $(PREFIX),,$(error variable "PREFIX" must be set)) $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) $(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) diff --git a/libsrc/apple2/ser/a2.ssc.s b/libsrc/apple2/ser/a2.ssc.s index d5c567165..a32110ef2 100644 --- a/libsrc/apple2/ser/a2.ssc.s +++ b/libsrc/apple2/ser/a2.ssc.s @@ -44,15 +44,15 @@ .addr $0000 ; Jump table - .addr INSTALL - .addr UNINSTALL - .addr OPEN - .addr CLOSE - .addr GET - .addr PUT - .addr STATUS - .addr IOCTL - .addr IRQ + .addr SER_INSTALL + .addr SER_UNINSTALL + .addr SER_OPEN + .addr SER_CLOSE + .addr SER_GET + .addr SER_PUT + .addr SER_STATUS + .addr SER_IOCTL + .addr SER_IRQ ;---------------------------------------------------------------------------- ; I/O definitions @@ -141,23 +141,23 @@ IdTableLen = * - IdValTable .code ;---------------------------------------------------------------------------- -; INSTALL: Is called after the driver is loaded into memory. If possible, +; SER_INSTALL: Is called after the driver is loaded into memory. If possible, ; check if the hardware is present. Must return an SER_ERR_xx code in a/x. ; ; Since we don't have to manage the IRQ vector on the Apple II, this is ; actually the same as: ; -; UNINSTALL: Is called before the driver is removed from memory. +; SER_UNINSTALL: Is called before the driver is removed from memory. ; No return code required (the driver is removed from memory on return). ; ; and: ; -; CLOSE: Close the port and disable interrupts. Called without parameters. +; SER_CLOSE: Close the port and disable interrupts. Called without parameters. ; Must return an SER_ERR_xx code in a/x. -INSTALL: -UNINSTALL: -CLOSE: +SER_INSTALL: +SER_UNINSTALL: +SER_CLOSE: ldx Index ; Check for open port beq :+ @@ -172,16 +172,16 @@ CLOSE: rts ;---------------------------------------------------------------------------- -; OPEN: A pointer to a ser_params structure is passed in ptr1. +; SER_OPEN: A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ldx #<$C000 stx ptr2 lda #>$C000 ora Slot sta ptr2+1 - + ; Check Pascal 1.1 Firmware Protocol ID bytes : ldy IdOfsTable,x lda IdValTable,x @@ -190,7 +190,7 @@ OPEN: inx cpx #IdTableLen bcc :- - + ; Convert slot to I/O register index lda Slot asl @@ -273,11 +273,11 @@ InvBaud:lda #T1Han - jsr set_VTIMR1_handler + lda #T2Han + jsr set_VTIMR2_handler .else - lda VTIMR1 - sta OldT1 - lda VTIMR1+1 - sta OldT1+1 + lda VTIMR2 + sta OldT2 + lda VTIMR2+1 + sta OldT2+1 php sei - lda #T1Han - sta VTIMR1+1 + lda #T2Han + sta VTIMR2+1 plp .endif @@ -257,20 +258,12 @@ INSTALL: sta AUDCTL lda #0 - sta AUDC1 + sta AUDC2 lda #15 - sta AUDF1 + sta AUDF2 sta STIMER -.if 0 ; the IRQ will now be dynamically enabled when the mouse is moved - lda POKMSK - ora #%00000001 ; timer 1 enable - sta POKMSK - sta IRQEN - sta irq_enabled -.endif - lda PORTA and #$0f sta old_porta_vbi @@ -290,23 +283,23 @@ UNINSTALL: ; uninstall timer irq routine lda POKMSK - and #%11111110 ; timer 1 disable + and #%11111101 ; timer 2 disable sta IRQEN sta POKMSK .ifdef __ATARIXL__ clc - jsr set_VTIMR1_handler + jsr set_VTIMR2_handler .else php sei - lda OldT1 - sta VTIMR1 - lda OldT1+1 - sta VTIMR1+1 + lda OldT2 + sta VTIMR2 + lda OldT2+1 + sta VTIMR2+1 plp .endif @@ -503,7 +496,7 @@ IRQ: lda PORTA ; mouse port contents ; Turn mouse polling IRQ back on lda POKMSK - ora #%00000001 ; timer 1 enable + ora #%00000010 ; timer 2 enable sta POKMSK sta IRQEN sta irq_enabled @@ -533,7 +526,7 @@ IRQ: lda PORTA ; mouse port contents sta irq_enabled lda POKMSK - and #%11111110 ; timer 1 disable + and #%11111101 ; timer 2 disable sta IRQEN sta POKMSK @@ -620,13 +613,18 @@ IRQ: lda PORTA ; mouse port contents ;---------------------------------------------------------------------------- -; T1Han: Local IRQ routine to poll mouse +; T2Han: Local IRQ routine to poll mouse ; -T1Han: lda CRITIC ; if CRITIC flag is set, disable the +T2Han: lda CRITIC ; if CRITIC flag is set, disable the bne disable_me ; high frequency polling IRQ, in order ; not to interfere with SIO I/O (e.g. - ; floppy access) + ; floppy access or serial I/O) + + lda in_irq ; handler entered again? + bne skip ; yes, ignore this interrupt + inc in_irq + cli ; enable IRQs so that we don't block them for too long tya pha @@ -803,6 +801,8 @@ mmexit: sty oldval tax pla tay + dec in_irq +skip: .ifdef __ATARIXL__ rts .else @@ -819,7 +819,7 @@ mmexit: sty oldval disable_me: lda POKMSK - and #%11111110 ; timer 1 disable + and #%11111101 ; timer 2 disable sta IRQEN sta POKMSK lda #0 diff --git a/libsrc/atari/mouseref.s b/libsrc/atari/mouseref.s index b75df93d1..ac99d36fa 100644 --- a/libsrc/atari/mouseref.s +++ b/libsrc/atari/mouseref.s @@ -5,8 +5,8 @@ .export mouse_libref .ifdef __ATARIXL__ - .import set_VTIMR1_handler -mouse_libref := set_VTIMR1_handler + .import set_VTIMR2_handler +mouse_libref := set_VTIMR2_handler .else .import _exit mouse_libref := _exit diff --git a/libsrc/atari/shadow_ram_timerirq2.s b/libsrc/atari/shadow_ram_timerirq2.s new file mode 100644 index 000000000..b2cdaecd2 --- /dev/null +++ b/libsrc/atari/shadow_ram_timerirq2.s @@ -0,0 +1,81 @@ +; +; Atari XL shadow RAM timer IRQ #2 handler +; +; Christian Groessler, chris@groessler.org, 2019 +; + +;DEBUG = 1 + +.ifdef __ATARIXL__ + +SHRAM_HANDLERS = 1 + .include "atari.inc" + .include "romswitch.inc" + .export set_VTIMR2_handler + + +.segment "LOWBSS" + +VTIMR2_handler: .res 3 + + +.segment "BSS" + +old_VTIMR2_handler: + .res 2 + + +.segment "LOWCODE" + +; timer interrupt handler: +; disable ROM, call user handler, enable ROM again + +my_VTIMR2_handler: + disable_rom_quick + jsr VTIMR2_handler + enable_rom_quick + pla + rti + +.segment "CODE" + +; install or remove VTIMR2 handler +; input: CF - 0/1 for remove/install handler +; AX - pointer to handler (if CF=1) +; registers destroyed + +set_VTIMR2_handler: + + bcc @remove + +; install vector + + stx VTIMR2_handler+2 + sta VTIMR2_handler+1 ; save passed vector in low memory + lda #$4C ; "JMP" opcode + sta VTIMR2_handler + + lda VTIMR2 + sta old_VTIMR2_handler + lda VTIMR2+1 + sta old_VTIMR2_handler+1 + + lda #my_VTIMR2_handler + sta VTIMR2+1 + plp + rts + +@remove: php + sei + lda old_VTIMR2_handler + sta VTIMR2 + lda old_VTIMR2_handler+1 + sta VTIMR2+1 + plp + rts + +.endif ; .ifdef __ATARIXL__ diff --git a/libsrc/atari/system_check.s b/libsrc/atari/system_check.s index 19efaf2e2..df7c433a4 100644 --- a/libsrc/atari/system_check.s +++ b/libsrc/atari/system_check.s @@ -16,8 +16,7 @@ ;DEBUG = 1 - .export __SYSTEM_CHECK__: absolute = 1 - .import __SYSCHK_LOAD__ + .export __SYSTEM_CHECK__, __SYSCHK_END__ .import __STARTADDRESS__ ; the following imports are only needed for the 'atari' target version @@ -25,10 +24,12 @@ .import __STACKSIZE__ .import __RESERVED_MEMORY__ + ; import our header and trailers + .forceimport __SYSCHKHDR__, __SYSCHKTRL__ + .include "zeropage.inc" .include "atari.inc" - .macro print_string text .local start, cont jmp cont @@ -229,25 +230,10 @@ delay1: ldx #0 .endproc -end: +__SYSTEM_CHECK__=syschk +__SYSCHK_END__: .ifndef __ATARIXL__ tmp: ; outside of the load chunk, some kind of poor man's .bss .endif -; ------------------------------------------------------------------------ -; Chunk header - -.segment "SYSCHKHDR" - - .word __SYSCHK_LOAD__ - .word end - 1 - -; ------------------------------------------------------------------------ -; Chunk "trailer" - sets INITAD - -.segment "SYSCHKTRL" - - .word INITAD - .word INITAD+1 - .word syschk diff --git a/libsrc/atari/system_check_hdr.s b/libsrc/atari/system_check_hdr.s new file mode 100644 index 000000000..1581ab918 --- /dev/null +++ b/libsrc/atari/system_check_hdr.s @@ -0,0 +1,16 @@ +; +; Atari startup system check headers +; +; Christian Groessler, chris@groessler.org, 2013 +; + .export __SYSCHKHDR__: absolute = 1 + .import __SYSCHK_LOAD__, __SYSCHK_END__ + +; ------------------------------------------------------------------------ +; Chunk header + +.segment "SYSCHKHDR" + + .word __SYSCHK_LOAD__ + .word __SYSCHK_END__ - 1 + diff --git a/libsrc/atari/system_check_trailer.s b/libsrc/atari/system_check_trailer.s new file mode 100644 index 000000000..312b83b1f --- /dev/null +++ b/libsrc/atari/system_check_trailer.s @@ -0,0 +1,17 @@ +; +; Atari startup system check headers +; +; Christian Groessler, chris@groessler.org, 2013 +; + .export __SYSCHKTRL__: absolute = 1 + .import __SYSTEM_CHECK__ + + .include "atari.inc" +; ------------------------------------------------------------------------ +; Chunk "trailer" - sets INITAD + +.segment "SYSCHKTRL" + + .word INITAD + .word INITAD+1 + .word __SYSTEM_CHECK__ diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index 1381a49a0..9358e5fea 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -22,13 +22,11 @@ static char C_dev[] = "C:"; static struct __iocb *findfreeiocb(void) { - struct __iocb *iocb = &IOCB; /* first IOCB (#0) */ int i; for (i = 0; i < 8; i++) { - if (iocb->handler == 0xff) - return iocb; - iocb++; + if (OS.iocb[i].handler == 0xff) + return &OS.iocb[i]; } return NULL; } @@ -52,7 +50,7 @@ int main(int argc, char **argv) fprintf(stderr, "couldn't find a free iocb\n"); return 1; } - iocb_num = (iocb - &IOCB) * 16; + iocb_num = (iocb - OS.iocb) * 16; if (verbose) printf("using iocb index $%02X ($%04X)\n", iocb_num, iocb); diff --git a/libsrc/atari/tgi/atari_tgi_common.inc b/libsrc/atari/tgi/atari_tgi_common.inc index cd486d91b..8c9f6c1f9 100644 --- a/libsrc/atari/tgi/atari_tgi_common.inc +++ b/libsrc/atari/tgi/atari_tgi_common.inc @@ -1110,11 +1110,8 @@ skipm: ; Loop while --dy > 0 ; locals string := tmp1 - cols := tmp3 pixels := tmp4 font := regsave -.rodata - ataint: .byte 64,0,32,96 .bss rows: .res 1 @@ -1222,32 +1219,31 @@ scvert: ldx x1 .endif ; Draw one character - ; Convert to ANTIC code -draw: tay - rol a - rol a - rol a - rol a - and #3 - tax - tya - and #$9f - ora ataint,x - ; Save and clear inverse video bit - sta inv - and #$7F +draw: + ; Extract the inverse mask + ldx #0 + asl a + bcc noinv + dex +noinv: stx inv + ; Calculate font data address + ldx CHBAS + cmp #$20*2 + bpl lowhalf + ; Semigraphic or lowercase + inx + inx +lowhalf: + asl a + bcc lowquarter + ; Letter + inx +lowquarter: + asl a sta font - lda #0 - sta font + 1 + stx font+1 - .repeat 3 - asl font - rol a - .endrepeat - - adc CHBAS - sta font + 1 ; Save old coords bit text_dir bpl hor @@ -1273,15 +1269,12 @@ cont: ldy #7 ; Put one row of the glyph putrow: sty rows lda (font),y - bit inv - bpl noinv - eor #$FF -noinv: sta pixels - lda #7 - sta cols + eor inv + sec + rol a + sta pixels ; Put one column of the row -putcol: asl pixels - bcc next_col +putcol: bcc next_col lda x1 pha lda x1 + 1 @@ -1317,8 +1310,8 @@ vertinc: sub mag_x sta y2 L2: - dec cols - bpl putcol + asl pixels + bne putcol next_row: ; Go to next row bit text_dir diff --git a/libsrc/atmos/ser/atmos-acia.s b/libsrc/atmos/ser/atmos-acia.s index 79fbc1bbe..f84b66a0a 100644 --- a/libsrc/atmos/ser/atmos-acia.s +++ b/libsrc/atmos/ser/atmos-acia.s @@ -44,15 +44,15 @@ .addr $0000 ; Jump table - .addr INSTALL - .addr UNINSTALL - .addr OPEN - .addr CLOSE - .addr GET - .addr PUT + .addr SER_INSTALL + .addr SER_UNINSTALL + .addr SER_OPEN + .addr SER_CLOSE + .addr SER_GET + .addr SER_PUT .addr SER_STATUS - .addr IOCTL - .addr IRQ + .addr SER_IOCTL + .addr SER_IRQ ;---------------------------------------------------------------------------- ; Global variables @@ -116,23 +116,23 @@ ParityTable: .code ;---------------------------------------------------------------------------- -; INSTALL: Is called after the driver is loaded into memory. If possible, +; SER_INSTALL: Is called after the driver is loaded into memory. If possible, ; check if the hardware is present. Must return an SER_ERR_xx code in a/x. ; ; Since we don't have to manage the IRQ vector on the Telestrat/Atmos, this is ; actually the same as: ; -; UNINSTALL: Is called before the driver is removed from memory. +; SER_UNINSTALL: Is called before the driver is removed from memory. ; No return code required (the driver is removed from memory on return). ; ; and: ; -; CLOSE: Close the port and disable interrupts. Called without parameters. +; SER_CLOSE: Close the port and disable interrupts. Called without parameters. ; Must return an SER_ERR_xx code in a/x. -INSTALL: -UNINSTALL: -CLOSE: +SER_INSTALL: +SER_UNINSTALL: +SER_CLOSE: ldx Index ; Check for open port beq :+ @@ -147,10 +147,10 @@ CLOSE: rts ;---------------------------------------------------------------------------- -; OPEN: A pointer to a ser_params structure is passed in ptr1. +; SER_OPEN: A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ; Check if the handshake setting is valid ldy #SER_PARAMS::HANDSHAKE ; Handshake lda (ptr1),y @@ -220,11 +220,11 @@ InvBaud:lda #SER_ERR_INV_IOCTL rts ;---------------------------------------------------------------------------- -; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All +; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All ; registers are already saved, no parameters are passed, but the carry flag ; is clear on entry. The routine must return with carry set if the interrupt ; was handled, otherwise with carry clear. -IRQ: +SER_IRQ: ldx Index ; Check for open port beq Done lda ACIA::STATUS,x ; Check ACIA status for receive interrupt diff --git a/libsrc/c128/cgetc.s b/libsrc/c128/cgetc.s index bc9d8da7f..7cf7fcc3e 100644 --- a/libsrc/c128/cgetc.s +++ b/libsrc/c128/cgetc.s @@ -10,6 +10,7 @@ .import cursor + .include "cbm_kernal.inc" .include "c128.inc" ;-------------------------------------------------------------------------- @@ -17,8 +18,8 @@ _cgetc: lda KEY_COUNT ; Get number of characters bne L2 ; Jump if there are already chars waiting -; Switch on the cursor if needed. We MUST always switch the cursor on, -; before switching it off, because switching it off will restore the +; Switch on the cursor if needed. We MUST always switch the cursor on, +; before switching it off, because switching it off will restore the ; character attribute remembered when it was switched on. So just switching ; it off will restore the wrong character attribute. diff --git a/libsrc/c128/clrscr.s b/libsrc/c128/clrscr.s index 2213be0cd..a3c519cb1 100644 --- a/libsrc/c128/clrscr.s +++ b/libsrc/c128/clrscr.s @@ -6,9 +6,6 @@ .export _clrscr - .include "c128.inc" + .include "cbm_kernal.inc" _clrscr = CLRSCR - - - diff --git a/libsrc/c128/cputc.s b/libsrc/c128/cputc.s index 9d269a47e..667260843 100644 --- a/libsrc/c128/cputc.s +++ b/libsrc/c128/cputc.s @@ -9,8 +9,8 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot .import gotoxy - .import PLOT + .include "cbm_kernal.inc" .include "c128.inc" newline = NEWLINE @@ -85,4 +85,3 @@ plot: ldy CURS_X ; position in Y putchar = $CC2F - diff --git a/libsrc/c128/mainargs.s b/libsrc/c128/mainargs.s index f53ceafa0..dcf590024 100644 --- a/libsrc/c128/mainargs.s +++ b/libsrc/c128/mainargs.s @@ -25,6 +25,7 @@ .constructor initmainargs, 24 .import __argc, __argv + .include "cbm_kernal.inc" .include "c128.inc" diff --git a/libsrc/c128/ser/c128-swlink.s b/libsrc/c128/ser/c128-swlink.s index 98411d4f8..3337e2668 100644 --- a/libsrc/c128/ser/c128-swlink.s +++ b/libsrc/c128/ser/c128-swlink.s @@ -45,15 +45,15 @@ ; Jump table - .word INSTALL - .word UNINSTALL - .word OPEN - .word CLOSE - .word GET - .word PUT - .word STATUS - .word IOCTL - .word IRQ + .word SER_INSTALL + .word SER_UNINSTALL + .word SER_OPEN + .word SER_CLOSE + .word SER_GET + .word SER_PUT + .word SER_STATUS + .word SER_IOCTL + .word SER_IRQ ;---------------------------------------------------------------------------- ; I/O definitions @@ -155,11 +155,11 @@ Vector := *+1 .reloc ;---------------------------------------------------------------------------- -; INSTALL routine. Is called after the driver is loaded into memory. If +; SER_INSTALL routine. Is called after the driver is loaded into memory. If ; possible, check if the hardware is present. ; Must return an SER_ERR_xx code in a/x. -INSTALL: +SER_INSTALL: ; Deactivate DTR and disable 6551 interrupts @@ -192,10 +192,10 @@ SetNMI: sta NMIVec rts ;---------------------------------------------------------------------------- -; UNINSTALL routine. Is called before the driver is removed from memory. +; SER_UNINSTALL routine. Is called before the driver is removed from memory. ; Must return an SER_ERR_xx code in a/x. -UNINSTALL: +SER_UNINSTALL: ; Stop interrupts, drop DTR @@ -212,7 +212,7 @@ UNINSTALL: ; PARAMS routine. A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ; Check if the handshake setting is valid @@ -283,11 +283,11 @@ InvBaud: rts ;---------------------------------------------------------------------------- -; CLOSE: Close the port, disable interrupts and flush the buffer. Called +; SER_CLOSE: Close the port, disable interrupts and flush the buffer. Called ; without parameters. Must return an error code in a/x. ; -CLOSE: +SER_CLOSE: ; Stop interrupts, drop DTR @@ -305,12 +305,13 @@ CLOSE: rts ;---------------------------------------------------------------------------- -; GET: Will fetch a character from the receive buffer and store it into the +; SER_GET: Will fetch a character from the receive buffer and store it into the ; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is ; return. ; -GET: ldx SendFreeCnt ; Send data if necessary +SER_GET: + ldx SendFreeCnt ; Send data if necessary inx ; X == $FF? beq @L1 lda #$00 @@ -349,11 +350,11 @@ GET: ldx SendFreeCnt ; Send data if necessary rts ;---------------------------------------------------------------------------- -; PUT: Output character in A. +; SER_PUT: Output character in A. ; Must return an error code in a/x. ; -PUT: +SER_PUT: ; Try to send @@ -383,23 +384,25 @@ PUT: rts ;---------------------------------------------------------------------------- -; STATUS: Return the status in the variable pointed to by ptr1. +; SER_STATUS: Return the status in the variable pointed to by ptr1. ; Must return an error code in a/x. ; -STATUS: lda ACIA_STATUS +SER_STATUS: + lda ACIA_STATUS ldx #0 sta (ptr1,x) txa ; SER_ERR_OK rts ;---------------------------------------------------------------------------- -; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl +; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl ; specific data in ptr1, and the ioctl code in A. ; Must return an error code in a/x. ; -IOCTL: lda #SER_ERR_INV_IOCTL rts @@ -407,7 +410,7 @@ IOCTL: lda #SER_ERR_INV_IOCTL - rts + rts ;---------------------------------------------------------------------------- -; IRQ: Not used on the C64 +; SER_IRQ: Not used on the C64 ; -IRQ = $0000 +SER_IRQ = $0000 ;---------------------------------------------------------------------------- ; @@ -476,4 +480,3 @@ InitBuffers: stx RecvFreeCnt stx SendFreeCnt rts - diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index ae0e23857..05e9e5b47 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -11,6 +11,7 @@ .import cursor .importzp tmp1 + .include "cbm_kernal.inc" .include "c64.inc" .include "soft80.inc" diff --git a/libsrc/c64/soft80mono_cgetc.s b/libsrc/c64/soft80mono_cgetc.s index d99dc7775..8d8dc940d 100644 --- a/libsrc/c64/soft80mono_cgetc.s +++ b/libsrc/c64/soft80mono_cgetc.s @@ -12,6 +12,7 @@ .import cursor .importzp tmp1 + .include "cbm_kernal.inc" .include "c64.inc" .include "soft80.inc" diff --git a/libsrc/cbm510/ser/cbm510-std.s b/libsrc/cbm510/ser/cbm510-std.s index 7629892e0..64f613cd5 100644 --- a/libsrc/cbm510/ser/cbm510-std.s +++ b/libsrc/cbm510/ser/cbm510-std.s @@ -46,15 +46,15 @@ ; Jump table - .word INSTALL - .word UNINSTALL - .word OPEN - .word CLOSE - .word GET - .word PUT - .word STATUS - .word IOCTL - .word IRQ + .word SER_INSTALL + .word SER_UNINSTALL + .word SER_OPEN + .word SER_CLOSE + .word SER_GET + .word SER_PUT + .word SER_STATUS + .word SER_IOCTL + .word SER_IRQ ;---------------------------------------------------------------------------- ; @@ -122,24 +122,24 @@ ParityTable: .code ;---------------------------------------------------------------------------- -; INSTALL routine. Is called after the driver is loaded into memory. If +; SER_INSTALL routine. Is called after the driver is loaded into memory. If ; possible, check if the hardware is present. ; Must return an SER_ERR_xx code in a/x. ; ; Since we don't have to manage the IRQ vector on the Plus/4, this is actually ; the same as: ; -; UNINSTALL routine. Is called before the driver is removed from memory. +; SER_UNINSTALL routine. Is called before the driver is removed from memory. ; Must return an SER_ERR_xx code in a/x. ; and: ; -; CLOSE: Close the port, disable interrupts and flush the buffer. Called +; SER_CLOSE: Close the port, disable interrupts and flush the buffer. Called ; without parameters. Must return an error code in a/x. ; -INSTALL: -UNINSTALL: -CLOSE: +SER_INSTALL: +SER_UNINSTALL: +SER_CLOSE: ; Deactivate DTR and disable 6551 interrupts @@ -156,7 +156,7 @@ CLOSE: ; PARAMS routine. A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ; Check if the handshake setting is valid @@ -236,12 +236,13 @@ InvBaud: rts ;---------------------------------------------------------------------------- -; GET: Will fetch a character from the receive buffer and store it into the +; SER_GET: Will fetch a character from the receive buffer and store it into the ; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is ; return. ; -GET: ldx SendFreeCnt ; Send data if necessary +SER_GET: + ldx SendFreeCnt ; Send data if necessary inx ; X == $FF? beq @L1 lda #$00 @@ -280,11 +281,11 @@ GET: ldx SendFreeCnt ; Send data if necessary rts ;---------------------------------------------------------------------------- -; PUT: Output character in A. +; SER_PUT: Output character in A. ; Must return an error code in a/x. ; -PUT: +SER_PUT: ; Try to send @@ -314,11 +315,12 @@ PUT: rts ;---------------------------------------------------------------------------- -; STATUS: Return the status in the variable pointed to by ptr1. +; SER_STATUS: Return the status in the variable pointed to by ptr1. ; Must return an error code in a/x. ; -STATUS: lda #$0F +SER_STATUS: + lda #$0F sta IndReg ldy #ACIA::STATUS lda (acia),y @@ -330,23 +332,25 @@ STATUS: lda #$0F rts ;---------------------------------------------------------------------------- -; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl +; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl ; specific data in ptr1, and the ioctl code in A. ; Must return an error code in a/x. ; -IOCTL: lda #SER_ERR_INV_IOCTL rts ;---------------------------------------------------------------------------- -; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All +; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All ; registers are already save, no parameters are passed, but the carry flag ; is clear on entry. The routine must return with carry set if the interrupt ; was handled, otherwise with carry clear. ; -IRQ: lda #$0F +SER_IRQ: + lda #$0F sta IndReg ; Switch to the system bank ldy #ACIA::STATUS lda (acia),y ; Check ACIA status for receive interrupt @@ -435,4 +439,3 @@ write: pha lda ExecReg sta IndReg rts - diff --git a/libsrc/cbm610/ser/cbm610-std.s b/libsrc/cbm610/ser/cbm610-std.s index 1b2d38aa5..7cdb285bd 100644 --- a/libsrc/cbm610/ser/cbm610-std.s +++ b/libsrc/cbm610/ser/cbm610-std.s @@ -46,15 +46,15 @@ ; Jump table - .word INSTALL - .word UNINSTALL - .word OPEN - .word CLOSE - .word GET - .word PUT - .word STATUS - .word IOCTL - .word IRQ + .word SER_INSTALL + .word SER_UNINSTALL + .word SER_OPEN + .word SER_CLOSE + .word SER_GET + .word SER_PUT + .word SER_STATUS + .word SER_IOCTL + .word SER_IRQ ;---------------------------------------------------------------------------- ; @@ -122,25 +122,25 @@ ParityTable: .code ;---------------------------------------------------------------------------- -; INSTALL routine. Is called after the driver is loaded into memory. If +; SER_INSTALL routine. Is called after the driver is loaded into memory. If ; possible, check if the hardware is present. ; Must return an SER_ERR_xx code in a/x. ; ; Since we don't have to manage the IRQ vector on the Plus/4, this is actually ; the same as: ; -; UNINSTALL routine. Is called before the driver is removed from memory. +; SER_UNINSTALL routine. Is called before the driver is removed from memory. ; Must return an SER_ERR_xx code in a/x. ; ; and: ; -; CLOSE: Close the port, disable interrupts and flush the buffer. Called +; SER_CLOSE: Close the port, disable interrupts and flush the buffer. Called ; without parameters. Must return an error code in a/x. ; -INSTALL: -UNINSTALL: -CLOSE: +SER_INSTALL: +SER_UNINSTALL: +SER_CLOSE: ; Deactivate DTR and disable 6551 interrupts @@ -157,7 +157,7 @@ CLOSE: ; PARAMS routine. A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ; Check if the handshake setting is valid @@ -237,12 +237,13 @@ InvBaud: rts ;---------------------------------------------------------------------------- -; GET: Will fetch a character from the receive buffer and store it into the +; SER_GET: Will fetch a character from the receive buffer and store it into the ; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is ; return. ; -GET: ldx SendFreeCnt ; Send data if necessary +SER_GET: + ldx SendFreeCnt ; Send data if necessary inx ; X == $FF? beq @L1 lda #$00 @@ -281,11 +282,11 @@ GET: ldx SendFreeCnt ; Send data if necessary rts ;---------------------------------------------------------------------------- -; PUT: Output character in A. +; SER_PUT: Output character in A. ; Must return an error code in a/x. ; -PUT: +SER_PUT: ; Try to send @@ -315,11 +316,12 @@ PUT: rts ;---------------------------------------------------------------------------- -; STATUS: Return the status in the variable pointed to by ptr1. +; SER_STATUS: Return the status in the variable pointed to by ptr1. ; Must return an error code in a/x. ; -STATUS: lda #$0F +SER_STATUS: + lda #$0F sta IndReg ldy #ACIA::STATUS lda (acia),y @@ -331,23 +333,25 @@ STATUS: lda #$0F rts ;---------------------------------------------------------------------------- -; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl +; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl ; specific data in ptr1, and the ioctl code in A. ; Must return an error code in a/x. ; -IOCTL: lda #SER_ERR_INV_IOCTL rts ;---------------------------------------------------------------------------- -; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All +; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All ; registers are already save, no parameters are passed, but the carry flag ; is clear on entry. The routine must return with carry set if the interrupt ; was handled, otherwise with carry clear. ; -IRQ: lda #$0F +SER_IRQ: + lda #$0F sta IndReg ; Switch to the system bank ldy #ACIA::STATUS lda (acia),y ; Check ACIA status for receive interrupt @@ -436,4 +440,3 @@ write: pha lda ExecReg sta IndReg rts - diff --git a/libsrc/common/getcpu.s b/libsrc/common/getcpu.s index 169c56bbd..ab6a8aef9 100644 --- a/libsrc/common/getcpu.s +++ b/libsrc/common/getcpu.s @@ -3,7 +3,7 @@ ; ; unsigned char getcpu (void); ; - + .include "zeropage.inc" .export _getcpu ; --------------------------------------------------------------------------- @@ -17,6 +17,7 @@ ; - carry set and 5 in A for a 65CE02 ; - carry set and 6 in A for a HuC6280 ; - carry clear and 7 in A for a 2a03/2a07 +; - carry set and 8 in A for a 45GS02 ; ; This function uses a $1A opcode which is a INA on the 816 and ignored ; (interpreted as a NOP) on a NMOS 6502. There are several CMOS versions @@ -26,52 +27,95 @@ .p816 ; Enable 65816 instructions _getcpu: + lda #0 inc a ; .byte $1A ; nop on nmos, inc on every cmos cmp #1 - bcc @L8 + bcc @IsNMOS ; This is at least a 65C02, check for a 65CE02/4510 .byte $42,$EA ; neg on 65CE02/4510, nop #$EA on 65C02, wdm $EA on 65816 cmp #1 - beq @L6 + beq @HasINCA ; This is at least a 65CE02, check for 4510 lda #5 ; CPU_65CE02 constant + ldx #0 ; to make sure MAP doesn't do anything, the upper nybl of X and Z must be clear .byte $5C ; map on 4510, aug on 65CE02 (acts like 4 byte nop) lda #3 ; CPU_4510 constant nop - bne @L9 + cmp #5 + beq @LoadXAndReturn + +; It is either a 4510 (C65) or a 45GS02 (MEGA65) + + ; 45GS02 supports 32-bit ZP indirect, so use that to check CPU type + ; without requiring a functioning MEGA65 hypervisor. + ; We setup a read of $200xx, then store a different value in $xx + ; and then re-read $200xx to see if it is unchanged. + + ; Setup 32-bit pointer to $00020000+tmp1 + lda #<$020000+tmp1 + sta regsave + lda #>$020000+tmp1 + sta regsave+1 + sta regsave+3 ; also write to upper byte of pointer to save an extra LDA #$00 + lda #^$020000+tmp1 + sta regsave+2 + + ; Prefixing LDA ($nn),Z with a NOP uses 32-bit ZP pointer on 45GS02, + ; but normal 16-bit ZP pointer on 4510 + ; (We assume Z=$00, which will be the normal case) + nop ; prefix to tell next instruction to be 32-bit ZP + .byte $b2,regsave ; LDA (regsave),Z + eor #$ff ; change the value + sta tmp1 ; store in $xx + ; now try again to load it: If the same, then 45GS02, as $200xx is unchanged + nop ; prefix to tell next instruction to be 32-bit ZP + .byte $b2,regsave ; LDA (regsave),Z + cmp tmp1 ; does the loaded value match what is in $xx? + bne @Is45GS02 ; $200xx and $xx have different values, so must be a MEGA65 45GS02 +@Is4510: + lda #3 ; CPU_4510 constant + ldx #0 ; load high byte of word + rts + +@Is45GS02: + lda #8 ; CPU_45GS02 constant + ldx #0 ; load high byte of word + rts ; 6502 type of cpu, check for a 2a03/2a07 -@L8: +@IsNMOS: sed ; set decimal mode, no decimal mode on the 2a03/2a07 lda #9 clc adc #1 ; $01+$09 = $10 on 6502, $01+$09 = $0A on 2a03/2a07 cld cmp #$0a - beq @L5 + beq @Is2a03 lda #0 ; CPU_6502 constant - beq @L9 -@L5: + beq @LoadXAndReturn +@Is2a03: lda #7 ; CPU_2A0x constant - bne @L9 + bne @LoadXAndReturn ; 65C02 cpu type, check for HuC6280 -@L4: ldx #6 ; CPU_HUC6280 constant +@CheckHuC6280: + ldx #6 ; CPU_HUC6280 constant .byte $22,$EA ; sax nop on HuC6280 (A=$06, X=$01), nop #$EA on 65C02 (A=$01, X=$06) - bne @L9 + bne @LoadXAndReturn ; Check for 65816/65802 -@L6: xba ; .byte $EB, put $01 in B accu (nop on 65C02/65SC02) +@HasINCA: + xba ; .byte $EB, put $01 in B accu (nop on 65C02/65SC02) dec a ; .byte $3A, A=$00 xba ; .byte $EB, A=$01 if 65816/65802 and A=$00 if 65C02/65SC02 inc a ; .byte $1A, A=$02 if 65816/65802 and A=$01 if 65C02/65SC02 cmp #2 - beq @L9 + beq @LoadXAndReturn ; check for 65SC02 @@ -82,9 +126,8 @@ _getcpu: ldx $F7 sty $F7 cpx #$00 - bne @L4 + bne @CheckHuC6280 lda #4 ; CPU_65SC02 constant - -@L9: ldx #0 ; Load high byte of word +@LoadXAndReturn: + ldx #0 rts - diff --git a/libsrc/geos-cbm/graph/setnewmode.s b/libsrc/geos-cbm/graph/setnewmode.s new file mode 100644 index 000000000..1d63cf78e --- /dev/null +++ b/libsrc/geos-cbm/graph/setnewmode.s @@ -0,0 +1,18 @@ +; +; Scott Hutter +; +; 18.12.18 + +; void SetNewMode(void); + + .export _SetNewMode + + .include "jumptab.inc" + .include "geossym.inc" + +_SetNewMode: + lda graphMode + eor #$80 + sta graphMode + jmp SetNewMode + diff --git a/libsrc/lynx/lynx-snd.s b/libsrc/lynx/lynx-snd.s index 9d0b8b7af..82b05276f 100644 --- a/libsrc/lynx/lynx-snd.s +++ b/libsrc/lynx/lynx-snd.s @@ -1062,7 +1062,7 @@ SndSetValues: ldx #4-1 set0: ldy SndOffsets,x lda SndChannel+2,y - _IFNE ; flag == 0 => don`t set + _IFNE ; flag == 0 => don't set bit #$80 _IFNE ; diff --git a/libsrc/lynx/ser/lynx-comlynx.s b/libsrc/lynx/ser/lynx-comlynx.s index 1fd24ad94..ded862eaa 100644 --- a/libsrc/lynx/ser/lynx-comlynx.s +++ b/libsrc/lynx/ser/lynx-comlynx.s @@ -25,15 +25,15 @@ .addr $0000 ; Jump table - .addr INSTALL - .addr UNINSTALL - .addr OPEN - .addr CLOSE - .addr GET - .addr PUT - .addr STATUS - .addr IOCTL - .addr IRQ + .addr SER_INSTALL + .addr SER_UNINSTALL + .addr SER_OPEN + .addr SER_CLOSE + .addr SER_GET + .addr SER_PUT + .addr SER_STATUS + .addr SER_IOCTL + .addr SER_IRQ ;---------------------------------------------------------------------------- ; Global variables @@ -54,25 +54,25 @@ TxDone: .res 1 .code ;---------------------------------------------------------------------------- -; INSTALL: Is called after the driver is loaded into memory. +; SER_INSTALL: Is called after the driver is loaded into memory. ; ; Must return an SER_ERR_xx code in a/x. -INSTALL: +SER_INSTALL: ; Set up IRQ vector ? ;---------------------------------------------------------------------------- -; UNINSTALL: Is called before the driver is removed from memory. +; SER_UNINSTALL: Is called before the driver is removed from memory. ; No return code required (the driver is removed from memory on return). ; -UNINSTALL: +SER_UNINSTALL: ;---------------------------------------------------------------------------- -; CLOSE: Close the port and disable interrupts. Called without parameters. +; SER_CLOSE: Close the port and disable interrupts. Called without parameters. ; Must return an SER_ERR_xx code in a/x. -CLOSE: +SER_CLOSE: ; Disable interrupts ; Done, return an error code lda #SER_ERR_INV_IOCTL rts ;---------------------------------------------------------------------------- -; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All +; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All ; registers are already saved, no parameters are passed, but the carry flag ; is clear on entry. The routine must return with carry set if the interrupt ; was handled, otherwise with carry clear. @@ -330,7 +330,7 @@ IOCTL: ; Both the Tx and Rx interrupts are level sensitive instead of edge sensitive. ; Due to this bug you have to disable the interrupt before clearing it. -IRQ: +SER_IRQ: lda INTSET ; Poll all pending interrupts and #SERIAL_INTERRUPT bne @L0 @@ -411,4 +411,3 @@ IRQ: @IRQexit: clc rts - diff --git a/libsrc/plus4/cgetc.s b/libsrc/plus4/cgetc.s index fcbc66064..62863c06e 100644 --- a/libsrc/plus4/cgetc.s +++ b/libsrc/plus4/cgetc.s @@ -7,6 +7,7 @@ .export _cgetc .import cursor + .include "cbm_kernal.inc" .include "plus4.inc" ; -------------------------------------------------------------------------- diff --git a/libsrc/plus4/clrscr.s b/libsrc/plus4/clrscr.s index 720a5e6e4..a67016255 100644 --- a/libsrc/plus4/clrscr.s +++ b/libsrc/plus4/clrscr.s @@ -6,6 +6,7 @@ .export _clrscr + .include "cbm_kernal.inc" .include "plus4.inc" .segment "LOWCODE" ; Must go into low memory @@ -16,9 +17,3 @@ sta ENABLE_RAM ; Switch back to RAM rts ; Return to caller .endproc - - - - - - diff --git a/libsrc/plus4/ser/plus4-stdser.s b/libsrc/plus4/ser/plus4-stdser.s index 6cacff327..bb44a4cf9 100644 --- a/libsrc/plus4/ser/plus4-stdser.s +++ b/libsrc/plus4/ser/plus4-stdser.s @@ -45,15 +45,15 @@ ; Jump table - .word INSTALL - .word UNINSTALL - .word OPEN - .word CLOSE - .word GET - .word PUT - .word STATUS - .word IOCTL - .word IRQ + .word SER_INSTALL + .word SER_UNINSTALL + .word SER_OPEN + .word SER_CLOSE + .word SER_GET + .word SER_PUT + .word SER_STATUS + .word SER_IOCTL + .word SER_IRQ ;---------------------------------------------------------------------------- ; I/O definitions @@ -130,25 +130,25 @@ ParityTable: .code ;---------------------------------------------------------------------------- -; INSTALL routine. Is called after the driver is loaded into memory. If +; SER_INSTALL routine. Is called after the driver is loaded into memory. If ; possible, check if the hardware is present. ; Must return an SER_ERR_xx code in a/x. ; ; Since we don't have to manage the IRQ vector on the Plus/4, this is actually ; the same as: ; -; UNINSTALL routine. Is called before the driver is removed from memory. +; SER_UNINSTALL routine. Is called before the driver is removed from memory. ; Must return an SER_ERR_xx code in a/x. ; ; and: ; -; CLOSE: Close the port, disable interrupts and flush the buffer. Called +; SER_CLOSE: Close the port, disable interrupts and flush the buffer. Called ; without parameters. Must return an error code in a/x. ; -INSTALL: -UNINSTALL: -CLOSE: +SER_INSTALL: +SER_UNINSTALL: +SER_CLOSE: ; Deactivate DTR and disable 6551 interrupts @@ -165,7 +165,7 @@ CLOSE: ; PARAMS routine. A pointer to a ser_params structure is passed in ptr1. ; Must return an SER_ERR_xx code in a/x. -OPEN: +SER_OPEN: ; Check if the handshake setting is valid @@ -244,12 +244,13 @@ InvBaud: rts ;---------------------------------------------------------------------------- -; GET: Will fetch a character from the receive buffer and store it into the +; SER_GET: Will fetch a character from the receive buffer and store it into the ; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is ; return. ; -GET: ldx SendFreeCnt ; Send data if necessary +SER_GET: + ldx SendFreeCnt ; Send data if necessary inx ; X == $FF? beq @L1 lda #$00 @@ -288,11 +289,11 @@ GET: ldx SendFreeCnt ; Send data if necessary rts ;---------------------------------------------------------------------------- -; PUT: Output character in A. +; SER_PUT: Output character in A. ; Must return an error code in a/x. ; -PUT: +SER_PUT: ; Try to send @@ -322,34 +323,37 @@ PUT: rts ;---------------------------------------------------------------------------- -; STATUS: Return the status in the variable pointed to by ptr1. +; SER_STATUS: Return the status in the variable pointed to by ptr1. ; Must return an error code in a/x. ; -STATUS: lda ACIA_STATUS +SER_STATUS: + lda ACIA_STATUS ldx #0 sta (ptr1,x) txa ; SER_ERR_OK rts ;---------------------------------------------------------------------------- -; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl +; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl ; specific data in ptr1, and the ioctl code in A. ; Must return an error code in a/x. ; -IOCTL: lda #SER_ERR_INV_IOCTL rts ; Run into IRQ instead ;---------------------------------------------------------------------------- -; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All +; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All ; registers are already save, no parameters are passed, but the carry flag ; is clear on entry. The routine must return with carry set if the interrupt ; was handled, otherwise with carry clear. ; -IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt +SER_IRQ: + lda ACIA_STATUS ; Check ACIA status for receive interrupt and #$08 beq @L9 ; Jump if no ACIA interrupt (carry still clear) lda ACIA_DATA ; Get byte from ACIA @@ -405,5 +409,3 @@ IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt jmp @L0 .endproc - - diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index 54af4780e..8a3126d72 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -78,7 +78,7 @@ L0: asl ptr1 ; Do a subtraction. we do not have enough space to store the intermediate ; result, so we may have to do the subtraction twice. - pha + tax cmp ptr3 lda ptr2+1 sbc ptr3+1 @@ -91,9 +91,9 @@ L0: asl ptr1 ; Overflow, do the subtraction again, this time store the result sta tmp4 ; We have the high byte already - pla + txa sbc ptr3 ; byte 0 - pha + tax lda ptr2+1 sbc ptr3+1 sta ptr2+1 ; byte 1 @@ -102,7 +102,7 @@ L0: asl ptr1 sta tmp3 ; byte 2 inc ptr1 ; Set result bit -L1: pla +L1: txa dey bne L0 sta ptr2 diff --git a/libsrc/runtime/udiv32by16r16.s b/libsrc/runtime/udiv32by16r16.s index 9897f9908..27f1176dd 100644 --- a/libsrc/runtime/udiv32by16r16.s +++ b/libsrc/runtime/udiv32by16r16.s @@ -34,19 +34,19 @@ L0: asl ptr1 rol a rol sreg+1 - pha + tax cmp ptr3 lda sreg+1 sbc ptr3+1 bcc L1 sta sreg+1 - pla + txa sbc ptr3 - pha + tax inc ptr1 -L1: pla +L1: txa dey bne L0 sta sreg diff --git a/libsrc/runtime/umul16x16r32.s b/libsrc/runtime/umul16x16r32.s index 9ecd1596e..cd2dae351 100644 --- a/libsrc/runtime/umul16x16r32.s +++ b/libsrc/runtime/umul16x16r32.s @@ -42,11 +42,11 @@ umul16x16r16m: clc adc ptr3 - pha + tax lda ptr3+1 adc sreg+1 sta sreg+1 - pla + txa @L1: ror sreg+1 ror a diff --git a/libsrc/runtime/umul8x16r24.s b/libsrc/runtime/umul8x16r24.s index ff7d0bae6..c006082a4 100644 --- a/libsrc/runtime/umul8x16r24.s +++ b/libsrc/runtime/umul8x16r24.s @@ -9,6 +9,7 @@ .include "zeropage.inc" + .macpack cpu ;--------------------------------------------------------------------------- ; 8x16 => 24 unsigned multiplication routine. Because the overhead for a @@ -30,9 +31,14 @@ umul8x16r16: umul8x16r24m: umul8x16r16m: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr1+1 + stz sreg +.else ldx #0 stx ptr1+1 stx sreg +.endif ldy #8 ; Number of bits ldx ptr3 ; Get into register for speed diff --git a/libsrc/telestrat/cgetc.s b/libsrc/telestrat/cgetc.s index 6a6b23318..cad8814af 100644 --- a/libsrc/telestrat/cgetc.s +++ b/libsrc/telestrat/cgetc.s @@ -2,27 +2,27 @@ ; jede jede@oric.org 2017-10-01 ; .export _cgetc - + .import cursor - + .include "telestrat.inc" .proc _cgetc - ; this routine could be quicker if we wrote in page 2 variables, + ; this routine could be quicker if we wrote in page 2 variables, ; but it's better to use telemon routine in that case, because telemon can manage 4 I/O ldx cursor ; if cursor equal to 0, then switch off cursor beq switchoff_cursor - + ldx #$00 ; x is the first screen BRK_TELEMON(XCSSCR) ; display cursor jmp loop ; could be replaced by a bne/beq but 'jmp' is cleaner than a bne/beq which could expect some matters - -switchoff_cursor: + +switchoff_cursor: ; at this step X is equal to $00, X must be set, because it's the id of the screen (telestrat can handle 4 virtuals screen) - BRK_TELEMON(XCOSCR) ; switch off cursor - -loop: + BRK_TELEMON(XCOSCR) ; switch off cursor + +loop: BRK_TELEMON XRD0 ; waits until key is pressed bcs loop rts -.endproc +.endproc diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 40e2c10b3..17f6327f0 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -1,16 +1,16 @@ ; jede jede@oric.org 2017-01-22 .export _close - - .import addysp,popax - - .include "zeropage.inc" + + .import addysp,popax + + .include "zeropage.inc" .include "telestrat.inc" .include "errno.inc" - .include "fcntl.inc" - + .include "fcntl.inc" + ; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _close - BRK_TELEMON XCLOSE ; launch primitive ROM + BRK_TELEMON XCLOSE ; launch primitive ROM rts .endproc diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s index 31c8ee205..1f90a7ca5 100644 --- a/libsrc/telestrat/clrscr.s +++ b/libsrc/telestrat/clrscr.s @@ -1,16 +1,16 @@ ; ; jede jede@oric.org 2017-02-25 -; +; .export _clrscr - + .importzp sp - + .include "telestrat.inc" .proc _clrscr ; Switch to text mode - BRK_TELEMON(XTEXT) + BRK_TELEMON(XTEXT) lda #SCREEN @@ -21,18 +21,18 @@ ldx #>(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE) lda #' ' BRK_TELEMON XFILLM - - + + ; reset prompt position lda #<(SCREEN+40) sta ADSCRL lda #>(SCREEN+40) sta ADSCRH - + ; reset display position lda #$01 sta SCRY lda #$00 - sta SCRX + sta SCRX rts -.endproc +.endproc diff --git a/libsrc/telestrat/gotox.s b/libsrc/telestrat/gotox.s index d6af0e4dd..f16c05b71 100644 --- a/libsrc/telestrat/gotox.s +++ b/libsrc/telestrat/gotox.s @@ -2,9 +2,9 @@ ; jede jede@oric.org 2017-02-25 ; .export _gotox - + .import popa - + .importzp sp .include "telestrat.inc" @@ -13,4 +13,4 @@ .proc _gotox sta SCRX rts -.endproc +.endproc diff --git a/libsrc/telestrat/gotoy.s b/libsrc/telestrat/gotoy.s index ed7101c80..05ed71de7 100644 --- a/libsrc/telestrat/gotoy.s +++ b/libsrc/telestrat/gotoy.s @@ -10,4 +10,4 @@ .proc _gotoy sta SCRY rts -.endproc +.endproc diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index 0c9e799da..b7ffb4ec7 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -24,28 +24,28 @@ initmainargs: ldx #0 ; Limit the length L0: lda BUFEDT,x - beq L3 - cmp #' ' - bne L1 - lda #0 - beq L3 + beq L3 + cmp #' ' + bne L1 + lda #0 + beq L3 L1: sta name,x inx - cpx #FNAME_LEN + cpx #FNAME_LEN bne L0 - lda #0 -L3: - sta name,x + lda #0 +L3: + sta name,x inc __argc ; argc always is equal to, at least, 1 - + ldy #1 * 2 ; Point to second argv slot - + next: lda BUFEDT,x beq done ; End of line reached inx cmp #' ' ; Skip leading spaces - beq next + beq next found: cmp #'"' ; Is the argument quoted? beq setterm ; Jump if so @@ -58,12 +58,12 @@ setterm:sta term ; Set end of argument marker txa ; Get low byte clc - adc #BUFEDT sta argv+1,y iny @@ -92,16 +92,16 @@ argloop:lda BUFEDT,x lda __argc ; Get low byte of argument count cmp #MAXARGS ; Maximum number of arguments reached? - bcc next ; Parse next one if not - - + bcc next ; Parse next one if not + + done: lda #argv sta __argv stx __argv + 1 rts - - + + .segment "INIT" term: .res 1 @@ -113,8 +113,8 @@ name: .res FNAME_LEN + 1 args: .res SCREEN_XSIZE * 2 - 1 param_found: - .res 1 + .res 1 ; char* argv[MAXARGS+1]={name}; -argv: - .addr name +argv: + .addr name .res MAXARGS * 2 diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index 08910f4f2..f59d3d31a 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -1,13 +1,13 @@ .export _open - + .import addysp,popax - + .importzp sp,tmp2,tmp3,tmp1 - - + + .include "telestrat.inc" .include "errno.inc" - .include "fcntl.inc" + .include "fcntl.inc" ; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _open @@ -17,8 +17,8 @@ dey ; ...checked (it generates a c compiler warning) dey dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 @@ -26,8 +26,8 @@ parmok: jsr popax ; Get flagss sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 75766cda2..76de9d0ac 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -8,7 +8,7 @@ .include "zeropage.inc" .include "telestrat.inc" - + ;int read (int fd, void* buf, unsigned count); .proc _read @@ -20,22 +20,20 @@ stx PTR_READ_DEST+1 sta ptr2 ; in order to calculate nb of bytes read stx ptr2+1 ; - + ; jsr popax ; fp pointer don't care in this version - lda ptr1 ; + lda ptr1 ; ldy ptr1+1 ; BRK_TELEMON XFREAD ; calls telemon30 routine ; compute nb of bytes read lda PTR_READ_DEST+1 sec sbc ptr2+1 - tax + tax lda PTR_READ_DEST sec sbc ptr2 ; Here A and X contains number of bytes read rts .endproc - - diff --git a/libsrc/telestrat/tgi/telestrat-228-200-3.s b/libsrc/telestrat/tgi/telestrat-228-200-3.s index ce501f0bf..228bdce99 100644 --- a/libsrc/telestrat/tgi/telestrat-228-200-3.s +++ b/libsrc/telestrat/tgi/telestrat-228-200-3.s @@ -170,7 +170,7 @@ CONTROL: ; CLEAR: - ; not done yet + BRK_TELEMON(XEFFHI) rts ; ------------------------------------------------------------------------ diff --git a/libsrc/telestrat/tgi/telestrat-240-200-2.s b/libsrc/telestrat/tgi/telestrat-240-200-2.s index 3ee918c4f..9bffebb0c 100644 --- a/libsrc/telestrat/tgi/telestrat-240-200-2.s +++ b/libsrc/telestrat/tgi/telestrat-240-200-2.s @@ -169,7 +169,7 @@ CONTROL: ; CLEAR: - ; not done yet + BRK_TELEMON(XEFFHI) rts ; ------------------------------------------------------------------------ diff --git a/libsrc/telestrat/wherex.s b/libsrc/telestrat/wherex.s index 0dd5139e1..8616003c8 100644 --- a/libsrc/telestrat/wherex.s +++ b/libsrc/telestrat/wherex.s @@ -2,7 +2,7 @@ ; jede jede@oric.org 2017-02-25 ; .export _wherex - + .importzp sp .include "telestrat.inc" @@ -11,4 +11,4 @@ ldx #$00 lda SCRX rts -.endproc +.endproc diff --git a/libsrc/telestrat/wherey.s b/libsrc/telestrat/wherey.s index 962608ca2..c05b5f5c8 100644 --- a/libsrc/telestrat/wherey.s +++ b/libsrc/telestrat/wherey.s @@ -1,12 +1,12 @@ ; ; jede jede@oric.org 2017-02-25 -; +; .export _wherey - + .include "telestrat.inc" .proc _wherey ldx #$00 lda SCRY rts -.endproc +.endproc diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 6498283fb..68aef42d6 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -23,34 +23,34 @@ jsr popax ; get fd and discard ; if fd=0001 then it stdout - cpx #0 - beq next - jmp L1 -next: - cmp #1 - beq L1 - + cpx #0 + beq next + jmp L1 +next: + cmp #1 + beq L1 + ; here it's a file opened - lda ptr1 - sta PTR_READ_DEST - lda ptr1+1 - sta PTR_READ_DEST+1 - lda ptr3 - ldy ptr3+1 + lda ptr1 + sta PTR_READ_DEST + lda ptr1+1 + sta PTR_READ_DEST+1 + lda ptr3 + ldy ptr3+1 BRK_TELEMON XFWRITE ; compute nb of bytes written - + lda PTR_READ_DEST+1 sec sbc ptr1+1 - tax + tax lda PTR_READ_DEST sec sbc ptr1 rts - - + + L1: inc ptr2 bne L2 inc ptr2+1 @@ -63,10 +63,10 @@ L2: ldy #0 BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms) lda #$0D ; return to the beggining of the line BRK_TELEMON XWR0 ; macro - + ldx #$0D -L3: +L3: BRK_TELEMON XWR0 ; macro inc ptr1 @@ -81,5 +81,3 @@ L9: lda ptr3 rts .endproc - - diff --git a/libsrc/vic20/cgetc.s b/libsrc/vic20/cgetc.s index d5af9a9f6..1a5c8d5a2 100644 --- a/libsrc/vic20/cgetc.s +++ b/libsrc/vic20/cgetc.s @@ -7,6 +7,7 @@ .export _cgetc .import cursor + .include "cbm_kernal.inc" .include "vic20.inc" _cgetc: lda KEY_COUNT ; Get number of characters diff --git a/libsrc/vic20/clrscr.s b/libsrc/vic20/clrscr.s index 8d4994eac..a3c519cb1 100644 --- a/libsrc/vic20/clrscr.s +++ b/libsrc/vic20/clrscr.s @@ -6,9 +6,6 @@ .export _clrscr - .include "vic20.inc" + .include "cbm_kernal.inc" _clrscr = CLRSCR - - - diff --git a/samples/Makefile b/samples/Makefile index 601d19d76..74094aeae 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -296,7 +296,7 @@ INSTALL = install samplesdir = $(PREFIX)/share/cc65/samples install: - $(if $(PREFIX),,$(error variable `PREFIX' must be set)) + $(if $(PREFIX),,$(error variable "PREFIX" must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos $(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial diff --git a/samples/atari2600hello.c b/samples/atari2600hello.c index e4f7893b7..4785ad90b 100644 --- a/samples/atari2600hello.c +++ b/samples/atari2600hello.c @@ -25,32 +25,32 @@ void main(void) { bss_v = 0x88; // Testing BSS variable for/*ever*/(;;) { - // Vertical Sync signal - TIA.vsync = 0x02; - TIA.wsync = 0x00; - TIA.wsync = 0x00; - TIA.wsync = 0x00; - TIA.vsync = 0x00; + // Vertical Sync signal + TIA.vsync = 0x02; + TIA.wsync = 0x00; + TIA.wsync = 0x00; + TIA.wsync = 0x00; + TIA.vsync = 0x00; - // Vertical Blank timer setting - RIOT.tim64t = VBLANK_TIM64; + // Vertical Blank timer setting + RIOT.tim64t = VBLANK_TIM64; - // Doing frame computation during blank - TIA.colubk = color++; // Update color + // Doing frame computation during blank + TIA.colubk = color++; // Update color - // Wait for end of Vertical Blank - while (RIOT.timint == 0) {} - TIA.wsync = 0x00; - TIA.vblank = 0x00; // Turn on beam + // Wait for end of Vertical Blank + while (RIOT.timint == 0) {} + TIA.wsync = 0x00; + TIA.vblank = 0x00; // Turn on beam - // Display frame - RIOT.t1024t = KERNAL_T1024; - while (RIOT.timint == 0) {} - TIA.wsync = 0x00; - TIA.vblank = 0x02; // Turn off beam + // Display frame + RIOT.t1024t = KERNAL_T1024; + while (RIOT.timint == 0) {} + TIA.wsync = 0x00; + TIA.vblank = 0x02; // Turn off beam - // Overscan - RIOT.tim64t = OVERSCAN_TIM64; - while (RIOT.timint == 0) {} + // Overscan + RIOT.tim64t = OVERSCAN_TIM64; + while (RIOT.timint == 0) {} } } diff --git a/src/Makefile b/src/Makefile index c1f11ff58..c93a8645f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -107,7 +107,7 @@ $(RM) /usr/local/bin/$(prog) endef # UNAVAIL_recipe install: - $(if $(PREFIX),,$(error variable `PREFIX' must be set)) + $(if $(PREFIX),,$(error variable "PREFIX" must be set)) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) ../bin/* $(DESTDIR)$(bindir) diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index 003a5fa69..a57bec813 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {5E8C19C6-B167-440C-8BEF-3CBF109CDB49} Win32Proj ar65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/ar65/exports.c b/src/ar65/exports.c index b3bb4cebe..b1e133e72 100644 --- a/src/ar65/exports.c +++ b/src/ar65/exports.c @@ -113,8 +113,8 @@ void ExpInsert (const char* Name, const ObjData* Module) while (1) { if (strcmp (L->Name, Name) == 0) { /* Duplicate entry */ - Warning ("External symbol `%s' in module `%s', library `%s', " - "is duplicated in module `%s'", + Warning ("External symbol '%s' in module '%s', library '%s', " + "is duplicated in module '%s'", Name, L->Module->Name, LibName, Module->Name); } if (L->Next == 0) { diff --git a/src/ar65/library.c b/src/ar65/library.c index c72e6e3cf..4d18168d8 100644 --- a/src/ar65/library.c +++ b/src/ar65/library.c @@ -95,11 +95,11 @@ static void ReadHeader (void) /* Read the header fields, checking magic and version */ Header.Magic = Read32 (Lib); if (Header.Magic != LIB_MAGIC) { - Error ("`%s' is not a valid library file", LibName); + Error ("'%s' is not a valid library file", LibName); } Header.Version = Read16 (Lib); if (Header.Version != LIB_VERSION) { - Error ("Wrong data version in `%s'", LibName); + Error ("Wrong data version in '%s'", LibName); } Header.Flags = Read16 (Lib); Header.IndexOffs = Read32 (Lib); @@ -229,11 +229,11 @@ void LibOpen (const char* Name, int MustExist, int NeedTemp) /* File does not exist */ if (MustExist) { - Error ("Library `%s' does not exist", Name); + Error ("Library '%s' does not exist", Name); } else { /* Announce the library's creation if ar65 is verbose. */ Print (stdout, 1, - "%s: Library `%s' will be created.\n", ProgName, Name); + "%s: Library '%s' will be created.\n", ProgName, Name); } } else { @@ -317,7 +317,7 @@ static void LibCheckExports (ObjData* O) unsigned I; /* Let the user know what we do */ - Print (stdout, 2, "Module `%s' (%u exports):\n", O->Name, CollCount (&O->Exports)); + Print (stdout, 2, "Module '%s' (%u exports):\n", O->Name, CollCount (&O->Exports)); /* Insert the exports into the global table */ for (I = 0; I < CollCount (&O->Exports); ++I) { @@ -381,7 +381,7 @@ void LibClose (void) /* Reopen the library and truncate it */ Lib = fopen (LibName, "wb"); if (Lib == 0) { - Error ("Cannot open library `%s' for writing: %s", + Error ("Cannot open library '%s' for writing: %s", LibName, strerror (errno)); } @@ -389,14 +389,14 @@ void LibClose (void) fseek (NewLib, 0, SEEK_SET); while ((Count = fread (Buf, 1, sizeof (Buf), NewLib)) != 0) { if (fwrite (Buf, 1, Count, Lib) != Count) { - Error ("Cannot write to `%s': %s", LibName, strerror (errno)); + Error ("Cannot write to '%s': %s", LibName, strerror (errno)); } } } /* Close both files */ if (Lib && fclose (Lib) != 0) { - Error ("Problem closing `%s': %s", LibName, strerror (errno)); + Error ("Problem closing '%s': %s", LibName, strerror (errno)); } if (NewLib && fclose (NewLib) != 0) { Error ("Problem closing temporary library file: %s", strerror (errno)); diff --git a/src/ar65/objdata.c b/src/ar65/objdata.c index 5a8f0c5fb..252ebe6ab 100644 --- a/src/ar65/objdata.c +++ b/src/ar65/objdata.c @@ -165,5 +165,5 @@ void DelObjData (const char* Module) } /* Not found! */ - Warning ("Module `%s' not found in library `%s'", Module, LibName); + Warning ("Module '%s' not found in library '%s'", Module, LibName); } diff --git a/src/ar65/objfile.c b/src/ar65/objfile.c index 0434f7e59..ac7dccb0d 100644 --- a/src/ar65/objfile.c +++ b/src/ar65/objfile.c @@ -68,7 +68,7 @@ static const char* GetModule (const char* Name) /* Must not end with a path separator */ if (*Module == 0) { - Error ("Cannot make module name from `%s'", Name); + Error ("Cannot make module name from '%s'", Name); } /* Done */ @@ -82,11 +82,11 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name) { H->Magic = Read32 (Obj); if (H->Magic != OBJ_MAGIC) { - Error ("`%s' is not an object file", Name); + Error ("'%s' is not an object file", Name); } H->Version = Read16 (Obj); if (H->Version != OBJ_VERSION) { - Error ("Object file `%s' has wrong version", Name); + Error ("Object file '%s' has wrong version", Name); } H->Flags = Read16 (Obj); H->OptionOffs = Read32 (Obj); @@ -236,7 +236,7 @@ void ObjAdd (const char* Name) /* Open the object file */ FILE* Obj = fopen (Name, "rb"); if (Obj == 0) { - Error ("Could not open `%s': %s", Name, strerror (errno)); + Error ("Could not open '%s': %s", Name, strerror (errno)); } /* Get the modification time of the object file. There's a race condition @@ -248,7 +248,7 @@ void ObjAdd (const char* Name) ** here. */ if (FileStat (Name, &StatBuf) != 0) { - Error ("Cannot stat object file `%s': %s", Name, strerror (errno)); + Error ("Cannot stat object file '%s': %s", Name, strerror (errno)); } /* Read and check the header */ @@ -267,7 +267,7 @@ void ObjAdd (const char* Name) ** and the external one. */ if (difftime ((time_t)O->MTime, StatBuf.st_mtime) > 0.0) { - Warning ("Replacing module `%s' by older version in library `%s'", + Warning ("Replacing module '%s' by older version in library '%s'", O->Name, LibName); } @@ -313,13 +313,13 @@ void ObjExtract (const char* Name) /* Bail out if the module does not exist */ if (O == 0) { - Error ("Module `%s' not found in library `%s'", Module, LibName); + Error ("Module '%s' not found in library '%s'", Module, LibName); } /* Open the output file */ Obj = fopen (Name, "w+b"); if (Obj == 0) { - Error ("Cannot open target file `%s': %s", Name, strerror (errno)); + Error ("Cannot open target file '%s': %s", Name, strerror (errno)); } /* Copy the complete object file data from the library to the new object @@ -329,11 +329,11 @@ void ObjExtract (const char* Name) /* Close the file */ if (fclose (Obj) != 0) { - Error ("Problem closing object file `%s': %s", Name, strerror (errno)); + Error ("Problem closing object file '%s': %s", Name, strerror (errno)); } /* Set access and modification time */ if (SetFileTimes (Name, O->MTime) != 0) { - Error ("Cannot set mod time on `%s': %s", Name, strerror (errno)); + Error ("Cannot set mod time on '%s': %s", Name, strerror (errno)); } } diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index fb7cf2e26..df246a59f 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC} Win32Proj ca65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/ca65/dbginfo.c b/src/ca65/dbginfo.c index 135739fb5..c9dd7ab6d 100644 --- a/src/ca65/dbginfo.c +++ b/src/ca65/dbginfo.c @@ -468,7 +468,7 @@ void DbgInfoCheck (void) /* Search for the symbol name */ S->Sym = SymFindAny (S->Scope, GetStrBuf (S->AsmName)); if (S->Sym == 0) { - PError (&S->Pos, "Assembler symbol `%s' not found", + PError (&S->Pos, "Assembler symbol '%s' not found", GetString (S->AsmName)); } else { /* Set the backlink */ diff --git a/src/ca65/ea65.c b/src/ca65/ea65.c index 2f7c2bfa9..275d90b56 100644 --- a/src/ca65/ea65.c +++ b/src/ca65/ea65.c @@ -133,7 +133,7 @@ void GetEA (EffAddr* A) A->AddrModeSet = AM65_STACK_REL_IND_Y; Consume (IndirectLeave, IndirectExpect); ConsumeComma (); - Consume (TOK_Y, "`Y' expected"); + Consume (TOK_Y, "'Y' expected"); } else { Error ("Syntax error"); } @@ -152,7 +152,7 @@ void GetEA (EffAddr* A) A->AddrModeSet = AM65_DIR_IND; break; default: - Consume (TOK_Y, "`Y' expected"); + Consume (TOK_Y, "'Y' expected"); A->AddrModeSet = AM65_DIR_IND_Y; break; } @@ -173,7 +173,7 @@ void GetEA (EffAddr* A) if (CurTok.Tok == TOK_COMMA) { /* [dir],y */ NextTok (); - Consume (TOK_Y, "`Y' expected"); + Consume (TOK_Y, "'Y' expected"); A->AddrModeSet = AM65_DIR_IND_LONG_Y; } else { /* [dir] */ diff --git a/src/ca65/enum.c b/src/ca65/enum.c index f0561b692..339b3230f 100644 --- a/src/ca65/enum.c +++ b/src/ca65/enum.c @@ -146,7 +146,7 @@ void DoEnum (void) } /* End of enum definition */ - Consume (TOK_ENDENUM, "`.ENDENUM' expected"); + Consume (TOK_ENDENUM, "'.ENDENUM' expected"); /* Free the base expression */ FreeExpr (BaseExpr); diff --git a/src/ca65/expr.c b/src/ca65/expr.c index ff4232c00..982bb05c6 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -699,7 +699,7 @@ static ExprNode* FuncAddrSize (void) /* Cheap local symbol */ Sym = SymFindLocal (SymLast, &CurTok.SVal, SYM_FIND_EXISTING); if (Sym == 0) { - Error ("Unknown symbol or scope: `%m%p'", &CurTok.SVal); + Error ("Unknown symbol or scope: '%m%p'", &CurTok.SVal); } else { AddrSize = Sym->AddrSize; } @@ -739,13 +739,13 @@ static ExprNode* FuncAddrSize (void) if (Sym) { AddrSize = Sym->AddrSize; } else { - Error ("Unknown symbol or scope: `%m%p%m%p'", &ScopeName, &Name); + Error ("Unknown symbol or scope: '%m%p%m%p'", &ScopeName, &Name); } } if (AddrSize == 0) { - Warning (1, "Unknown address size: `%m%p%m%p'", &ScopeName, &Name); + Warning (1, "Unknown address size: '%m%p%m%p'", &ScopeName, &Name); } /* Free the string buffers */ @@ -780,7 +780,7 @@ static ExprNode* FuncSizeOf (void) /* Cheap local symbol */ Sym = SymFindLocal (SymLast, &CurTok.SVal, SYM_FIND_EXISTING); if (Sym == 0) { - Error ("Unknown symbol or scope: `%m%p'", &CurTok.SVal); + Error ("Unknown symbol or scope: '%m%p'", &CurTok.SVal); } else { SizeSym = GetSizeOfSymbol (Sym); } @@ -832,7 +832,7 @@ static ExprNode* FuncSizeOf (void) if (Sym) { SizeSym = GetSizeOfSymbol (Sym); } else { - Error ("Unknown symbol or scope: `%m%p%m%p'", + Error ("Unknown symbol or scope: '%m%p%m%p'", &ScopeName, &Name); } } @@ -840,7 +840,7 @@ static ExprNode* FuncSizeOf (void) /* Check if we have a size */ if (SizeSym == 0 || !SymIsConst (SizeSym, &Size)) { - Error ("Size of `%m%p%m%p' is unknown", &ScopeName, &Name); + Error ("Size of '%m%p%m%p' is unknown", &ScopeName, &Name); Size = 0; } diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 0fb766b6f..b11345338 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -65,6 +65,7 @@ static const char* const FeatureKeys[FEAT_COUNT] = { "underline_in_numbers", "addrsize", "bracket_as_indirect", + "string_escapes", }; @@ -123,6 +124,7 @@ feature_t SetFeature (const StrBuf* Key) case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break; case FEAT_ADDRSIZE: AddrSize = 1; break; case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = 1; break; + case FEAT_STRING_ESCAPES: StringEscapes = 1; break; default: /* Keep gcc silent */ break; } diff --git a/src/ca65/feature.h b/src/ca65/feature.h index 050c197f0..876f3c4a8 100644 --- a/src/ca65/feature.h +++ b/src/ca65/feature.h @@ -67,6 +67,7 @@ typedef enum { FEAT_UNDERLINE_IN_NUMBERS, FEAT_ADDRSIZE, FEAT_BRACKET_AS_INDIRECT, + FEAT_STRING_ESCAPES, /* Special value: Number of features available */ FEAT_COUNT diff --git a/src/ca65/filetab.c b/src/ca65/filetab.c index ce4b15c03..4ca32631e 100644 --- a/src/ca65/filetab.c +++ b/src/ca65/filetab.c @@ -211,7 +211,7 @@ unsigned GetFileIndex (const StrBuf* Name) /* If we don't have this index, print a diagnostic and use the main file */ if (F == 0) { - Error ("File name `%m%p' not found in file table", Name); + Error ("File name '%m%p' not found in file table", Name); return 0; } else { return F->Index; @@ -316,7 +316,7 @@ static void CreateDepFile (const char* Name, FileType Types) /* Open the file */ FILE* F = fopen (Name, "w"); if (F == 0) { - Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot open dependency file '%s': %s", Name, strerror (errno)); } /* Print the output file followed by a tab char */ diff --git a/src/ca65/global.c b/src/ca65/global.c index 31e599f00..a216fc406 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -66,6 +66,7 @@ unsigned char DbgSyms = 0; /* Add debug symbols */ unsigned char LineCont = 0; /* Allow line continuation */ unsigned char LargeAlignment = 0; /* Don't warn about large alignments */ unsigned char RelaxChecks = 0; /* Relax a few assembler checks */ +unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */ /* Emulation features */ unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */ @@ -84,4 +85,3 @@ unsigned char ForceRange = 0; /* Force values into expected range */ unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */ unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */ unsigned char BracketAsIndirect = 0; /* Use '[]' not '()' for indirection */ - diff --git a/src/ca65/global.h b/src/ca65/global.h index 397d9221b..77d90beca 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -68,6 +68,7 @@ extern unsigned char DbgSyms; /* Add debug symbols */ extern unsigned char LineCont; /* Allow line continuation */ extern unsigned char LargeAlignment; /* Don't warn about large alignments */ extern unsigned char RelaxChecks; /* Relax a few assembler checks */ +extern unsigned char StringEscapes; /* Allow C-style escapes in strings */ /* Emulation features */ extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */ diff --git a/src/ca65/listing.c b/src/ca65/listing.c index b3f3d9282..9f2396612 100644 --- a/src/ca65/listing.c +++ b/src/ca65/listing.c @@ -304,7 +304,7 @@ void CreateListing (void) /* Open the real listing file */ F = fopen (SB_GetConstBuf (&ListingName), "w"); if (F == 0) { - Fatal ("Cannot open listing file `%s': %s", + Fatal ("Cannot open listing file '%s': %s", SB_GetConstBuf (&ListingName), strerror (errno)); } diff --git a/src/ca65/macro.c b/src/ca65/macro.c index 1f6812ce0..988493976 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -375,7 +375,7 @@ static void MacSkipDef (unsigned Style) if (CurTok.Tok != TOK_EOF) { SkipUntilSep (); } else { - Error ("`.ENDMACRO' expected"); + Error ("'.ENDMACRO' expected"); } } else { /* Skip until end of line */ @@ -409,7 +409,7 @@ void MacDef (unsigned Style) /* Did we already define that macro? */ if (HT_Find (&MacroTab, &CurTok.SVal) != 0) { /* Macro is already defined */ - Error ("A macro named `%m%p' is already defined", &CurTok.SVal); + Error ("A macro named '%m%p' is already defined", &CurTok.SVal); /* Skip tokens until we reach the final .endmacro */ MacSkipDef (Style); return; @@ -451,7 +451,7 @@ void MacDef (unsigned Style) IdDesc* List = M->Params; while (1) { if (SB_Compare (&List->Id, &CurTok.SVal) == 0) { - Error ("Duplicate symbol `%m%p'", &CurTok.SVal); + Error ("Duplicate symbol '%m%p'", &CurTok.SVal); } if (List->Next == 0) { break; @@ -500,7 +500,7 @@ void MacDef (unsigned Style) } /* May not have end of file in a macro definition */ if (CurTok.Tok == TOK_EOF) { - Error ("`.ENDMACRO' expected"); + Error ("'.ENDMACRO' expected"); goto Done; } } else { @@ -930,7 +930,7 @@ static void StartExpDefine (MacExp* E) if (CurTok.Tok == TOK_COMMA) { NextTok (); } else { - Error ("`,' expected"); + Error ("',' expected"); } } } diff --git a/src/ca65/main.c b/src/ca65/main.c index fbca2beac..33e0a74b5 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -168,7 +168,7 @@ static void NewSymbol (const char* SymName, long Val) /* Check if have already a symbol with this name */ if (SymIsDef (Sym)) { - AbEnd ("`%s' is already defined", SymName); + AbEnd ("'%s' is already defined", SymName); } /* Generate an expression for the symbol */ @@ -201,7 +201,7 @@ static void SetSys (const char* Sys) break; case TGT_MODULE: - AbEnd ("Cannot use `module' as a target for the assembler"); + AbEnd ("Cannot use 'module' as a target for the assembler"); break; case TGT_ATARI2600: @@ -331,7 +331,7 @@ static void SetSys (const char* Sys) break; default: - AbEnd ("Invalid target name: `%s'", Sys); + AbEnd ("Invalid target name: '%s'", Sys); } @@ -346,7 +346,7 @@ static void FileNameOption (const char* Opt, const char* Arg, StrBuf* Name) { /* Cannot have the option twice */ if (SB_NotEmpty (Name)) { - AbEnd ("Cannot use option `%s' twice", Opt); + AbEnd ("Cannot use option '%s' twice", Opt); } /* Remember the file name for later */ SB_CopyStr (Name, Arg); @@ -427,7 +427,7 @@ static void OptCPU (const char* Opt attribute ((unused)), const char* Arg) { cpu_t CPU = FindCPU (Arg); if (CPU == CPU_UNKNOWN) { - AbEnd ("Invalid CPU: `%s'", Arg); + AbEnd ("Invalid CPU: '%s'", Arg); } else { SetCPU (CPU); } @@ -478,7 +478,7 @@ static void OptFeature (const char* Opt attribute ((unused)), const char* Arg) /* Set the feature, check for errors */ if (SetFeature (SB_InitFromString (&Feature, Arg)) == FEAT_UNKNOWN) { - AbEnd ("Illegal emulation feature: `%s'", Arg); + AbEnd ("Illegal emulation feature: '%s'", Arg); } } @@ -533,7 +533,7 @@ static void OptListBytes (const char* Opt, const char* Arg) /* Check the bounds */ if (Num != 0 && (Num < MIN_LIST_BYTES || Num > MAX_LIST_BYTES)) { - AbEnd ("Argument for option `%s' is out of range", Opt); + AbEnd ("Argument for option '%s' is out of range", Opt); } /* Use the value */ @@ -549,7 +549,7 @@ static void OptListing (const char* Opt, const char* Arg) ** the filename is empty or begins with the option char. */ if (Arg == 0 || *Arg == '\0' || *Arg == '-') { - Fatal ("The meaning of `%s' has changed. It does now " + Fatal ("The meaning of '%s' has changed. It does now " "expect a file name as argument.", Opt); } @@ -566,7 +566,7 @@ static void OptMemoryModel (const char* Opt, const char* Arg) /* Check the current memory model */ if (MemoryModel != MMODEL_UNKNOWN) { - AbEnd ("Cannot use option `%s' twice", Opt); + AbEnd ("Cannot use option '%s' twice", Opt); } /* Translate the memory model name and check it */ @@ -762,7 +762,7 @@ static void OneLine (void) */ if (CurTok.Tok != TOK_COLON) { if (HadWS || !NoColonLabels) { - Error ("`:' expected"); + Error ("':' expected"); /* Try some smart error recovery */ if (CurTok.Tok == TOK_NAMESPACE) { NextTok (); @@ -807,7 +807,7 @@ static void OneLine (void) } else if (PCAssignment && (CurTok.Tok == TOK_STAR || CurTok.Tok == TOK_PC)) { NextTok (); if (CurTok.Tok != TOK_EQ) { - Error ("`=' expected"); + Error ("'=' expected"); SkipUntilSep (); } else { /* Skip the equal sign */ @@ -1040,7 +1040,7 @@ int main (int argc, char* argv []) } else { /* Filename. Check if we already had one */ if (InFile) { - fprintf (stderr, "%s: Don't know what to do with `%s'\n", + fprintf (stderr, "%s: Don't know what to do with '%s'\n", ProgName, Arg); exit (EXIT_FAILURE); } else { diff --git a/src/ca65/nexttok.c b/src/ca65/nexttok.c index 1521ed0c2..54733740e 100644 --- a/src/ca65/nexttok.c +++ b/src/ca65/nexttok.c @@ -179,7 +179,7 @@ static void FuncConcat (void) ** by the string token just created. */ if (CurTok.Tok != TOK_RPAREN) { - Error ("`)' expected"); + Error ("')' expected"); } else { CurTok.Tok = TOK_STRCON; SB_Copy (&CurTok.SVal, &Buf); @@ -253,7 +253,7 @@ static void FuncIdent (void) SB_Copy (&Buf, &CurTok.SVal); NextTok (); if (CurTok.Tok != TOK_RPAREN) { - Error ("`)' expected"); + Error ("')' expected"); } else { CurTok.Tok = Id; SB_Copy (&CurTok.SVal, &Buf); @@ -600,7 +600,7 @@ static void FuncSPrintF (void) ** by the string token just created. */ if (CurTok.Tok != TOK_RPAREN) { - Error ("`)' expected"); + Error ("')' expected"); } else { CurTok.Tok = TOK_STRCON; SB_Copy (&CurTok.SVal, &R); @@ -660,7 +660,7 @@ static void FuncString (void) ** by the string token just created. */ if (CurTok.Tok != TOK_RPAREN) { - Error ("`)' expected"); + Error ("')' expected"); } else { CurTok.Tok = TOK_STRCON; SB_Copy (&CurTok.SVal, &Buf); @@ -754,7 +754,7 @@ void ConsumeSep (void) void ConsumeLParen (void) /* Consume a left paren */ { - Consume (TOK_LPAREN, "`(' expected"); + Consume (TOK_LPAREN, "'(' expected"); } @@ -762,7 +762,7 @@ void ConsumeLParen (void) void ConsumeRParen (void) /* Consume a right paren */ { - Consume (TOK_RPAREN, "`)' expected"); + Consume (TOK_RPAREN, "')' expected"); } @@ -770,7 +770,7 @@ void ConsumeRParen (void) void ConsumeComma (void) /* Consume a comma */ { - Consume (TOK_COMMA, "`,' expected"); + Consume (TOK_COMMA, "',' expected"); } diff --git a/src/ca65/objfile.c b/src/ca65/objfile.c index dfa0d146e..b475d15df 100644 --- a/src/ca65/objfile.c +++ b/src/ca65/objfile.c @@ -113,7 +113,7 @@ static void ObjWriteError (void) remove (OutFile); /* Now abort with a fatal error */ - Fatal ("Cannot write to output file `%s': %s", OutFile, strerror (Error)); + Fatal ("Cannot write to output file '%s': %s", OutFile, strerror (Error)); } @@ -170,7 +170,7 @@ void ObjOpen (void) /* Create the output file */ F = fopen (OutFile, "w+b"); if (F == 0) { - Fatal ("Cannot open output file `%s': %s", OutFile, strerror (errno)); + Fatal ("Cannot open output file '%s': %s", OutFile, strerror (errno)); } /* Write a dummy header */ diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index a1115606b..a0eb28699 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -167,13 +167,13 @@ static void SetBoolOption (unsigned char* Flag) switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) { case 0: *Flag = 0; NextTok (); break; case 1: *Flag = 1; NextTok (); break; - default: ErrorSkip ("`on' or `off' expected"); break; + default: ErrorSkip ("'on' or 'off' expected"); break; } } else if (TokIsSep (CurTok.Tok)) { /* Without anything assume switch on */ *Flag = 1; } else { - ErrorSkip ("`on' or `off' expected"); + ErrorSkip ("'on' or 'off' expected"); } } @@ -1017,7 +1017,7 @@ static void DoFeature (void) /* Set the feature and check for errors */ if (SetFeature (&CurTok.SVal) == FEAT_UNKNOWN) { /* Not found */ - ErrorSkip ("Invalid feature: `%m%p'", &CurTok.SVal); + ErrorSkip ("Invalid feature: '%m%p'", &CurTok.SVal); return; } else { /* Skip the keyword */ @@ -1242,7 +1242,7 @@ static void DoIncBin (void) char* PathName = SearchFile (BinSearchPath, SB_GetConstBuf (&Name)); if (PathName == 0 || (F = fopen (PathName, "rb")) == 0) { /* Not found or cannot open, print an error and bail out */ - ErrorSkip ("Cannot open include file `%m%p': %s", &Name, strerror (errno)); + ErrorSkip ("Cannot open include file '%m%p': %s", &Name, strerror (errno)); xfree (PathName); goto ExitPoint; } @@ -1268,7 +1268,7 @@ static void DoIncBin (void) */ SB_Terminate (&Name); if (FileStat (SB_GetConstBuf (&Name), &StatBuf) != 0) { - Fatal ("Cannot stat input file `%m%p': %s", &Name, strerror (errno)); + Fatal ("Cannot stat input file '%m%p': %s", &Name, strerror (errno)); } /* Add the file to the input file table */ @@ -1305,7 +1305,7 @@ static void DoIncBin (void) size_t BytesRead = fread (Buf, 1, BytesToRead, F); if (BytesToRead != BytesRead) { /* Some sort of error */ - ErrorSkip ("Cannot read from include file `%m%p': %s", + ErrorSkip ("Cannot read from include file '%m%p': %s", &Name, strerror (errno)); break; } @@ -1896,7 +1896,7 @@ static void DoUnDef (void) static void DoUnexpected (void) /* Got an unexpected keyword */ { - Error ("Unexpected `%m%p'", &Keyword); + Error ("Unexpected '%m%p'", &Keyword); SkipUntilSep (); } diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 7c291666c..f80fe2bca 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -501,7 +501,7 @@ int NewInputFile (const char* Name) /* Main file */ F = fopen (Name, "r"); if (F == 0) { - Fatal ("Cannot open input file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot open input file '%s': %s", Name, strerror (errno)); } } else { /* We are on include level. Search for the file in the include @@ -510,7 +510,7 @@ int NewInputFile (const char* Name) PathName = SearchFile (IncSearchPath, Name); if (PathName == 0 || (F = fopen (PathName, "r")) == 0) { /* Not found or cannot open, print an error and bail out */ - Error ("Cannot open include file `%s': %s", Name, strerror (errno)); + Error ("Cannot open include file '%s': %s", Name, strerror (errno)); goto ExitPoint; } @@ -527,7 +527,7 @@ int NewInputFile (const char* Name) ** here. */ if (FileStat (Name, &Buf) != 0) { - Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot stat input file '%s': %s", Name, strerror (errno)); } /* Add the file to the input file table and remember the index */ @@ -794,6 +794,43 @@ static void ReadStringConst (int StringTerm) break; } + if (C == '\\' && StringEscapes) { + NextChar (); + + switch (C) { + case EOF: + Error ("Unterminated escape sequence in string constant"); + break; + case '\\': + case '\'': + case '"': + break; + case 't': + C = '\x09'; + break; + case 'r': + C = '\x0D'; + break; + case 'n': + C = '\x0A'; + break; + case 'x': + NextChar (); + if (IsXDigit (C)) { + char high_nibble = DigitVal (C) << 4; + NextChar (); + if (IsXDigit (C)) { + C = high_nibble | DigitVal (C); + break; + } + } + /* otherwise, fall through */ + default: + Error ("Unsupported escape sequence in string constant"); + break; + } + } + /* Append the char to the string */ SB_AppendChar (&CurTok.SVal, C); @@ -1054,7 +1091,7 @@ Again: /* Not found */ if (!LeadingDotInIdents) { /* Invalid pseudo instruction */ - Error ("`%m%p' is not a recognized control command", &CurTok.SVal); + Error ("'%m%p' is not a recognized control command", &CurTok.SVal); goto Again; } diff --git a/src/ca65/segment.c b/src/ca65/segment.c index 35a41ffe1..aa9a48512 100644 --- a/src/ca65/segment.c +++ b/src/ca65/segment.c @@ -134,7 +134,7 @@ static Segment* NewSegment (const char* Name, unsigned char AddrSize) /* Check the segment name for invalid names */ if (!ValidSegName (Name)) { - Error ("Illegal segment name: `%s'", Name); + Error ("Illegal segment name: '%s'", Name); } /* Create a new segment and return it */ diff --git a/src/ca65/struct.c b/src/ca65/struct.c index 195f29ba4..5ea7a18ec 100644 --- a/src/ca65/struct.c +++ b/src/ca65/struct.c @@ -261,9 +261,9 @@ static long DoStructInternal (long Offs, unsigned Type) /* End of struct/union definition */ if (Type == STRUCT) { - Consume (TOK_ENDSTRUCT, "`.ENDSTRUCT' expected"); + Consume (TOK_ENDSTRUCT, "'.ENDSTRUCT' expected"); } else { - Consume (TOK_ENDUNION, "`.ENDUNION' expected"); + Consume (TOK_ENDUNION, "'.ENDUNION' expected"); } /* Return the size of the struct */ diff --git a/src/ca65/studyexpr.c b/src/ca65/studyexpr.c index 366b50ff1..90d2d6e18 100644 --- a/src/ca65/studyexpr.c +++ b/src/ca65/studyexpr.c @@ -524,7 +524,7 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D) if (SymHasUserMark (Sym)) { LIError (&Sym->DefLines, - "Circular reference in definition of symbol `%m%p'", + "Circular reference in definition of symbol '%m%p'", GetSymName (Sym)); ED_SetError (D); } else { diff --git a/src/ca65/symbol.c b/src/ca65/symbol.c index 0b02aab45..3b06fd1a2 100644 --- a/src/ca65/symbol.c +++ b/src/ca65/symbol.c @@ -95,7 +95,7 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName) if (Scope == 0) { /* Scope not found */ SB_Terminate (FullName); - Error ("No such scope: `%m%p'", FullName); + Error ("No such scope: '%m%p'", FullName); return 0; } @@ -139,7 +139,7 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName) Scope = SymFindScope (Scope, Name, SYM_FIND_EXISTING); if (Scope == 0) { /* Scope not found */ - Error ("No such scope: `%m%p'", FullName); + Error ("No such scope: '%m%p'", FullName); return 0; } diff --git a/src/ca65/symentry.c b/src/ca65/symentry.c index 06c537cf6..cf789da5e 100644 --- a/src/ca65/symentry.c +++ b/src/ca65/symentry.c @@ -213,24 +213,24 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags { if (S->Flags & SF_IMPORT) { /* Defined symbol is marked as imported external symbol */ - Error ("Symbol `%m%p' is already an import", GetSymName (S)); + Error ("Symbol '%m%p' is already an import", GetSymName (S)); return; } if ((Flags & SF_VAR) != 0 && (S->Flags & (SF_EXPORT | SF_GLOBAL))) { /* Variable symbols cannot be exports or globals */ - Error ("Var symbol `%m%p' cannot be an export or global symbol", GetSymName (S)); + Error ("Var symbol '%m%p' cannot be an export or global symbol", GetSymName (S)); return; } if (S->Flags & SF_DEFINED) { /* Multiple definition. In case of a variable, this is legal. */ if ((S->Flags & SF_VAR) == 0) { - Error ("Symbol `%m%p' is already defined", GetSymName (S)); + Error ("Symbol '%m%p' is already defined", GetSymName (S)); S->Flags |= SF_MULTDEF; return; } else { /* Redefinition must also be a variable symbol */ if ((Flags & SF_VAR) == 0) { - Error ("Symbol `%m%p' is already different kind", GetSymName (S)); + Error ("Symbol '%m%p' is already different kind", GetSymName (S)); return; } /* Delete the current symbol expression, since it will get @@ -285,7 +285,7 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags S->ExportSize = S->AddrSize; } else if (S->AddrSize > S->ExportSize) { /* We're exporting a symbol smaller than it actually is */ - Warning (1, "Symbol `%m%p' is %s but exported %s", + Warning (1, "Symbol '%m%p' is %s but exported %s", GetSymName (S), AddrSizeToStr (S->AddrSize), AddrSizeToStr (S->ExportSize)); } @@ -315,13 +315,13 @@ void SymImport (SymEntry* S, unsigned char AddrSize, unsigned Flags) /* Mark the given symbol as an imported symbol */ { if (S->Flags & SF_DEFINED) { - Error ("Symbol `%m%p' is already defined", GetSymName (S)); + Error ("Symbol '%m%p' is already defined", GetSymName (S)); S->Flags |= SF_MULTDEF; return; } if (S->Flags & SF_EXPORT) { /* The symbol is already marked as exported symbol */ - Error ("Cannot import exported symbol `%m%p'", GetSymName (S)); + Error ("Cannot import exported symbol '%m%p'", GetSymName (S)); return; } @@ -337,16 +337,16 @@ void SymImport (SymEntry* S, unsigned char AddrSize, unsigned Flags) */ if (S->Flags & SF_IMPORT) { if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED)) { - Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Redeclaration mismatch for symbol '%m%p'", GetSymName (S)); } if (AddrSize != S->AddrSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } if (S->Flags & SF_GLOBAL) { S->Flags &= ~SF_GLOBAL; if (AddrSize != S->AddrSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } @@ -369,12 +369,12 @@ void SymExport (SymEntry* S, unsigned char AddrSize, unsigned Flags) /* Check if it's ok to export the symbol */ if (S->Flags & SF_IMPORT) { /* The symbol is already marked as imported external symbol */ - Error ("Symbol `%m%p' is already an import", GetSymName (S)); + Error ("Symbol '%m%p' is already an import", GetSymName (S)); return; } if (S->Flags & SF_VAR) { /* Variable symbols cannot be exported */ - Error ("Var symbol `%m%p' cannot be exported", GetSymName (S)); + Error ("Var symbol '%m%p' cannot be exported", GetSymName (S)); return; } @@ -383,7 +383,7 @@ void SymExport (SymEntry* S, unsigned char AddrSize, unsigned Flags) */ if (S->Flags & SF_GLOBAL) { if (AddrSize != S->ExportSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } S->Flags &= ~SF_GLOBAL; @@ -398,7 +398,7 @@ void SymExport (SymEntry* S, unsigned char AddrSize, unsigned Flags) */ if ((S->Flags & (SF_EXPORT|SF_DEFINED)) == SF_EXPORT) { if (S->ExportSize != AddrSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } S->ExportSize = AddrSize; @@ -412,7 +412,7 @@ void SymExport (SymEntry* S, unsigned char AddrSize, unsigned Flags) S->ExportSize = S->AddrSize; } else if (S->AddrSize > S->ExportSize) { /* We're exporting a symbol smaller than it actually is */ - Warning (1, "Symbol `%m%p' is %s but exported %s", + Warning (1, "Symbol '%m%p' is %s but exported %s", GetSymName (S), AddrSizeToStr (S->AddrSize), AddrSizeToStr (S->ExportSize)); } @@ -434,7 +434,7 @@ void SymGlobal (SymEntry* S, unsigned char AddrSize, unsigned Flags) { if (S->Flags & SF_VAR) { /* Variable symbols cannot be exported or imported */ - Error ("Var symbol `%m%p' cannot be made global", GetSymName (S)); + Error ("Var symbol '%m%p' cannot be made global", GetSymName (S)); return; } @@ -447,7 +447,7 @@ void SymGlobal (SymEntry* S, unsigned char AddrSize, unsigned Flags) AddrSize = GetCurrentSegAddrSize (); } if (AddrSize != S->AddrSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } return; } @@ -459,12 +459,12 @@ void SymGlobal (SymEntry* S, unsigned char AddrSize, unsigned Flags) if ((S->Flags & SF_DEFINED) == 0) { /* Symbol is undefined */ if (AddrSize != S->ExportSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } else if (AddrSize != ADDR_SIZE_DEFAULT) { /* Symbol is defined and address size given */ if (AddrSize != S->ExportSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } return; @@ -476,7 +476,7 @@ void SymGlobal (SymEntry* S, unsigned char AddrSize, unsigned Flags) */ if (S->Flags & SF_GLOBAL) { if (AddrSize != S->ExportSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } return; } @@ -494,7 +494,7 @@ void SymGlobal (SymEntry* S, unsigned char AddrSize, unsigned Flags) S->ExportSize = S->AddrSize; } else if (S->AddrSize > S->ExportSize) { /* We're exporting a symbol smaller than it actually is */ - Warning (1, "Symbol `%m%p' is %s but exported %s", + Warning (1, "Symbol '%m%p' is %s but exported %s", GetSymName (S), AddrSizeToStr (S->AddrSize), AddrSizeToStr (S->ExportSize)); } @@ -537,12 +537,12 @@ void SymConDes (SymEntry* S, unsigned char AddrSize, unsigned Type, unsigned Pri /* Check for errors */ if (S->Flags & SF_IMPORT) { /* The symbol is already marked as imported external symbol */ - Error ("Symbol `%m%p' is already an import", GetSymName (S)); + Error ("Symbol '%m%p' is already an import", GetSymName (S)); return; } if (S->Flags & SF_VAR) { /* Variable symbols cannot be exported or imported */ - Error ("Var symbol `%m%p' cannot be exported", GetSymName (S)); + Error ("Var symbol '%m%p' cannot be exported", GetSymName (S)); return; } @@ -552,7 +552,7 @@ void SymConDes (SymEntry* S, unsigned char AddrSize, unsigned Type, unsigned Pri */ if (S->Flags & (SF_EXPORT | SF_GLOBAL)) { if (S->ExportSize != AddrSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } S->Flags &= ~SF_GLOBAL; } @@ -566,7 +566,7 @@ void SymConDes (SymEntry* S, unsigned char AddrSize, unsigned Type, unsigned Pri /* Use the real size of the symbol */ S->ExportSize = S->AddrSize; } else if (S->AddrSize != S->ExportSize) { - Error ("Address size mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Address size mismatch for symbol '%m%p'", GetSymName (S)); } } @@ -575,7 +575,7 @@ void SymConDes (SymEntry* S, unsigned char AddrSize, unsigned Type, unsigned Pri */ if (S->ConDesPrio[Type] != CD_PRIO_NONE) { if (S->ConDesPrio[Type] != Prio) { - Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S)); + Error ("Redeclaration mismatch for symbol '%m%p'", GetSymName (S)); } } S->ConDesPrio[Type] = Prio; diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index 35d5a8066..afe7b3ad6 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -178,7 +178,7 @@ static SymTable* NewSymTable (SymTable* Parent, const StrBuf* Name) } } else { /* Duplicate scope name */ - Internal ("Duplicate scope name: `%m%p'", Name); + Internal ("Duplicate scope name: '%m%p'", Name); } } } @@ -216,7 +216,7 @@ void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, /* Check if the scope has been defined before */ if (CurrentScope->Flags & ST_DEFINED) { - Error ("Duplicate scope `%m%p'", ScopeName); + Error ("Duplicate scope '%m%p'", ScopeName); } } else { @@ -502,7 +502,7 @@ static void SymCheckUndefined (SymEntry* S) if (Sym->Flags & SF_IMPORT) { /* The symbol is already marked as import */ LIError (&S->RefLines, - "Symbol `%s' is already an import", + "Symbol '%s' is already an import", GetString (Sym->Name)); } if ((Sym->Flags & SF_EXPORT) == 0) { @@ -516,7 +516,7 @@ static void SymCheckUndefined (SymEntry* S) if (Sym->AddrSize > Sym->ExportSize) { /* We're exporting a symbol smaller than it actually is */ LIWarning (&Sym->DefLines, 1, - "Symbol `%m%p' is %s but exported %s", + "Symbol '%m%p' is %s but exported %s", GetSymName (Sym), AddrSizeToStr (Sym->AddrSize), AddrSizeToStr (Sym->ExportSize)); @@ -541,7 +541,7 @@ static void SymCheckUndefined (SymEntry* S) if (S->Flags & SF_EXPORT) { /* We will not auto-import an export */ LIError (&S->RefLines, - "Exported symbol `%m%p' was never defined", + "Exported symbol '%m%p' was never defined", GetSymName (S)); } else { if (AutoImport) { @@ -554,7 +554,7 @@ static void SymCheckUndefined (SymEntry* S) } else { /* Error */ LIError (&S->RefLines, - "Symbol `%m%p' is undefined", + "Symbol '%m%p' is undefined", GetSymName (S)); } } @@ -616,7 +616,7 @@ void SymCheck (void) ReleaseFullLineInfo (&S->RefLines); } else if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) { LIWarning (&S->DefLines, 2, - "Symbol `%m%p' is defined but never used", + "Symbol '%m%p' is defined but never used", GetSymName (S)); } @@ -625,7 +625,7 @@ void SymCheck (void) if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) { /* Imported symbol is not referenced */ LIWarning (&S->DefLines, 2, - "Symbol `%m%p' is imported but never used", + "Symbol '%m%p' is imported but never used", GetSymName (S)); } else { /* Give the import an id, count imports */ @@ -653,7 +653,7 @@ void SymCheck (void) } else if (S->AddrSize > S->ExportSize) { /* We're exporting a symbol smaller than it actually is */ LIWarning (&S->DefLines, 1, - "Symbol `%m%p' is %s but exported %s", + "Symbol '%m%p' is %s but exported %s", GetSymName (S), AddrSizeToStr (S->AddrSize), AddrSizeToStr (S->ExportSize)); @@ -673,7 +673,7 @@ void SymCheck (void) const FilePos* P = S->GuessedUse[S->AddrSize - 1]; if (P) { PWarning (P, 0, - "Didn't use %s addressing for `%m%p'", + "Didn't use %s addressing for '%m%p'", AddrSizeToStr (S->AddrSize), GetSymName (S)); } diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 12573e862..a56ecf880 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA} Win32Proj cc65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/cc65/asmstmt.c b/src/cc65/asmstmt.c index 1fc4e3167..ae4308522 100644 --- a/src/cc65/asmstmt.c +++ b/src/cc65/asmstmt.c @@ -102,7 +102,7 @@ static SymEntry* AsmGetSym (unsigned Arg, unsigned Type) /* Did we find a symbol with this name? */ if (Sym == 0) { - Error ("Undefined symbol `%s' for argument %u", CurTok.Ident, Arg); + Error ("Undefined symbol '%s' for argument %u", CurTok.Ident, Arg); AsmErrorSkip (); return 0; } diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 0f7b45968..a611f4f6a 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -4256,7 +4256,7 @@ void g_initauto (unsigned Label, unsigned Size) AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0)); AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); AddCodeLine ("bne %s", LocalLabelName (CodeLabel)); } } @@ -4281,7 +4281,7 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size) AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0)); AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0)); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); AddCodeLine ("bne %s", LocalLabelName (CodeLabel)); } else { /* Use the easy way here: memcpy() */ diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index e9d98f5b8..972d48f6a 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -461,7 +461,7 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) ** use and change all registers. */ if (Debug) { - fprintf (stderr, "No info about internal function `%s'\n", Name); + fprintf (stderr, "No info about internal function '%s'\n", Name); } *Use = REG_ALL; *Chg = REG_ALL; diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 3116539dc..575398c11 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -981,7 +981,7 @@ static OptFunc* GetOptFunc (const char* Name) OptFunc* F = FindOptFunc (Name); if (F == 0) { /* Not found */ - AbEnd ("Optimization step `%s' not found", Name); + AbEnd ("Optimization step '%s' not found", Name); } return F; } @@ -1168,10 +1168,10 @@ static void WriteDebugOutput (CodeSeg* S, const char* Step) /* Output a header line */ if (Step == 0) { /* Initial output */ - WriteOutput ("Initial code for function `%s':\n", + WriteOutput ("Initial code for function '%s':\n", S->Func? S->Func->Name : ""); } else { - WriteOutput ("Code after applying `%s':\n", Step); + WriteOutput ("Code after applying '%s':\n", Step); } /* Output the code segment */ @@ -1512,7 +1512,7 @@ void RunOpt (CodeSeg* S) /* Print the name of the function we are working on */ if (S->Func) { - Print (stdout, 1, "Running optimizer for function `%s'\n", S->Func->Name); + Print (stdout, 1, "Running optimizer for function '%s'\n", S->Func->Name); } else { Print (stdout, 1, "Running optimizer for global code segment\n"); } diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index a808a26f7..ba759988b 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -317,12 +317,12 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) /* Expect zp x indirect */ L = SkipSpace (L+1); if (toupper (*L) != 'X') { - Error ("ASM code error: `X' expected"); + Error ("ASM code error: 'X' expected"); return 0; } L = SkipSpace (L+1); if (*L != ')') { - Error ("ASM code error: `)' expected"); + Error ("ASM code error: ')' expected"); return 0; } L = SkipSpace (L+1); @@ -337,7 +337,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) if (*L == ',') { L = SkipSpace (L+1); if (toupper (*L) != 'Y') { - Error ("ASM code error: `Y' expected"); + Error ("ASM code error: 'Y' expected"); return 0; } L = SkipSpace (L+1); @@ -378,7 +378,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) /* Check for subroutine call to local label */ if ((OPC->Info & OF_CALL) && IsLocalLabelName (Arg)) { Error ("ASM code error: " - "Cannot use local label `%s' in subroutine call", + "Cannot use local label '%s' in subroutine call", Arg); } AM = AM65_ABS; @@ -532,7 +532,7 @@ void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) case '.': /* Control instruction */ ReadToken (L, " \t", Token, sizeof (Token)); - Error ("ASM code error: Pseudo instruction `%s' not supported", Token); + Error ("ASM code error: Pseudo instruction '%s' not supported", Token); break; default: @@ -780,7 +780,7 @@ CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name) if (L) { /* We found it - be sure it does not already have an owner */ if (L->Owner) { - Error ("ASM label `%s' is already defined", Name); + Error ("ASM label '%s' is already defined", Name); return L; } } else { @@ -790,7 +790,7 @@ CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name) /* Safety. This call is quite costly, but safety is better */ if (CollIndex (&S->Labels, L) >= 0) { - Error ("ASM label `%s' is already defined", Name); + Error ("ASM label '%s' is already defined", Name); return L; } @@ -906,7 +906,7 @@ void CS_MergeLabels (CodeSeg* S) /* Print some debugging output */ if (Debug) { - printf ("Removing unused global label `%s'", X->Name); + printf ("Removing unused global label '%s'", X->Name); } /* And free the label */ diff --git a/src/cc65/compile.c b/src/cc65/compile.c index d79ef350b..9cc7f9641 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -192,7 +192,7 @@ static void Parse (void) /* This is a definition */ if (SymIsDef (Entry)) { - Error ("Global variable `%s' has already been defined", + Error ("Global variable '%s' has already been defined", Entry->Name); } Entry->Flags |= SC_DEF; @@ -204,11 +204,11 @@ static void Parse (void) if (!IsTypeVoid (Decl.Type)) { if (!IsTypeArray (Decl.Type)) { /* Size is unknown and not an array */ - Error ("Variable `%s' has unknown size", Decl.Ident); + Error ("Variable '%s' has unknown size", Decl.Ident); } } else if (IS_Get (&Standard) != STD_CC65) { /* We cannot declare variables of type void */ - Error ("Illegal type for variable `%s'", Decl.Ident); + Error ("Illegal type for variable '%s'", Decl.Ident); } } @@ -234,12 +234,12 @@ static void Parse (void) if (IsTypeVoid (Decl.Type)) { /* We cannot declare variables of type void */ - Error ("Illegal type for variable `%s'", Decl.Ident); + Error ("Illegal type for variable '%s'", Decl.Ident); Entry->Flags &= ~(SC_STORAGE | SC_DEF); } else if (Size == 0) { /* Size is unknown. Is it an array? */ if (!IsTypeArray (Decl.Type)) { - Error ("Variable `%s' has unknown size", Decl.Ident); + Error ("Variable '%s' has unknown size", Decl.Ident); } Entry->Flags &= ~(SC_STORAGE | SC_DEF); } else { @@ -256,7 +256,7 @@ static void Parse (void) const char* bssName = GetSegName (SEG_BSS); if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) { - Error ("Global variable `%s' already was defined in the `%s' segment.", + Error ("Global variable '%s' already was defined in the '%s' segment.", Entry->Name, Entry->V.BssName); } Entry->V.BssName = xstrdup (bssName); @@ -286,7 +286,7 @@ static void Parse (void) /* Function body. Check for duplicate function definitions */ if (SymIsDef (Entry)) { - Error ("Body for function `%s' has already been defined", + Error ("Body for function '%s' has already been defined", Entry->Name); } diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 19100781c..e3b5edfec 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -102,7 +102,7 @@ static unsigned ParseInitInternal (Type* T, int AllowFlexibleMembers); static void DuplicateQualifier (const char* Name) /* Print an error message */ { - Warning ("Duplicate qualifier: `%s'", Name); + Warning ("Duplicate qualifier: '%s'", Name); } @@ -551,7 +551,7 @@ static SymEntry* StructOrUnionForwardDecl (const char* Name, unsigned Type) Entry = AddStructSym (Name, Type, 0, 0); } else if ((Entry->Flags & SC_TYPEMASK) != Type) { /* Already defined, but no struct */ - Error ("Symbol `%s' is already different kind", Name); + Error ("Symbol '%s' is already different kind", Name); } return Entry; } @@ -1070,7 +1070,7 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers) Entry = FindTagSym (CurTok.Ident); if (Entry) { if (SymIsLocal (Entry) && (Entry->Flags & SC_ENUM) == 0) { - Error ("Symbol `%s' is already different kind", Entry->Name); + Error ("Symbol '%s' is already different kind", Entry->Name); } } else { /* Insert entry into table ### */ @@ -1211,10 +1211,10 @@ static void ParseOldStyleParamList (FuncDesc* F) Sym->Flags &= ~SC_DEFTYPE; } else { /* Type has already been changed */ - Error ("Redefinition for parameter `%s'", Sym->Name); + Error ("Redefinition for parameter '%s'", Sym->Name); } } else { - Error ("Unknown identifier: `%s'", Decl.Ident); + Error ("Unknown identifier: '%s'", Decl.Ident); } } @@ -1291,7 +1291,7 @@ static void ParseAnsiParamList (FuncDesc* F) /* If the parameter is a struct or union, emit a warning */ if (IsClassStruct (Decl.Type)) { if (IS_Get (&WarnStructParam)) { - Warning ("Passing struct by value for parameter `%s'", Decl.Ident); + Warning ("Passing struct by value for parameter '%s'", Decl.Ident); } } @@ -1512,7 +1512,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) ConstAbsIntExpr (hie1, &Expr); if (Expr.IVal <= 0) { if (D->Ident[0] != '\0') { - Error ("Size of array `%s' is invalid", D->Ident); + Error ("Size of array '%s' is invalid", D->Ident); } else { Error ("Size of array is invalid"); } @@ -1534,16 +1534,16 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) /* If we have remaining qualifiers, flag them as invalid */ if (Qualifiers & T_QUAL_NEAR) { - Error ("Invalid `__near__' qualifier"); + Error ("Invalid '__near__' qualifier"); } if (Qualifiers & T_QUAL_FAR) { - Error ("Invalid `__far__' qualifier"); + Error ("Invalid '__far__' qualifier"); } if (Qualifiers & T_QUAL_FASTCALL) { - Error ("Invalid `__fastcall__' qualifier"); + Error ("Invalid '__fastcall__' qualifier"); } if (Qualifiers & T_QUAL_CDECL) { - Error ("Invalid `__cdecl__' qualifier"); + Error ("Invalid '__cdecl__' qualifier"); } } @@ -1637,7 +1637,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode) ** have the C89 standard enabled explicitly. */ if (IS_Get (&Standard) >= STD_C99) { - Warning ("Implicit `int' return type is an obsolete feature"); + Warning ("Implicit 'int' return type is an obsolete feature"); } GetFuncDesc (D->Type)->Flags |= FD_OLDSTYLE_INTRET; } @@ -1653,7 +1653,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode) ** for variables with implicit int type. */ if ((Spec->Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) { - Warning ("Implicit `int' is an obsolete feature"); + Warning ("Implicit 'int' is an obsolete feature"); } } @@ -1662,7 +1662,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode) unsigned Size = SizeOf (D->Type); if (Size >= 0x10000) { if (D->Ident[0] != '\0') { - Error ("Size of `%s' is invalid (0x%06X)", D->Ident, Size); + Error ("Size of '%s' is invalid (0x%06X)", D->Ident, Size); } else { Error ("Invalid size in declaration (0x%06X)", Size); } @@ -1735,7 +1735,7 @@ static unsigned OpeningCurlyBraces (unsigned BracesNeeded) NextToken (); } if (BraceCount < BracesNeeded) { - Error ("`{' expected"); + Error ("'{' expected"); } return BraceCount; } @@ -1755,7 +1755,7 @@ static void ClosingCurlyBraces (unsigned BracesExpected) NextToken (); NextToken (); } else { - Error ("`}' expected"); + Error ("'}' expected"); return; } --BracesExpected; diff --git a/src/cc65/declattr.c b/src/cc65/declattr.c index bdaea20d6..37048e69b 100644 --- a/src/cc65/declattr.c +++ b/src/cc65/declattr.c @@ -225,7 +225,7 @@ void ParseAttribute (Declaration* D) } else { /* Attribute not known, maybe typo */ - Error ("Illegal attribute: `%s'", AttrName); + Error ("Illegal attribute: '%s'", AttrName); /* Skip until end of attribute */ ErrorSkip (); diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 55c6391d2..320ac2321 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -791,9 +791,9 @@ static void Primary (ExprDesc* E) ** list and returning int. */ if (IS_Get (&Standard) >= STD_C99) { - Error ("Call to undefined function `%s'", Ident); + Error ("Call to undefined function '%s'", Ident); } else { - Warning ("Call to undefined function `%s'", Ident); + Warning ("Call to undefined function '%s'", Ident); } Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC); E->Type = Sym->Type; @@ -804,7 +804,7 @@ static void Primary (ExprDesc* E) Sym = AddLocalSym (Ident, type_int, SC_AUTO | SC_REF, 0); E->Flags = E_LOC_STACK | E_RTYPE_LVAL; E->Type = type_int; - Error ("Undefined symbol: `%s'", Ident); + Error ("Undefined symbol: '%s'", Ident); } } @@ -1174,7 +1174,7 @@ static void StructRef (ExprDesc* Expr) NextToken (); Field = FindStructField (Expr->Type, Ident); if (Field == 0) { - Error ("Struct/union has no field named `%s'", Ident); + Error ("Struct/union has no field named '%s'", Ident); /* Make the expression an integer at address zero */ ED_MakeConstAbs (Expr, 0, type_int); return; @@ -2485,7 +2485,7 @@ static void parseadd (ExprDesc* Expr) typeadjust (Expr, &Expr2, 1); } else { /* OOPS */ - Error ("Invalid operands for binary operator `+'"); + Error ("Invalid operands for binary operator '+'"); } } else { @@ -2567,7 +2567,7 @@ static void parseadd (ExprDesc* Expr) } } else { /* OOPS */ - Error ("Invalid operands for binary operator `+'"); + Error ("Invalid operands for binary operator '+'"); flags = CF_INT; } @@ -2611,7 +2611,7 @@ static void parseadd (ExprDesc* Expr) flags = typeadjust (Expr, &Expr2, 1); } else { /* OOPS */ - Error ("Invalid operands for binary operator `+'"); + Error ("Invalid operands for binary operator '+'"); flags = CF_INT; } @@ -2653,7 +2653,7 @@ static void parseadd (ExprDesc* Expr) flags = typeadjust (Expr, &Expr2, 0) & ~CF_CONST; } else { /* OOPS */ - Error ("Invalid operands for binary operator `+'"); + Error ("Invalid operands for binary operator '+'"); flags = CF_INT; } @@ -2689,7 +2689,7 @@ static void parsesub (ExprDesc* Expr) /* lhs cannot be function or pointer to function */ if (IsTypeFunc (Expr->Type) || IsTypeFuncPtr (Expr->Type)) { - Error ("Invalid left operand for binary operator `-'"); + Error ("Invalid left operand for binary operator '-'"); /* Make it pointer to char to avoid further errors */ Expr->Type = type_uchar; } @@ -2712,7 +2712,7 @@ static void parsesub (ExprDesc* Expr) /* rhs cannot be function or pointer to function */ if (IsTypeFunc (Expr2.Type) || IsTypeFuncPtr (Expr2.Type)) { - Error ("Invalid right operand for binary operator `-'"); + Error ("Invalid right operand for binary operator '-'"); /* Make it pointer to char to avoid further errors */ Expr2.Type = type_uchar; } @@ -2750,7 +2750,7 @@ static void parsesub (ExprDesc* Expr) Expr->IVal -= Expr2.IVal; } else { /* OOPS */ - Error ("Invalid operands for binary operator `-'"); + Error ("Invalid operands for binary operator '-'"); } /* Result is constant, condition codes not set */ @@ -2783,7 +2783,7 @@ static void parsesub (ExprDesc* Expr) flags = typeadjust (Expr, &Expr2, 1); } else { /* OOPS */ - Error ("Invalid operands for binary operator `-'"); + Error ("Invalid operands for binary operator '-'"); flags = CF_INT; } @@ -2837,7 +2837,7 @@ static void parsesub (ExprDesc* Expr) flags = typeadjust (Expr, &Expr2, 0); } else { /* OOPS */ - Error ("Invalid operands for binary operator `-'"); + Error ("Invalid operands for binary operator '-'"); flags = CF_INT; } @@ -3304,7 +3304,7 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr, const char* Op) /* The rhs must be an integer (or a float, but we don't support that yet */ if (!IsClassInt (Expr2.Type)) { - Error ("Invalid right operand for binary operator `%s'", Op); + Error ("Invalid right operand for binary operator '%s'", Op); /* Continue. Wrong code will be generated, but the compiler won't ** break, so this is the best error recovery. */ @@ -3421,7 +3421,7 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr, const char* Op) */ hie1 (&Expr2); if (!IsClassInt (Expr2.Type)) { - Error ("Invalid right operand for binary operator `%s'", Op); + Error ("Invalid right operand for binary operator '%s'", Op); /* Continue. Wrong code will be generated, but the compiler won't ** break, so this is the best error recovery. */ diff --git a/src/cc65/function.c b/src/cc65/function.c index 97d6916ff..3256d7541 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -422,14 +422,14 @@ void NewFunc (SymEntry* Func) /* Main cannot be a fastcall function */ if (IsQualFastcall (Func->Type)) { - Error ("`main' cannot be declared as __fastcall__"); + Error ("'main' cannot be declared as __fastcall__"); } /* If cc65 extensions aren't enabled, don't allow a main function that ** doesn't return an int. */ if (IS_Get (&Standard) != STD_CC65 && CurrentFunc->ReturnType[0].C != T_INT) { - Error ("`main' must always return an int"); + Error ("'main' must always return an int"); } /* Add a forced import of a symbol that is contained in the startup diff --git a/src/cc65/hexval.c b/src/cc65/hexval.c index 37e43da14..ce4e33acf 100644 --- a/src/cc65/hexval.c +++ b/src/cc65/hexval.c @@ -54,7 +54,7 @@ unsigned HexVal (int C) */ { if (!IsXDigit (C)) { - Error ("Invalid hexadecimal digit: `%c'", C); + Error ("Invalid hexadecimal digit: '%c'", C); } if (IsDigit (C)) { return C - '0'; diff --git a/src/cc65/input.c b/src/cc65/input.c index 005e0c668..22a66e1f7 100644 --- a/src/cc65/input.c +++ b/src/cc65/input.c @@ -174,7 +174,7 @@ static AFile* NewAFile (IFile* IF, FILE* F) struct stat Buf; if (FileStat (IF->Name, &Buf) != 0) { /* Error */ - Fatal ("Cannot stat `%s': %s", IF->Name, strerror (errno)); + Fatal ("Cannot stat '%s': %s", IF->Name, strerror (errno)); } IF->Size = (unsigned long) Buf.st_size; IF->MTime = (unsigned long) Buf.st_mtime; @@ -251,7 +251,7 @@ void OpenMainFile (const char* Name) FILE* F = fopen (Name, "r"); if (F == 0) { /* Cannot open */ - Fatal ("Cannot open input file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot open input file '%s': %s", Name, strerror (errno)); } /* Allocate a new AFile structure for the file */ @@ -284,7 +284,7 @@ void OpenIncludeFile (const char* Name, InputType IT) /* Search for the file */ N = SearchFile ((IT == IT_SYSINC)? SysIncSearchPath : UsrIncSearchPath, Name); if (N == 0) { - PPError ("Include file `%s' not found", Name); + PPError ("Include file '%s' not found", Name); return; } @@ -303,12 +303,12 @@ void OpenIncludeFile (const char* Name, InputType IT) F = fopen (IF->Name, "r"); if (F == 0) { /* Error opening the file */ - PPError ("Cannot open include file `%s': %s", IF->Name, strerror (errno)); + PPError ("Cannot open include file '%s': %s", IF->Name, strerror (errno)); return; } /* Debugging output */ - Print (stdout, 1, "Opened include file `%s'\n", IF->Name); + Print (stdout, 1, "Opened include file '%s'\n", IF->Name); /* Allocate a new AFile structure */ (void) NewAFile (IF, F); @@ -619,7 +619,7 @@ static void CreateDepFile (const char* Name, InputType Types) /* Open the file */ FILE* F = fopen (Name, "w"); if (F == 0) { - Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot open dependency file '%s': %s", Name, strerror (errno)); } /* If a dependency target was given, use it, otherwise use the output diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 024c1c5fc..02155f412 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -143,7 +143,7 @@ static void ParseRegisterDecl (Declaration* Decl, int Reg) ** we cannot allow that here. */ if (ParseInit (Sym->Type) != Size) { - Error ("Cannot initialize flexible array members of storage class `register'"); + Error ("Cannot initialize flexible array members of storage class 'register'"); } /* Generate code to copy this data into the variable space */ @@ -171,7 +171,7 @@ static void ParseRegisterDecl (Declaration* Decl, int Reg) /* Cannot allocate a variable of zero size */ if (Size == 0) { - Error ("Variable `%s' has unknown size", Decl->Ident); + Error ("Variable '%s' has unknown size", Decl->Ident); } } @@ -357,7 +357,7 @@ static void ParseAutoDecl (Declaration* Decl) /* Cannot allocate a variable of zero size */ if (Size == 0) { - Error ("Variable `%s' has unknown size", Decl->Ident); + Error ("Variable '%s' has unknown size", Decl->Ident); } } @@ -411,7 +411,7 @@ static void ParseStaticDecl (Declaration* Decl) /* Cannot allocate a variable of zero size */ if (Size == 0) { - Error ("Variable `%s' has unknown size", Decl->Ident); + Error ("Variable '%s' has unknown size", Decl->Ident); } } diff --git a/src/cc65/macrotab.c b/src/cc65/macrotab.c index daf5cd7b8..09f0db50a 100644 --- a/src/cc65/macrotab.c +++ b/src/cc65/macrotab.c @@ -245,7 +245,7 @@ void AddMacroArg (Macro* M, const char* Arg) for (I = 0; I < CollCount (&M->FormalArgs); ++I) { if (strcmp (CollAtUnchecked (&M->FormalArgs, I), Arg) == 0) { /* Found */ - Error ("Duplicate macro parameter: `%s'", Arg); + Error ("Duplicate macro parameter: '%s'", Arg); break; } } diff --git a/src/cc65/main.c b/src/cc65/main.c index 7783587aa..871e21ebc 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -160,7 +160,7 @@ static void SetSys (const char* Sys) break; case TGT_MODULE: - AbEnd ("Cannot use `module' as a target for the compiler"); + AbEnd ("Cannot use 'module' as a target for the compiler"); break; case TGT_ATARI2600: @@ -256,7 +256,7 @@ static void SetSys (const char* Sys) case TGT_TELESTRAT: DefineNumericMacro ("__TELESTRAT__", 1); break; - + case TGT_NES: DefineNumericMacro ("__NES__", 1); break; @@ -300,7 +300,11 @@ static void FileNameOption (const char* Opt, const char* Arg, StrBuf* Name) { /* Cannot have the option twice */ if (SB_NotEmpty (Name)) { - AbEnd ("Cannot use option `%s' twice", Opt); + AbEnd ("Cannot use option '%s' twice", Opt); + } + /* A typo in OptTab[] might allow a NULL Arg */ + if (Arg == 0) { + Internal ("Typo in OptTab[]; option '%s' should require an argument", Opt); } /* Remember the file name for later */ SB_CopyStr (Name, Arg); @@ -358,7 +362,7 @@ static void CheckSegName (const char* Seg) { /* Print an error and abort if the name is not ok */ if (!ValidSegName (Seg)) { - AbEnd ("Segment name `%s' is invalid", Seg); + AbEnd ("Segment name '%s' is invalid", Seg); } } @@ -455,7 +459,7 @@ static void OptCPU (const char* Opt, const char* Arg) CPU = FindCPU (Arg); if (CPU != CPU_6502 && CPU != CPU_6502X && CPU != CPU_65SC02 && CPU != CPU_65C02 && CPU != CPU_65816 && CPU != CPU_HUC6280) { - AbEnd ("Invalid argument for %s: `%s'", Opt, Arg); + AbEnd ("Invalid argument for %s: '%s'", Opt, Arg); } } @@ -500,7 +504,7 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg) /* Open the file */ FILE* F = fopen (Arg, "r"); if (F == 0) { - AbEnd ("Cannot open `%s': %s", Arg, strerror (errno)); + AbEnd ("Cannot open '%s': %s", Arg, strerror (errno)); } /* Read line by line, ignore empty lines and switch optimization @@ -558,7 +562,7 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg) -static void OptDebugOptOutput (const char* Opt attribute ((unused)), +static void OptDebugOptOutput (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Output optimization steps */ { @@ -671,7 +675,7 @@ static void OptMemoryModel (const char* Opt, const char* Arg) /* Check the current memory model */ if (MemoryModel != MMODEL_UNKNOWN) { - AbEnd ("Cannot use option `%s' twice", Opt); + AbEnd ("Cannot use option '%s' twice", Opt); } /* Translate the memory model name and check it */ @@ -735,7 +739,7 @@ static void OptStandard (const char* Opt, const char* Arg) /* Find the standard from the given name */ standard_t Std = FindStandard (Arg); if (Std == STD_UNKNOWN) { - AbEnd ("Invalid argument for %s: `%s'", Opt, Arg); + AbEnd ("Invalid argument for %s: '%s'", Opt, Arg); } else if (IS_Get (&Standard) != STD_UNKNOWN) { AbEnd ("Option %s given more than once", Opt); } else { @@ -1065,7 +1069,7 @@ int main (int argc, char* argv[]) /* Write the output to the file */ WriteAsmOutput (); - Print (stdout, 1, "Wrote output to `%s'\n", OutputFilename); + Print (stdout, 1, "Wrote output to '%s'\n", OutputFilename); /* Close the file, check for errors */ CloseOutputFile (); diff --git a/src/cc65/output.c b/src/cc65/output.c index e0b06ef99..6ce5334ca 100644 --- a/src/cc65/output.c +++ b/src/cc65/output.c @@ -102,9 +102,9 @@ void OpenOutputFile () /* Open the file */ OutputFile = fopen (OutputFilename, "w"); if (OutputFile == 0) { - Fatal ("Cannot open output file `%s': %s", OutputFilename, strerror (errno)); + Fatal ("Cannot open output file '%s': %s", OutputFilename, strerror (errno)); } - Print (stdout, 1, "Opened output file `%s'\n", OutputFilename); + Print (stdout, 1, "Opened output file '%s'\n", OutputFilename); } @@ -120,9 +120,9 @@ void OpenDebugOutputFile (const char* Name) /* Open the file */ OutputFile = fopen (Name, "w"); if (OutputFile == 0) { - Fatal ("Cannot open debug output file `%s': %s", Name, strerror (errno)); + Fatal ("Cannot open debug output file '%s': %s", Name, strerror (errno)); } - Print (stdout, 1, "Opened debug output file `%s'\n", Name); + Print (stdout, 1, "Opened debug output file '%s'\n", Name); } @@ -138,7 +138,7 @@ void CloseOutputFile () remove (OutputFilename); Fatal ("Cannot write to output file (disk full?)"); } - Print (stdout, 1, "Closed output file `%s'\n", OutputFilename); + Print (stdout, 1, "Closed output file '%s'\n", OutputFilename); OutputFile = 0; } diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 64ea4a1aa..b05ef6122 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -356,7 +356,7 @@ static int BoolKeyword (StrBuf* Ident) } /* Error */ - Error ("Pragma argument must be one of `on', `off', `true' or `false'"); + Error ("Pragma argument must be one of 'on', 'off', 'true' or 'false'"); return 0; } @@ -453,7 +453,7 @@ static void SegNamePragma (StrBuf* B, segment_t Seg) } else { /* Segment name is invalid */ - Error ("Illegal segment name: `%s'", Name); + Error ("Illegal segment name: '%s'", Name); } @@ -788,7 +788,7 @@ static void ParsePragma (void) ** for unknown pragmas, but warn about them if enabled (the default). */ if (IS_Get (&WarnUnknownPragma)) { - Warning ("Unknown pragma `%s'", SB_GetConstBuf (&Ident)); + Warning ("Unknown pragma '%s'", SB_GetConstBuf (&Ident)); } goto ExitPoint; } @@ -898,9 +898,9 @@ static void ParsePragma (void) FlagPragma (&B, &StaticLocals); break; - case PRAGMA_WRAPPED_CALL: - WrappedCallPragma(&B); - break; + case PRAGMA_WRAPPED_CALL: + WrappedCallPragma(&B); + break; case PRAGMA_WARN: WarnPragma (&B); diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 99ce6acc1..1c4837d94 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -304,7 +304,7 @@ static void OldStyleComment (void) } } else { if (CurC == '/' && NextC == '*') { - PPWarning ("`/*' found inside a comment"); + PPWarning ("'/*' found inside a comment"); } NextChar (); } @@ -491,7 +491,7 @@ static void ReadMacroArgs (MacroExp* E) NewStyleComment (); } else if (CurC == '\0') { /* End of input inside macro argument list */ - PPError ("Unterminated argument list invoking macro `%s'", E->M->Name); + PPError ("Unterminated argument list invoking macro '%s'", E->M->Name); ClearLine (); break; @@ -611,7 +611,7 @@ static void MacroArgSubst (MacroExp* E) NextChar (); SkipWhitespace (0); if (!IsSym (Ident) || (ArgIdx = FindMacroArg (E->M, Ident)) < 0) { - PPError ("`#' is not followed by a macro parameter"); + PPError ("'#' is not followed by a macro parameter"); } else { /* Make a valid string from Replacement */ Arg = ME_GetActual (E, ArgIdx); @@ -782,7 +782,7 @@ static void DefineMacro (void) /* Ellipsis */ NextChar (); if (CurC != '.' || NextC != '.') { - PPError ("`...' expected"); + PPError ("'...' expected"); ClearLine (); return; } @@ -803,7 +803,7 @@ static void DefineMacro (void) /* __VA_ARGS__ is only allowed in C89 mode */ if (!C89 && strcmp (Ident, "__VA_ARGS__") == 0) { - PPWarning ("`__VA_ARGS__' can only appear in the expansion " + PPWarning ("'__VA_ARGS__' can only appear in the expansion " "of a C99 variadic macro"); } @@ -823,7 +823,7 @@ static void DefineMacro (void) /* Check for a right paren and eat it if we find one */ if (CurC != ')') { - PPError ("`)' expected"); + PPError ("')' expected"); ClearLine (); return; } @@ -900,7 +900,7 @@ static unsigned Pass1 (StrBuf* Source, StrBuf* Target) if (HaveParen) { SkipWhitespace (0); if (CurC != ')') { - PPError ("`)' expected"); + PPError ("')' expected"); } else { NextChar (); } @@ -1138,7 +1138,7 @@ static void DoInclude (void) break; default: - PPError ("`\"' or `<' expected"); + PPError ("'\"' or '<' expected"); goto Done; } NextChar (); @@ -1295,7 +1295,7 @@ void Preprocess (void) PPError ("Duplicate #else"); } } else { - PPError ("Unexpected `#else'"); + PPError ("Unexpected '#else'"); } break; @@ -1314,7 +1314,7 @@ void Preprocess (void) /* Remove the clause that needs a terminator */ Skip = (IfStack[IfIndex--] & IFCOND_SKIP) != 0; } else { - PPError ("Unexpected `#endif'"); + PPError ("Unexpected '#endif'"); } break; @@ -1387,7 +1387,7 @@ void Preprocess (void) } if (NextLine () == 0) { if (IfIndex >= 0) { - PPError ("`#endif' expected"); + PPError ("'#endif' expected"); } return; } diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 8605f55a5..695085e94 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -377,7 +377,7 @@ static void CharConst (void) /* Check for closing quote */ if (CurC != '\'') { - Error ("`\'' expected"); + Error ("'\'' expected"); } else { /* Skip the quote */ NextChar (); @@ -1044,7 +1044,7 @@ int Consume (token_t Token, const char* ErrorMsg) int ConsumeColon (void) /* Check for a colon and skip it. */ { - return Consume (TOK_COLON, "`:' expected"); + return Consume (TOK_COLON, "':' expected"); } @@ -1057,7 +1057,7 @@ int ConsumeSemi (void) NextToken (); return 1; } else { - Error ("`;' expected"); + Error ("';' expected"); if (CurTok.Tok == TOK_COLON || CurTok.Tok == TOK_COMMA) { NextToken (); } @@ -1075,7 +1075,7 @@ int ConsumeComma (void) NextToken (); return 1; } else { - Error ("`,' expected"); + Error ("',' expected"); if (CurTok.Tok == TOK_SEMI) { NextToken (); } @@ -1088,7 +1088,7 @@ int ConsumeComma (void) int ConsumeLParen (void) /* Check for a left parenthesis and skip it */ { - return Consume (TOK_LPAREN, "`(' expected"); + return Consume (TOK_LPAREN, "'(' expected"); } @@ -1096,7 +1096,7 @@ int ConsumeLParen (void) int ConsumeRParen (void) /* Check for a right parenthesis and skip it */ { - return Consume (TOK_RPAREN, "`)' expected"); + return Consume (TOK_RPAREN, "')' expected"); } @@ -1104,7 +1104,7 @@ int ConsumeRParen (void) int ConsumeLBrack (void) /* Check for a left bracket and skip it */ { - return Consume (TOK_LBRACK, "`[' expected"); + return Consume (TOK_LBRACK, "'[' expected"); } @@ -1112,7 +1112,7 @@ int ConsumeLBrack (void) int ConsumeRBrack (void) /* Check for a right bracket and skip it */ { - return Consume (TOK_RBRACK, "`]' expected"); + return Consume (TOK_RBRACK, "']' expected"); } @@ -1120,7 +1120,7 @@ int ConsumeRBrack (void) int ConsumeLCurly (void) /* Check for a left curly brace and skip it */ { - return Consume (TOK_LCURLY, "`{' expected"); + return Consume (TOK_LCURLY, "'{' expected"); } @@ -1128,5 +1128,5 @@ int ConsumeLCurly (void) int ConsumeRCurly (void) /* Check for a right curly brace and skip it */ { - return Consume (TOK_RCURLY, "`}' expected"); + return Consume (TOK_RCURLY, "'}' expected"); } diff --git a/src/cc65/scanstrbuf.c b/src/cc65/scanstrbuf.c index 91abc8cb3..bbee569d2 100644 --- a/src/cc65/scanstrbuf.c +++ b/src/cc65/scanstrbuf.c @@ -271,7 +271,7 @@ int SB_GetNumber (StrBuf* B, long* Val) SB_Skip (B); *Val = SignExtendChar (TgtTranslateChar (ParseChar (B))); if (SB_Peek (B) != '\'') { - Error ("`\'' expected"); + Error ("'\'' expected"); return 0; } else { /* Skip the quote */ diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 14169671b..657bc9963 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -115,7 +115,7 @@ static void CheckSemi (int* PendingToken) { int HaveToken = (CurTok.Tok == TOK_SEMI); if (!HaveToken) { - Error ("`;' expected"); + Error ("';' expected"); /* Try to be smart about errors */ if (CurTok.Tok == TOK_COLON || CurTok.Tok == TOK_COMMA) { HaveToken = 1; @@ -231,7 +231,7 @@ static void DoStatement (void) g_defcodelabel (ContinueLabel); /* Parse the end condition */ - Consume (TOK_WHILE, "`while' expected"); + Consume (TOK_WHILE, "'while' expected"); TestInParens (LoopLabel, 1); ConsumeSemi (); @@ -332,7 +332,7 @@ static void ReturnStatement (void) } } else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) { - Error ("Function `%s' must return a value", F_GetFuncName (CurrentFunc)); + Error ("Function '%s' must return a value", F_GetFuncName (CurrentFunc)); } /* Mark the function as having a return statement */ @@ -361,7 +361,7 @@ static void BreakStatement (void) /* Check if we are inside a loop */ if (L == 0) { /* Error: No current loop */ - Error ("`break' statement not within loop or switch"); + Error ("'break' statement not within loop or switch"); return; } @@ -396,7 +396,7 @@ static void ContinueStatement (void) /* Did we find it? */ if (L == 0) { - Error ("`continue' statement not within a loop"); + Error ("'continue' statement not within a loop"); return; } @@ -591,7 +591,7 @@ int Statement (int* PendingToken) case TOK_LCURLY: NextToken (); GotBreak = CompoundStatement (); - CheckTok (TOK_RCURLY, "`{' expected", PendingToken); + CheckTok (TOK_RCURLY, "'{' expected", PendingToken); return GotBreak; case TOK_IF: diff --git a/src/cc65/swstmt.c b/src/cc65/swstmt.c index 512f4257d..4a3730283 100644 --- a/src/cc65/swstmt.c +++ b/src/cc65/swstmt.c @@ -303,7 +303,7 @@ void DefaultLabel (void) } else { /* case keyword outside a switch statement */ - Error ("`default' label not within a switch statement"); + Error ("'default' label not within a switch statement"); } diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index bdbec55bb..72f7f54da 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -168,11 +168,11 @@ static void CheckSymTable (SymTable* Tab) !SymHasAttr (Entry, atUnused)) { if (Flags & SC_PARAM) { if (IS_Get (&WarnUnusedParam)) { - Warning ("Parameter `%s' is never used", Entry->Name); + Warning ("Parameter '%s' is never used", Entry->Name); } } else { if (IS_Get (&WarnUnusedVar)) { - Warning ("`%s' is defined but never used", Entry->Name); + Warning ("'%s' is defined but never used", Entry->Name); } } } @@ -182,11 +182,11 @@ static void CheckSymTable (SymTable* Tab) if (Flags & SC_LABEL) { if (!SymIsDef (Entry)) { /* Undefined label */ - Error ("Undefined label: `%s'", Entry->Name); + Error ("Undefined label: '%s'", Entry->Name); } else if (!SymIsRef (Entry)) { /* Defined but not used */ if (IS_Get (&WarnUnusedLabel)) { - Warning ("`%s' is defined but never used", Entry->Name); + Warning ("'%s' is defined but never used", Entry->Name); } } } @@ -566,10 +566,10 @@ SymEntry* AddStructSym (const char* Name, unsigned Type, unsigned Size, SymTable /* We do have an entry. This may be a forward, so check it. */ if ((Entry->Flags & SC_TYPEMASK) != Type) { /* Existing symbol is not a struct */ - Error ("Symbol `%s' is already different kind", Name); + Error ("Symbol '%s' is already different kind", Name); } else if (Size > 0 && Entry->V.S.Size > 0) { /* Both structs are definitions. */ - Error ("Multiple definition for `%s'", Name); + Error ("Multiple definition for '%s'", Name); } else { /* Define the struct size if it is given */ if (Size > 0) { @@ -605,7 +605,7 @@ SymEntry* AddBitField (const char* Name, unsigned Offs, unsigned BitOffs, unsign if (Entry) { /* We have a symbol with this name already */ - Error ("Multiple definition for `%s'", Name); + Error ("Multiple definition for '%s'", Name); } else { @@ -639,9 +639,9 @@ SymEntry* AddConstSym (const char* Name, const Type* T, unsigned Flags, long Val SymEntry* Entry = FindSymInTable (Tab, Name, HashStr (Name)); if (Entry) { if ((Entry->Flags & SC_CONST) != SC_CONST) { - Error ("Symbol `%s' is already different kind", Name); + Error ("Symbol '%s' is already different kind", Name); } else { - Error ("Multiple definition for `%s'", Name); + Error ("Multiple definition for '%s'", Name); } return Entry; } @@ -706,7 +706,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) if (SymIsDef (Entry) && (Flags & SC_DEF) != 0) { /* Trying to define the label more than once */ - Error ("Label `%s' is defined more than once", Name); + Error ("Label '%s' is defined more than once", Name); } NewDOR = AddDefOrRef (Entry, Flags); @@ -809,7 +809,7 @@ SymEntry* AddLocalSym (const char* Name, const Type* T, unsigned Flags, int Offs if (Entry) { /* We have a symbol with this name already */ - Error ("Multiple definition for `%s'", Name); + Error ("Multiple definition for '%s'", Name); } else { @@ -865,12 +865,12 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) ** then avoid a compiler crash. See GitHub issue #728. */ if (Entry->Flags & SC_ENUM) { - Fatal ("Can't redeclare enum constant `%s' as global variable", Name); + Fatal ("Can't redeclare enum constant '%s' as global variable", Name); } /* We have a symbol with this name already */ if (Entry->Flags & SC_TYPE) { - Error ("Multiple definition for `%s'", Name); + Error ("Multiple definition for '%s'", Name); return Entry; } @@ -890,7 +890,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) if ((Size != UNSPECIFIED && ESize != UNSPECIFIED && Size != ESize) || TypeCmp (T + 1, EType + 1) < TC_EQUAL) { /* Types not identical: Conflicting types */ - Error ("Conflicting types for `%s'", Name); + Error ("Conflicting types for '%s'", Name); return Entry; } else { /* Check if we have a size in the existing definition */ @@ -903,7 +903,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } else { /* New type must be identical */ if (TypeCmp (EType, T) < TC_EQUAL) { - Error ("Conflicting types for `%s'", Name); + Error ("Conflicting types for '%s'", Name); return Entry; } @@ -930,7 +930,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) ** warn about the conflict. (It will compile a public declaration.) */ if ((Flags & SC_EXTERN) == 0 && (Entry->Flags & SC_EXTERN) != 0) { - Warning ("static declaration follows non-static declaration of `%s'.", Name); + Warning ("static declaration follows non-static declaration of '%s'.", Name); } /* An extern declaration must not change the current linkage. */ @@ -942,7 +942,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) ** warn about the conflict. (It will compile a public declaration.) */ if ((Flags & SC_EXTERN) != 0 && (Entry->Flags & SC_EXTERN) == 0) { - Warning ("public declaration follows static declaration of `%s'.", Name); + Warning ("public declaration follows static declaration of '%s'.", Name); } /* Add the new flags */ @@ -1017,7 +1017,7 @@ void MakeZPSym (const char* Name) if (Entry) { Entry->Flags |= SC_ZEROPAGE; } else { - Error ("Undefined symbol: `%s'", Name); + Error ("Undefined symbol: '%s'", Name); } } diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index 47ab993c1..21ad33f12 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -76,7 +76,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType) /* Don't allow casts from void to something else. */ if (IsTypeVoid (OldType)) { - Error ("Cannot convert from `void' to something else"); + Error ("Cannot convert from 'void' to something else"); goto ExitPoint; } diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index d120399d1..351f6077e 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC} Win32Proj chrcvt65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/chrcvt65/main.c b/src/chrcvt65/main.c index 7e7183e0a..b2a21a114 100644 --- a/src/chrcvt65/main.c +++ b/src/chrcvt65/main.c @@ -325,7 +325,7 @@ static void ConvertFile (const char* Input, const char* Output) /* Try to open the file for reading */ FILE* F = fopen (Input, "rb"); if (F == 0) { - Error ("Cannot open input file `%s': %s", Input, strerror (errno)); + Error ("Cannot open input file '%s': %s", Input, strerror (errno)); } /* Seek to the end and determine the size */ @@ -337,9 +337,9 @@ static void ConvertFile (const char* Input, const char* Output) /* Check if the size is reasonable */ if (Size > 32*1024) { - Error ("Input file `%s' is too large (max = 32k)", Input); + Error ("Input file '%s' is too large (max = 32k)", Input); } else if (Size < 0x100) { - Error ("Input file `%s' is too small to be a vector font file", Input); + Error ("Input file '%s' is too small to be a vector font file", Input); } /* Allocate memory for the file */ @@ -347,7 +347,7 @@ static void ConvertFile (const char* Input, const char* Output) /* Read the file contents into the buffer */ if (fread (Buf, 1, (size_t) Size, F) != (size_t) Size) { - Error ("Error reading from input file `%s'", Input); + Error ("Error reading from input file '%s'", Input); } /* Close the file */ @@ -355,14 +355,14 @@ static void ConvertFile (const char* Input, const char* Output) /* Verify the header */ if (memcmp (Buf, ChrHeader, sizeof (ChrHeader)) != 0) { - Error ("Invalid format for `%s': invalid header", Input); + Error ("Invalid format for '%s': invalid header", Input); } MsgEnd = memchr (Buf + sizeof (ChrHeader), 0x1A, 0x80); if (MsgEnd == 0) { - Error ("Invalid format for `%s': description not found", Input); + Error ("Invalid format for '%s': description not found", Input); } if (MsgEnd[1] != 0x80 || MsgEnd[2] != 0x00) { - Error ("Invalid format for `%s': wrong header size", Input); + Error ("Invalid format for '%s': wrong header size", Input); } /* We expect the file to hold chars from 0x20 (space) to 0x7E (tilde) */ @@ -372,9 +372,9 @@ static void ConvertFile (const char* Input, const char* Output) if (FirstChar > 0x20 || LastChar < 0x7E) { Print (stderr, 1, "FirstChar = $%04X, CharCount = %u\n", FirstChar, CharCount); - Error ("File `%s' doesn't contain the chars we need", Input); + Error ("File '%s' doesn't contain the chars we need", Input); } else if (LastChar >= 0x100) { - Error ("File `%s' contains too many character definitions", Input); + Error ("File '%s' contains too many character definitions", Input); } /* Print the copyright from the header */ @@ -405,7 +405,7 @@ static void ConvertFile (const char* Input, const char* Output) /* Check if the offset is valid */ if (Remaining <= 0) { - Error ("Invalid data offset in input file `%s'", Input); + Error ("Invalid data offset in input file '%s'", Input); } /* Convert the vector data and place it into the buffer */ @@ -422,7 +422,7 @@ static void ConvertFile (const char* Input, const char* Output) /* The baseline must be zero, otherwise we cannot convert */ if (Buf[0x89] != 0) { - Error ("Baseline of font in `%s' is not zero", Input); + Error ("Baseline of font in '%s' is not zero", Input); } /* If the output file is NULL, use the name of the input file with ".tch" @@ -435,33 +435,33 @@ static void ConvertFile (const char* Input, const char* Output) /* Open the output file */ F = fopen (Output, "wb"); if (F == 0) { - Error ("Cannot open output file `%s': %s", Output, strerror (errno)); + Error ("Cannot open output file '%s': %s", Output, strerror (errno)); } /* Write the header to the output file */ if (fwrite (TchHeader, 1, sizeof (TchHeader), F) != sizeof (TchHeader)) { - Error ("Error writing to `%s' (disk full?)", Output); + Error ("Error writing to '%s' (disk full?)", Output); } /* Write the width table to the output file */ if (fwrite (WidthBuf, 1, 0x5F, F) != 0x5F) { - Error ("Error writing to `%s' (disk full?)", Output); + Error ("Error writing to '%s' (disk full?)", Output); } /* Write the offsets to the output file */ if (fwrite (SB_GetConstBuf (&Offsets), 1, 0x5F * 2, F) != 0x5F * 2) { - Error ("Error writing to `%s' (disk full?)", Output); + Error ("Error writing to '%s' (disk full?)", Output); } /* Write the data to the output file */ Offs = SB_GetLen (&VectorData); if (fwrite (SB_GetConstBuf (&VectorData), 1, Offs, F) != Offs) { - Error ("Error writing to `%s' (disk full?)", Output); + Error ("Error writing to '%s' (disk full?)", Output); } /* Close the output file */ if (fclose (F) != 0) { - Error ("Error closing to `%s': %s", Output, strerror (errno)); + Error ("Error closing to '%s': %s", Output, strerror (errno)); } /* Done */ diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index b6ceb161a..dab77e196 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {F657912F-050A-488B-B203-50ED5715CDD7} Win32Proj cl65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/cl65/main.c b/src/cl65/main.c index e61bd02a5..4a65e8729 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -339,7 +339,7 @@ static void CmdAddFile (CmdDesc* Cmd, const char* File) for (I = 0; I < Cmd->FileCount; ++I) { if (strcmp (Cmd->Files[I], File) == 0) { /* Duplicate file */ - Warning ("Duplicate file in argument list: `%s'", File); + Warning ("Duplicate file in argument list: '%s'", File); /* No need to search further */ break; } @@ -447,7 +447,7 @@ static void ExecProgram (CmdDesc* Cmd) /* Check the result code */ if (Status < 0) { /* Error executing the program */ - Error ("Cannot execute `%s': %s", Cmd->Name, strerror (errno)); + Error ("Cannot execute '%s': %s", Cmd->Name, strerror (errno)); } else if (Status != 0) { /* Called program had an error */ exit (Status); @@ -573,7 +573,7 @@ static void AssembleIntermediate (const char* SourceFile) /* Remove the input file */ if (remove (AsmName) < 0) { - Warning ("Cannot remove temporary file `%s': %s", + Warning ("Cannot remove temporary file '%s': %s", AsmName, strerror (errno)); } @@ -757,7 +757,7 @@ static void Usage (void) " -o name\t\t\tName the output file\n" " -r\t\t\t\tEnable register variables\n" " -t sys\t\t\tSet the target system\n" - " -u sym\t\t\tForce an import of symbol `sym'\n" + " -u sym\t\t\tForce an import of symbol 'sym'\n" " -v\t\t\t\tVerbose mode\n" " -vm\t\t\t\tVerbose map file\n" " -C name\t\t\tUse linker config file\n" @@ -803,7 +803,7 @@ static void Usage (void) " --debug\t\t\tDebug mode\n" " --debug-info\t\t\tAdd debug info\n" " --feature name\t\tSet an emulation feature\n" - " --force-import sym\t\tForce an import of symbol `sym'\n" + " --force-import sym\t\tForce an import of symbol 'sym'\n" " --help\t\t\tHelp (this text)\n" " --include-dir dir\t\tSet a compiler include directory path\n" " --ld-args options\t\tPass options to the linker\n" @@ -1296,9 +1296,9 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg) { Target = FindTarget (Arg); if (Target == TGT_UNKNOWN) { - Error ("No such target system: `%s'", Arg); + Error ("No such target system: '%s'", Arg); } else if (Target == TGT_MODULE) { - Error ("Cannot use `module' as target, use --module instead"); + Error ("Cannot use 'module' as target, use --module instead"); } } @@ -1631,7 +1631,7 @@ int main (int argc, char* argv []) break; default: - Error ("Don't know what to do with `%s'", Arg); + Error ("Don't know what to do with '%s'", Arg); } diff --git a/src/cl65/spawn-unix.inc b/src/cl65/spawn-unix.inc index 283285c76..36eb7aab4 100644 --- a/src/cl65/spawn-unix.inc +++ b/src/cl65/spawn-unix.inc @@ -82,7 +82,7 @@ int spawnvp (int Mode attribute ((unused)), const char* File, char* const argv [ /* The son - exec the program */ if (execvp (File, argv) < 0) { - Error ("Cannot exec `%s': %s", File, strerror (errno)); + Error ("Cannot exec '%s': %s", File, strerror (errno)); } } else { @@ -94,7 +94,7 @@ int spawnvp (int Mode attribute ((unused)), const char* File, char* const argv [ /* Examine the child status */ if (!WIFEXITED (Status)) { - Error ("Subprocess `%s' aborted by signal %d", File, WTERMSIG (Status)); + Error ("Subprocess '%s' aborted by signal %d", File, WTERMSIG (Status)); } } diff --git a/src/co65.vcxproj b/src/co65.vcxproj index 89eed36e1..9b4f18786 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2} Win32Proj co65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/co65/convert.c b/src/co65/convert.c index af036ebf7..ec6d68401 100644 --- a/src/co65/convert.c +++ b/src/co65/convert.c @@ -394,7 +394,7 @@ void Convert (const O65Data* D) switch (O->Type) { case O65_OPT_FILENAME: - Print (stdout, 1, "O65 filename option: `%s'\n", + Print (stdout, 1, "O65 filename option: '%s'\n", GetO65OptionText (O)); break; @@ -402,7 +402,7 @@ void Convert (const O65Data* D) if (O->Len == 2) { Warning ("Operating system option without data found"); } else { - Print (stdout, 1, "O65 operating system option: `%s'\n", + Print (stdout, 1, "O65 operating system option: '%s'\n", GetO65OSName (O->Data[0])); switch (O->Data[0]) { case O65_OS_CC65_MODULE: @@ -418,7 +418,7 @@ void Convert (const O65Data* D) break; case O65_OPT_ASM: - Print (stdout, 1, "O65 assembler option: `%s'\n", + Print (stdout, 1, "O65 assembler option: '%s'\n", GetO65OptionText (O)); break; @@ -427,11 +427,11 @@ void Convert (const O65Data* D) xfree (Author); } Author = xstrdup (GetO65OptionText (O)); - Print (stdout, 1, "O65 author option: `%s'\n", Author); + Print (stdout, 1, "O65 author option: '%s'\n", Author); break; case O65_OPT_TIMESTAMP: - Print (stdout, 1, "O65 timestamp option: `%s'\n", + Print (stdout, 1, "O65 timestamp option: '%s'\n", GetO65OptionText (O)); break; @@ -450,11 +450,11 @@ void Convert (const O65Data* D) /* Open the output file */ F = fopen (OutputName, "w"); if (F == 0) { - Error ("Cannot open `%s': %s", OutputName, strerror (errno)); + Error ("Cannot open '%s': %s", OutputName, strerror (errno)); } /* Create a header */ - fprintf (F, ";\n; File generated by co65 v %s using model `%s'\n;\n", + fprintf (F, ";\n; File generated by co65 v %s using model '%s'\n;\n", GetVersionAsString (), GetModelName (Model)); /* Select the CPU */ diff --git a/src/co65/main.c b/src/co65/main.c index 43d263516..33ecdbf6f 100644 --- a/src/co65/main.c +++ b/src/co65/main.c @@ -112,7 +112,7 @@ static void CheckLabelName (const char* Label) } if (*L) { - Error ("Label name `%s' is invalid", Label); + Error ("Label name '%s' is invalid", Label); } } @@ -123,7 +123,7 @@ static void CheckSegName (const char* Seg) { /* Print an error and abort if the name is not ok */ if (!ValidSegName (Seg)) { - Error ("Segment name `%s' is invalid", Seg); + Error ("Segment name '%s' is invalid", Seg); } } @@ -244,7 +244,7 @@ static void OptO65Model (const char* Opt attribute ((unused)), const char* Arg) /* Search for the model name */ Model = FindModel (Arg); if (Model == O65_MODEL_INVALID) { - Error ("Unknown o65 model `%s'", Arg); + Error ("Unknown o65 model '%s'", Arg); } } @@ -387,7 +387,7 @@ int main (int argc, char* argv []) } else { /* Filename. Check if we already had one */ if (InputName) { - Error ("Don't know what to do with `%s'", Arg); + Error ("Don't know what to do with '%s'", Arg); } else { InputName = Arg; } diff --git a/src/co65/o65.c b/src/co65/o65.c index 3496995a8..81c07bb8c 100644 --- a/src/co65/o65.c +++ b/src/co65/o65.c @@ -361,7 +361,7 @@ O65Data* ReadO65File (const char* Name) /* Open the o65 input file */ FILE* F = fopen (Name, "rb"); if (F == 0) { - Error ("Cannot open `%s': %s", Name, strerror (errno)); + Error ("Cannot open '%s': %s", Name, strerror (errno)); } /* Read the file data */ diff --git a/src/common.vcxproj b/src/common.vcxproj index 644d6da85..eb0dffd66 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -110,18 +110,19 @@ {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} Win32Proj common + 10.0.16299.0 StaticLibrary true - v140 + v141 false true StaticLibrary - v140 + v141 diff --git a/src/common/check.c b/src/common/check.c index c6c5d2d95..0d0e6ef4b 100644 --- a/src/common/check.c +++ b/src/common/check.c @@ -75,5 +75,5 @@ static void DefaultCheckFailed (const char* Msg, const char* Cond, const char* File, unsigned Line) { /* Output a diagnostic and abort */ - AbEnd ("%s%s, file `%s', line %u", Msg, Cond, File, Line); + AbEnd ("%s%s, file '%s', line %u", Msg, Cond, File, Line); } diff --git a/src/common/cmdline.c b/src/common/cmdline.c index 0f6622934..4de79a419 100644 --- a/src/common/cmdline.c +++ b/src/common/cmdline.c @@ -239,7 +239,7 @@ void NeedArg (const char* Opt) void InvArg (const char* Opt, const char* Arg) /* Print an error about an invalid option argument and exit. */ { - AbEnd ("Invalid argument for %s: `%s'", Opt, Arg); + AbEnd ("Invalid argument for %s: '%s'", Opt, Arg); } @@ -247,7 +247,7 @@ void InvArg (const char* Opt, const char* Arg) void InvDef (const char* Def) /* Print an error about an invalid definition and die */ { - AbEnd ("Invalid definition: `%s'", Def); + AbEnd ("Invalid definition: '%s'", Def); } diff --git a/src/common/intptrstack.h b/src/common/intptrstack.h index a7b1c6683..4e9cf08f4 100644 --- a/src/common/intptrstack.h +++ b/src/common/intptrstack.h @@ -47,8 +47,8 @@ typedef struct IntPtrStack IntPtrStack; struct IntPtrInner { - long val; - void *ptr; + long val; + void *ptr; }; struct IntPtrStack { unsigned Count; diff --git a/src/common/target.h b/src/common/target.h index c8e2472d3..5b086e40c 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -103,6 +103,7 @@ extern target_t Target; #define BINFMT_DEFAULT 0 /* Default (binary) */ #define BINFMT_BINARY 1 /* Straight binary format */ #define BINFMT_O65 2 /* Andre Fachats o65 format */ +#define BINFMT_ATARIEXE 3 /* Standard Atari binary load */ diff --git a/src/da65.vcxproj b/src/da65.vcxproj index 06af7505d..7a8b0de68 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {0BCFB793-2B25-40E2-B265-75848824AC4C} Win32Proj da65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/da65/asminc.c b/src/da65/asminc.c index 06a397d52..59ba0aab4 100644 --- a/src/da65/asminc.c +++ b/src/da65/asminc.c @@ -148,7 +148,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) ++L; } else { if (!IgnoreUnknown) { - Error ("%s(%u): Missing `='", Filename, Line); + Error ("%s(%u): Missing '='", Filename, Line); } continue; } diff --git a/src/da65/code.c b/src/da65/code.c index 9aff732b3..3fb6a21d3 100644 --- a/src/da65/code.c +++ b/src/da65/code.c @@ -78,12 +78,12 @@ void LoadCode (void) /* Open the file */ F = fopen (InFile, "rb"); if (F == 0) { - Error ("Cannot open `%s': %s", InFile, strerror (errno)); + Error ("Cannot open '%s': %s", InFile, strerror (errno)); } /* Seek to the end to get the size of the file */ if (fseek (F, 0, SEEK_END) != 0) { - Error ("Cannot seek on file `%s': %s", InFile, strerror (errno)); + Error ("Cannot seek on file '%s': %s", InFile, strerror (errno)); } Size = ftell (F); @@ -101,7 +101,7 @@ void LoadCode (void) ** the file. */ if (fseek (F, InputOffs, SEEK_SET) != 0) { - Error ("Cannot seek on file `%s': %s", InFile, strerror (errno)); + Error ("Cannot seek on file '%s': %s", InFile, strerror (errno)); } Size -= InputOffs; @@ -130,10 +130,10 @@ void LoadCode (void) /* Check if the size is larger than what we can read */ if (Size == 0) { - Error ("Nothing to read from input file `%s'", InFile); + Error ("Nothing to read from input file '%s'", InFile); } if (Size > MaxCount) { - Warning ("File `%s' is too large, ignoring %ld bytes", + Warning ("File '%s' is too large, ignoring %ld bytes", InFile, Size - MaxCount); } else if (MaxCount > Size) { MaxCount = (unsigned) Size; @@ -142,7 +142,7 @@ void LoadCode (void) /* Read from the file and remember the number of bytes read */ Count = fread (CodeBuf + StartAddr, 1, MaxCount, F); if (ferror (F) || Count != MaxCount) { - Error ("Error reading from `%s': %s", InFile, strerror (errno)); + Error ("Error reading from '%s': %s", InFile, strerror (errno)); } /* Close the file */ diff --git a/src/da65/labels.c b/src/da65/labels.c index 6aa7f38cf..97e195ebf 100644 --- a/src/da65/labels.c +++ b/src/da65/labels.c @@ -92,7 +92,9 @@ static void AddLabel (unsigned Addr, attr_t Attr, const char* Name) ** have a name (you guessed that, didn't you?). */ if (ExistingAttr == Attr && - ((Name == 0 && SymTab[Addr] == 0) || strcmp (SymTab[Addr], Name) == 0)) { + ((Name == 0 && SymTab[Addr] == 0) || + (Name != 0 && SymTab[Addr] != 0 && + strcmp (SymTab[Addr], Name) == 0))) { return; } Error ("Duplicate label for address $%04X: %s/%s", Addr, SymTab[Addr], Name); diff --git a/src/da65/main.c b/src/da65/main.c index b0a784dd8..1fc07f006 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -617,7 +617,7 @@ int main (int argc, char* argv []) } else { /* Filename. Check if we already had one */ if (InFile) { - fprintf (stderr, "%s: Don't know what to do with `%s'\n", + fprintf (stderr, "%s: Don't know what to do with '%s'\n", ProgName, Arg); exit (EXIT_FAILURE); } else { diff --git a/src/da65/output.c b/src/da65/output.c index 4daacb1ee..5b0b6b79c 100644 --- a/src/da65/output.c +++ b/src/da65/output.c @@ -96,7 +96,7 @@ void OpenOutput (const char* Name) if (Name != 0) { F = fopen (Name, "w"); if (F == 0) { - Error ("Cannot open `%s': %s", Name, strerror (errno)); + Error ("Cannot open '%s': %s", Name, strerror (errno)); } } else { F = stdout; diff --git a/src/da65/scanner.c b/src/da65/scanner.c index 2bb80a8ef..85853d6c4 100644 --- a/src/da65/scanner.c +++ b/src/da65/scanner.c @@ -7,7 +7,7 @@ /* */ /* */ /* (C) 2000-2005 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ @@ -466,7 +466,7 @@ Again: /* C++ style comment */ NextChar (); if (C != '/') { - InfoError ("Invalid token `/'"); + InfoError ("Invalid token '/'"); } do { NextChar (); @@ -482,7 +482,7 @@ Again: break; default: - InfoError ("Invalid character `%c'", C); + InfoError ("Invalid character '%c'", C); } } @@ -503,7 +503,7 @@ void InfoConsume (unsigned T, const char* Msg) void InfoConsumeLCurly (void) /* Consume a left curly brace */ { - InfoConsume (INFOTOK_LCURLY, "`{' expected"); + InfoConsume (INFOTOK_LCURLY, "'{' expected"); } @@ -511,7 +511,7 @@ void InfoConsumeLCurly (void) void InfoConsumeRCurly (void) /* Consume a right curly brace */ { - InfoConsume (INFOTOK_RCURLY, "`}' expected"); + InfoConsume (INFOTOK_RCURLY, "'}' expected"); } @@ -519,7 +519,7 @@ void InfoConsumeRCurly (void) void InfoConsumeSemi (void) /* Consume a semicolon */ { - InfoConsume (INFOTOK_SEMI, "`;' expected"); + InfoConsume (INFOTOK_SEMI, "';' expected"); } @@ -527,7 +527,7 @@ void InfoConsumeSemi (void) void InfoConsumeColon (void) /* Consume a colon */ { - InfoConsume (INFOTOK_COLON, "`:' expected"); + InfoConsume (INFOTOK_COLON, "':' expected"); } @@ -683,7 +683,7 @@ void InfoOpenInput (void) /* Open the file */ InputFile = fopen (InfoFile, "r"); if (InputFile == 0) { - Error ("Cannot open `%s': %s", InfoFile, strerror (errno)); + Error ("Cannot open '%s': %s", InfoFile, strerror (errno)); } /* Initialize variables */ diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index e0d8894f9..42001ed07 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -2687,7 +2687,7 @@ static void NextToken (InputData* D) break; default: - ParseError (D, CC65_ERROR, "Invalid input character `%c'", D->C); + ParseError (D, CC65_ERROR, "Invalid input character '%c'", D->C); } } diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index afac0cce1..841ec635a 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39} Win32Proj grc65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/grc65/main.c b/src/grc65/main.c index a53801a39..f6554eada 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -151,12 +151,12 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg) break; case TGT_UNKNOWN: - AbEnd ("Unknown target system `%s'", Arg); + AbEnd ("Unknown target system '%s'", Arg); break; default: /* Target is known but unsupported */ - AbEnd ("Unsupported target system `%s'", Arg); + AbEnd ("Unsupported target system '%s'", Arg); break; } } diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index cc5598aad..a78f3128b 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {26C749A0-814C-47A2-9D36-AE92AE932FE4} Win32Proj ld65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 @@ -105,6 +106,7 @@ + @@ -138,8 +140,9 @@ + - \ No newline at end of file + diff --git a/src/ld65/asserts.c b/src/ld65/asserts.c index 276b13595..626ed94a6 100644 --- a/src/ld65/asserts.c +++ b/src/ld65/asserts.c @@ -129,7 +129,7 @@ void CheckAssertions (void) /* If the expression is not constant, we're not able to handle it */ if (!IsConstExpr (A->Expr)) { - Warning ("Cannot evaluate assertion in module `%s', line %u", + Warning ("Cannot evaluate assertion in module '%s', line %u", Module, Line); } else if (GetExprVal (A->Expr) == 0) { @@ -149,7 +149,7 @@ void CheckAssertions (void) break; default: - Internal ("Invalid assertion action (%u) in module `%s', " + Internal ("Invalid assertion action (%u) in module '%s', " "line %u (file corrupt?)", A->Action, Module, Line); break; diff --git a/src/ld65/bin.c b/src/ld65/bin.c index a77d49679..688622415 100644 --- a/src/ld65/bin.c +++ b/src/ld65/bin.c @@ -154,7 +154,7 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M) SegDesc* S = CollAtUnchecked (&M->SegList, I); /* Keep the user happy */ - Print (stdout, 1, " Writing `%s'\n", GetString (S->Name)); + Print (stdout, 1, " Writing '%s'\n", GetString (S->Name)); /* Writes do only occur in the load area and not for BSS segments */ DoWrite = (S->Flags & SF_BSS) == 0 && /* No BSS segment */ @@ -286,23 +286,23 @@ void BinWriteTarget (BinDesc* D, struct File* F) /* Open the file */ D->F = fopen (D->Filename, "wb"); if (D->F == 0) { - Error ("Cannot open `%s': %s", D->Filename, strerror (errno)); + Error ("Cannot open '%s': %s", D->Filename, strerror (errno)); } /* Keep the user happy */ - Print (stdout, 1, "Opened `%s'...\n", D->Filename); + Print (stdout, 1, "Opened '%s'...\n", D->Filename); /* Dump all memory areas */ for (I = 0; I < CollCount (&F->MemoryAreas); ++I) { /* Get this entry */ MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I); - Print (stdout, 1, " Dumping `%s'\n", GetString (M->Name)); + Print (stdout, 1, " Dumping '%s'\n", GetString (M->Name)); BinWriteMem (D, M); } /* Close the file */ if (fclose (D->F) != 0) { - Error ("Cannot write to `%s': %s", D->Filename, strerror (errno)); + Error ("Cannot write to '%s': %s", D->Filename, strerror (errno)); } /* Reset the file and filename */ diff --git a/src/ld65/binfmt.c b/src/ld65/binfmt.c index a510f94b7..f4f2678fe 100644 --- a/src/ld65/binfmt.c +++ b/src/ld65/binfmt.c @@ -73,6 +73,7 @@ int RelocatableBinFmt (unsigned Format) switch (Format) { case BINFMT_BINARY: + case BINFMT_ATARIEXE: Reloc = 0; break; diff --git a/src/ld65/config.c b/src/ld65/config.c index 1d3e810f6..f8bff2ac0 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -68,6 +68,7 @@ #include "objdata.h" #include "scanner.h" #include "spool.h" +#include "xex.h" @@ -149,6 +150,7 @@ static Collection CfgSymbols = STATIC_COLLECTION_INITIALIZER; /* Descriptor holding information about the binary formats */ static BinDesc* BinFmtDesc = 0; static O65Desc* O65FmtDesc = 0; +static XexDesc* XexFmtDesc = 0; @@ -226,7 +228,7 @@ static MemoryArea* CfgGetMemory (unsigned Name) { MemoryArea* M = CfgFindMemory (Name); if (M == 0) { - CfgError (&CfgErrorPos, "Invalid memory area `%s'", GetString (Name)); + CfgError (&CfgErrorPos, "Invalid memory area '%s'", GetString (Name)); } return M; } @@ -320,7 +322,7 @@ static MemoryArea* CreateMemoryArea (const FilePos* Pos, unsigned Name) MemoryArea* M = CfgFindMemory (Name); if (M) { CfgError (&CfgErrorPos, - "Memory area `%s' defined twice", + "Memory area '%s' defined twice", GetString (Name)); } @@ -343,7 +345,7 @@ static SegDesc* NewSegDesc (unsigned Name) /* Check for duplicate names */ SegDesc* S = CfgFindSegDesc (Name); if (S) { - CfgError (&CfgErrorPos, "Segment `%s' defined twice", GetString (Name)); + CfgError (&CfgErrorPos, "Segment '%s' defined twice", GetString (Name)); } /* Allocate memory */ @@ -543,6 +545,7 @@ static void ParseFiles (void) { "FORMAT", CFGTOK_FORMAT }, }; static const IdentTok Formats [] = { + { "ATARI", CFGTOK_ATARIEXE }, { "O65", CFGTOK_O65 }, { "BIN", CFGTOK_BIN }, { "BINARY", CFGTOK_BIN }, @@ -566,7 +569,7 @@ static void ParseFiles (void) F = FindFile (GetStrBufId (&CfgSVal)); if (F == 0) { CfgError (&CfgErrorPos, - "File `%s' not found in MEMORY section", + "File '%s' not found in MEMORY section", SB_GetConstBuf (&CfgSVal)); } @@ -607,6 +610,10 @@ static void ParseFiles (void) F->Format = BINFMT_O65; break; + case CFGTOK_ATARIEXE: + F->Format = BINFMT_ATARIEXE; + break; + default: Error ("Unexpected format token"); } @@ -798,7 +805,7 @@ static void ParseSegments (void) */ if ((S->Flags & SF_BSS) != 0 && (S->Load != S->Run)) { CfgWarning (&CfgErrorPos, - "Segment with type `bss' has both LOAD and RUN " + "Segment with type 'bss' has both LOAD and RUN " "memory areas assigned"); } @@ -806,7 +813,7 @@ static void ParseSegments (void) if ((S->Flags & SF_RO) == 0) { if (S->Run->Flags & MF_RO) { CfgError (&CfgErrorPos, - "Cannot put r/w segment `%s' in r/o memory area `%s'", + "Cannot put r/w segment '%s' in r/o memory area '%s'", GetString (S->Name), GetString (S->Run->Name)); } } @@ -995,6 +1002,87 @@ static void ParseO65 (void) +static void ParseXex (void) +/* Parse the o65 format section */ +{ + static const IdentTok Attributes [] = { + { "RUNAD", CFGTOK_RUNAD }, + { "INITAD", CFGTOK_INITAD }, + }; + + /* Remember the attributes read */ + /* Bitmask to remember the attributes we got already */ + enum { + atNone = 0x0000, + atRunAd = 0x0001, + }; + unsigned AttrFlags = atNone; + Import *RunAd = 0; + Import *InitAd; + MemoryArea *InitMem; + + /* Read the attributes */ + while (CfgTok == CFGTOK_IDENT) { + + /* Map the identifier to a token */ + cfgtok_t AttrTok; + CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute"); + AttrTok = CfgTok; + + /* An optional assignment follows */ + CfgNextTok (); + CfgOptionalAssign (); + + /* Check which attribute was given */ + switch (AttrTok) { + + case CFGTOK_RUNAD: + /* Cannot have this attribute twice */ + FlagAttr (&AttrFlags, atRunAd, "RUNAD"); + /* We expect an identifier */ + CfgAssureIdent (); + /* Generate an import for the symbol */ + RunAd = InsertImport (GenImport (GetStrBufId (&CfgSVal), ADDR_SIZE_ABS)); + /* Remember the file position */ + CollAppend (&RunAd->RefLines, GenLineInfo (&CfgErrorPos)); + /* Eat the identifier token */ + CfgNextTok (); + break; + + case CFGTOK_INITAD: + /* We expect a memory area followed by a colon and an identifier */ + CfgAssureIdent (); + InitMem = CfgGetMemory (GetStrBufId (&CfgSVal)); + CfgNextTok (); + CfgConsumeColon (); + CfgAssureIdent (); + /* Generate an import for the symbol */ + InitAd = InsertImport (GenImport (GetStrBufId (&CfgSVal), ADDR_SIZE_ABS)); + /* Remember the file position */ + CollAppend (&InitAd->RefLines, GenLineInfo (&CfgErrorPos)); + /* Eat the identifier token */ + CfgNextTok (); + /* Add to XEX */ + if (XexAddInitAd (XexFmtDesc, InitMem, InitAd)) + CfgError (&CfgErrorPos, "INITAD already given for memory area"); + break; + + default: + FAIL ("Unexpected attribute token"); + + } + + /* Skip an optional comma */ + CfgOptionalComma (); + } + + /* Set the RUNAD import if we have one */ + if ( RunAd ) + XexSetRunAd (XexFmtDesc, RunAd); +} + + + static void ParseFormats (void) /* Parse a target format section */ { @@ -1002,6 +1090,7 @@ static void ParseFormats (void) { "O65", CFGTOK_O65 }, { "BIN", CFGTOK_BIN }, { "BINARY", CFGTOK_BIN }, + { "ATARI", CFGTOK_ATARIEXE }, }; while (CfgTok == CFGTOK_IDENT) { @@ -1022,6 +1111,10 @@ static void ParseFormats (void) ParseO65 (); break; + case CFGTOK_ATARIEXE: + ParseXex (); + break; + case CFGTOK_BIN: /* No attribibutes available */ break; @@ -1511,7 +1604,7 @@ static void ParseConfig (void) CfgNextTok (); /* Expected a curly brace */ - CfgConsume (CFGTOK_LCURLY, "`{' expected"); + CfgConsume (CFGTOK_LCURLY, "'{' expected"); /* Read the block */ switch (BlockTok) { @@ -1546,7 +1639,7 @@ static void ParseConfig (void) } /* Skip closing brace */ - CfgConsume (CFGTOK_RCURLY, "`}' expected"); + CfgConsume (CFGTOK_RCURLY, "'}' expected"); } while (CfgTok != CFGTOK_EOF); } @@ -1559,6 +1652,7 @@ void CfgRead (void) /* Create the descriptors for the binary formats */ BinFmtDesc = NewBinDesc (); O65FmtDesc = NewO65Desc (); + XexFmtDesc = NewXexDesc (); /* If we have a config name given, open the file, otherwise we will read ** from a buffer. @@ -1603,7 +1697,7 @@ static void ProcessSegments (void) */ if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) { CfgWarning (GetSourcePos (S->LI), - "Segment `%s' with type `bss' contains initialized data", + "Segment '%s' with type 'bss' contains initialized data", GetString (S->Name)); } @@ -1632,7 +1726,7 @@ static void ProcessSegments (void) /* Print a warning if the segment is not optional */ if ((S->Flags & SF_OPTIONAL) == 0) { CfgWarning (&CfgErrorPos, - "Segment `%s' does not exist", + "Segment '%s' does not exist", GetString (S->Name)); } @@ -1665,7 +1759,7 @@ static void ProcessSymbols (void) if (O65GetImport (O65FmtDesc, Sym->Name) != 0) { CfgError ( GetSourcePos (Sym->LI), - "Exported o65 symbol `%s' cannot also be an o65 import", + "Exported o65 symbol '%s' cannot also be an o65 import", GetString (Sym->Name) ); } @@ -1677,7 +1771,7 @@ static void ProcessSymbols (void) if (O65GetExport (O65FmtDesc, Sym->Name) != 0) { CfgError ( GetSourcePos (Sym->LI), - "Duplicate exported o65 symbol: `%s'", + "Duplicate exported o65 symbol: '%s'", GetString (Sym->Name) ); } @@ -1691,7 +1785,7 @@ static void ProcessSymbols (void) if (O65GetExport (O65FmtDesc, Sym->Name) != 0) { CfgError ( GetSourcePos (Sym->LI), - "Imported o65 symbol `%s' cannot also be an o65 export", + "Imported o65 symbol '%s' cannot also be an o65 export", GetString (Sym->Name) ); } @@ -1703,7 +1797,7 @@ static void ProcessSymbols (void) if (O65GetImport (O65FmtDesc, Sym->Name) != 0) { CfgError ( GetSourcePos (Sym->LI), - "Duplicate imported o65 symbol: `%s'", + "Duplicate imported o65 symbol: '%s'", GetString (Sym->Name) ); } @@ -1813,7 +1907,7 @@ unsigned CfgProcess (void) */ if (!IsConstExpr (M->StartExpr)) { CfgError (GetSourcePos (M->LI), - "Start address of memory area `%s' is not constant", + "Start address of memory area '%s' is not constant", GetString (M->Name)); } Addr = M->Start = GetExprVal (M->StartExpr); @@ -1838,7 +1932,7 @@ unsigned CfgProcess (void) /* Resolve the size expression */ if (!IsConstExpr (M->SizeExpr)) { CfgError (GetSourcePos (M->LI), - "Size of memory area `%s' is not constant", + "Size of memory area '%s' is not constant", GetString (M->Name)); } M->Size = GetExprVal (M->SizeExpr); @@ -1859,15 +1953,15 @@ unsigned CfgProcess (void) ++Overwrites; } else { CfgError (GetSourcePos (M->LI), - "Segment `%s' of type `overwrite' requires either" - " `Start' or `Offset' attribute to be specified", + "Segment '%s' of type 'overwrite' requires either" + " 'Start' or 'Offset' attribute to be specified", GetString (S->Name)); } } else { if (Overwrites > 0) { CfgError (GetSourcePos (M->LI), - "Segment `%s' is preceded by at least one segment" - " of type `overwrite'", + "Segment '%s' is preceded by at least one segment" + " of type 'overwrite'", GetString (S->Name)); } } @@ -1893,7 +1987,7 @@ unsigned CfgProcess (void) ** in the linker. */ CfgWarning (GetSourcePos (S->LI), - "Segment `%s' isn't aligned properly; the" + "Segment '%s' isn't aligned properly; the" " resulting executable might not be functional.", GetString (S->Name)); } @@ -1908,7 +2002,7 @@ unsigned CfgProcess (void) */ if (M->FillLevel == 0 && NewAddr > Addr) { CfgWarning (GetSourcePos (S->LI), - "The first segment in memory area `%s' " + "The first segment in memory area '%s' " "needs fill bytes for alignment.", GetString (M->Name)); } @@ -1929,7 +2023,7 @@ unsigned CfgProcess (void) if (S->Flags & SF_OVERWRITE) { if (NewAddr < M->Start) { CfgError (GetSourcePos (S->LI), - "Segment `%s' begins before memory area `%s'", + "Segment '%s' begins before memory area '%s'", GetString (S->Name), GetString (M->Name)); } else { Addr = NewAddr; @@ -1940,12 +2034,12 @@ unsigned CfgProcess (void) ++Overflows; if (S->Flags & SF_OFFSET) { CfgWarning (GetSourcePos (S->LI), - "Segment `%s' offset is too small in `%s' by %lu byte%c", + "Segment '%s' offset is too small in '%s' by %lu byte%c", GetString (S->Name), GetString (M->Name), Addr - NewAddr, (Addr - NewAddr == 1) ? ' ' : 's'); } else { CfgWarning (GetSourcePos (S->LI), - "Segment `%s' start address is too low in `%s' by %lu byte%c", + "Segment '%s' start address is too low in '%s' by %lu byte%c", GetString (S->Name), GetString (M->Name), Addr - NewAddr, (Addr - NewAddr == 1) ? ' ' : 's'); } @@ -1992,7 +2086,7 @@ unsigned CfgProcess (void) ++Overflows; M->Flags |= MF_OVERFLOW; CfgWarning (GetSourcePos (M->LI), - "Segment `%s' overflows memory area `%s' by %lu byte%c", + "Segment '%s' overflows memory area '%s' by %lu byte%c", GetString (S->Name), GetString (M->Name), M->FillLevel - M->Size, (M->FillLevel - M->Size == 1) ? ' ' : 's'); } @@ -2098,6 +2192,10 @@ void CfgWriteTarget (void) O65WriteTarget (O65FmtDesc, F); break; + case BINFMT_ATARIEXE: + XexWriteTarget (XexFmtDesc, F); + break; + default: Internal ("Invalid binary format: %u", F->Format); @@ -2117,7 +2215,7 @@ void CfgWriteTarget (void) MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, J); /* Debugging */ - Print (stdout, 2, "Skipping `%s'...\n", GetString (M->Name)); + Print (stdout, 2, "Skipping '%s'...\n", GetString (M->Name)); /* Walk throught the segments */ for (K = 0; K < CollCount (&M->SegList); ++K) { diff --git a/src/ld65/dbgfile.c b/src/ld65/dbgfile.c index 386706f66..204aff9d8 100644 --- a/src/ld65/dbgfile.c +++ b/src/ld65/dbgfile.c @@ -107,7 +107,7 @@ void CreateDbgFile (void) /* Open the debug info file */ FILE* F = fopen (DbgFileName, "w"); if (F == 0) { - Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno)); + Error ("Cannot create debug file '%s': %s", DbgFileName, strerror (errno)); } /* Output version information */ @@ -166,6 +166,6 @@ void CreateDbgFile (void) /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno)); + Error ("Error closing debug file '%s': %s", DbgFileName, strerror (errno)); } } diff --git a/src/ld65/exports.c b/src/ld65/exports.c index e7ef3d413..0f9ac1c10 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -166,13 +166,13 @@ Import* ReadImport (FILE* F, ObjData* Obj) */ if (ObjHasFiles (I->Obj)) { const LineInfo* LI = GetImportPos (I); - Error ("Invalid import size in for `%s', imported from %s(%u): 0x%02X", + Error ("Invalid import size in for '%s', imported from %s(%u): 0x%02X", GetString (I->Name), GetSourceName (LI), GetSourceLine (LI), I->AddrSize); } else { - Error ("Invalid import size in for `%s', imported from %s: 0x%02X", + Error ("Invalid import size in for '%s', imported from %s: 0x%02X", GetString (I->Name), GetObjFileName (I->Obj), I->AddrSize); @@ -199,7 +199,7 @@ Import* GenImport (unsigned Name, unsigned char AddrSize) /* We have no object file information and no line info for a new ** import */ - Error ("Invalid import size 0x%02X for symbol `%s'", + Error ("Invalid import size 0x%02X for symbol '%s'", I->AddrSize, GetString (I->Name)); } @@ -483,7 +483,7 @@ void InsertExport (Export* E) } } else { /* Duplicate entry, ignore it */ - Warning ("Duplicate external identifier: `%s'", + Warning ("Duplicate external identifier: '%s'", GetString (L->Name)); } return; @@ -662,7 +662,7 @@ long GetExportVal (const Export* E) { if (E->Expr == 0) { /* OOPS */ - Internal ("`%s' is an undefined external", GetString (E->Name)); + Internal ("'%s' is an undefined external", GetString (E->Name)); } return GetExprVal (E->Expr); } @@ -720,9 +720,9 @@ static void CheckSymType (const Export* E) } /* Output the diagnostic */ - Warning ("Address size mismatch for `%s': " - "Exported from %s as `%s', " - "import in %s as `%s'", + Warning ("Address size mismatch for '%s': " + "Exported from %s as '%s', " + "import in %s as '%s'", GetString (E->Name), SB_GetConstBuf (&ExportLoc), ExpAddrSize, @@ -770,7 +770,7 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data) /* Unresolved external */ Import* Imp = E->ImpList; fprintf (stderr, - "Unresolved external `%s' referenced in:\n", + "Unresolved external '%s' referenced in:\n", GetString (E->Name)); while (Imp) { unsigned J; @@ -1053,7 +1053,7 @@ void CircularRefError (const Export* E) /* Print an error about a circular reference using to define the given export */ { const LineInfo* LI = GetExportPos (E); - Error ("Circular reference for symbol `%s', %s(%u)", + Error ("Circular reference for symbol '%s', %s(%u)", GetString (E->Name), GetSourceName (LI), GetSourceLine (LI)); diff --git a/src/ld65/expr.c b/src/ld65/expr.c index efdff899e..2a08b5a98 100644 --- a/src/ld65/expr.c +++ b/src/ld65/expr.c @@ -407,12 +407,12 @@ long GetExprVal (ExprNode* Expr) Error ("Argument for .BANK is not segment relative or too complex"); } if (D.Seg->MemArea == 0) { - Error ("Segment `%s' is referenced by .BANK but " + Error ("Segment '%s' is referenced by .BANK but " "not assigned to a memory area", GetString (D.Seg->Name)); } if (D.Seg->MemArea->BankExpr == 0) { - Error ("Memory area `%s' is referenced by .BANK but " + Error ("Memory area '%s' is referenced by .BANK but " "has no BANK attribute", GetString (D.Seg->MemArea->Name)); } diff --git a/src/ld65/extsyms.c b/src/ld65/extsyms.c index b250125a7..cca10f3ad 100644 --- a/src/ld65/extsyms.c +++ b/src/ld65/extsyms.c @@ -89,7 +89,7 @@ ExtSym* NewExtSym (ExtSymTab* Tab, unsigned Name) ExtSym* E = GetExtSym (Tab, Name); if (E != 0) { /* We do already have a symbol with this name */ - Error ("Duplicate external symbol `%s'", GetString (Name)); + Error ("Duplicate external symbol '%s'", GetString (Name)); } /* Allocate memory for the structure */ diff --git a/src/ld65/library.c b/src/ld65/library.c index 0dadcfa67..dd964cff2 100644 --- a/src/ld65/library.c +++ b/src/ld65/library.c @@ -112,7 +112,7 @@ static void CloseLibrary (Library* L) { /* Close the library file */ if (fclose (L->F) != 0) { - Error ("Error closing `%s': %s", GetString (L->Name), strerror (errno)); + Error ("Error closing '%s': %s", GetString (L->Name), strerror (errno)); } L->F = 0; } @@ -144,7 +144,7 @@ static void LibSeek (Library* L, unsigned long Offs) /* Do a seek in the library checking for errors */ { if (fseek (L->F, Offs, SEEK_SET) != 0) { - Error ("Seek error in `%s' (%lu): %s", + Error ("Seek error in '%s' (%lu): %s", GetString (L->Name), Offs, strerror (errno)); } } @@ -158,7 +158,7 @@ static void LibReadHeader (Library* L) L->Header.Magic = LIB_MAGIC; L->Header.Version = Read16 (L->F); if (L->Header.Version != LIB_VERSION) { - Error ("Wrong data version in `%s'", GetString (L->Name)); + Error ("Wrong data version in '%s'", GetString (L->Name)); } L->Header.Flags = Read16 (L->F); L->Header.IndexOffs = Read32 (L->F); @@ -171,12 +171,12 @@ static void LibReadObjHeader (Library* L, ObjData* O) { O->Header.Magic = Read32 (L->F); if (O->Header.Magic != OBJ_MAGIC) { - Error ("Object file `%s' in library `%s' is invalid", + Error ("Object file '%s' in library '%s' is invalid", GetObjFileName (O), GetString (L->Name)); } O->Header.Version = Read16 (L->F); if (O->Header.Version != OBJ_VERSION) { - Error ("Object file `%s' in library `%s' has wrong version", + Error ("Object file '%s' in library '%s' has wrong version", GetObjFileName (O), GetString (L->Name)); } O->Header.Flags = Read16 (L->F); diff --git a/src/ld65/lineinfo.c b/src/ld65/lineinfo.c index 25eca4fcd..d2c1de0f7 100644 --- a/src/ld65/lineinfo.c +++ b/src/ld65/lineinfo.c @@ -162,7 +162,7 @@ void ReadLineInfoList (FILE* F, ObjData* O, Collection* LineInfos) ** therefore be part of the line infos read from the object file. */ if (LineInfoIndex >= CollCount (&O->LineInfos)) { - Internal ("Invalid line info index %u in module `%s' - max is %u", + Internal ("Invalid line info index %u in module '%s' - max is %u", LineInfoIndex, GetObjFileName (O), CollCount (&O->LineInfos)); diff --git a/src/ld65/main.c b/src/ld65/main.c index 74511a48a..e0dcf9727 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -123,7 +123,7 @@ static void Usage (void) " -m name\t\tCreate a map file\n" " -o name\t\tName the default output file\n" " -t sys\t\tSet the target system\n" - " -u sym\t\tForce an import of symbol `sym'\n" + " -u sym\t\tForce an import of symbol 'sym'\n" " -v\t\t\tVerbose mode\n" " -vm\t\t\tVerbose map file\n" "\n" @@ -133,7 +133,7 @@ static void Usage (void) " --dbgfile name\tGenerate debug information\n" " --define sym=val\tDefine a symbol\n" " --end-group\t\tEnd a library group\n" - " --force-import sym\tForce an import of symbol `sym'\n" + " --force-import sym\tForce an import of symbol 'sym'\n" " --help\t\tHelp (this text)\n" " --lib file\t\tLink this library\n" " --lib-path path\tSpecify a library search path\n" @@ -214,13 +214,13 @@ static void LinkFile (const char* Name, FILETYPE Type) /* We must have a valid name now */ if (PathName == 0) { - Error ("Input file `%s' not found", Name); + Error ("Input file '%s' not found", Name); } /* Try to open the file */ F = fopen (PathName, "rb"); if (F == 0) { - Error ("Cannot open `%s': %s", PathName, strerror (errno)); + Error ("Cannot open '%s': %s", PathName, strerror (errno)); } /* Read the magic word */ @@ -246,7 +246,7 @@ static void LinkFile (const char* Name, FILETYPE Type) default: fclose (F); - Error ("File `%s' has unknown type", PathName); + Error ("File '%s' has unknown type", PathName); } @@ -322,7 +322,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg) PathName = SearchFile (CfgDefaultPath, Arg); } if (PathName == 0) { - Error ("Cannot find config file `%s'", Arg); + Error ("Cannot find config file '%s'", Arg); } /* Read the config */ @@ -376,7 +376,7 @@ static void OptForceImport (const char* Opt attribute ((unused)), const char* Ar /* Get the address size and check it */ unsigned char AddrSize = AddrSizeFromStr (ColPos+1); if (AddrSize == ADDR_SIZE_INVALID) { - Error ("Invalid address size `%s'", ColPos+1); + Error ("Invalid address size '%s'", ColPos+1); } /* Create a copy of the argument */ @@ -509,7 +509,7 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg) /* Map the target name to a target id */ Target = FindTarget (Arg); if (Target == TGT_UNKNOWN) { - Error ("Invalid target name: `%s'", Arg); + Error ("Invalid target name: '%s'", Arg); } /* Set the target binary format */ @@ -526,7 +526,7 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg) PathName = SearchFile (CfgDefaultPath, SB_GetBuf (&FileName)); } if (PathName == 0) { - Error ("Cannot find config file `%s'", SB_GetBuf (&FileName)); + Error ("Cannot find config file '%s'", SB_GetBuf (&FileName)); } /* Free file name memory */ diff --git a/src/ld65/mapfile.c b/src/ld65/mapfile.c index 0cf9b651b..7fec986ff 100644 --- a/src/ld65/mapfile.c +++ b/src/ld65/mapfile.c @@ -67,7 +67,7 @@ void CreateMapFile (int ShortMap) /* Open the map file */ FILE* F = fopen (MapFileName, "w"); if (F == 0) { - Error ("Cannot create map file `%s': %s", MapFileName, strerror (errno)); + Error ("Cannot create map file '%s': %s", MapFileName, strerror (errno)); } /* Write a modules list */ @@ -132,7 +132,7 @@ void CreateMapFile (int ShortMap) /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing map file `%s': %s", MapFileName, strerror (errno)); + Error ("Error closing map file '%s': %s", MapFileName, strerror (errno)); } } @@ -144,7 +144,7 @@ void CreateLabelFile (void) /* Open the label file */ FILE* F = fopen (LabelFileName, "w"); if (F == 0) { - Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno)); + Error ("Cannot create label file '%s': %s", LabelFileName, strerror (errno)); } /* Print the labels for the export symbols */ @@ -155,6 +155,6 @@ void CreateLabelFile (void) /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing label file `%s': %s", LabelFileName, strerror (errno)); + Error ("Error closing label file '%s': %s", LabelFileName, strerror (errno)); } } diff --git a/src/ld65/o65.c b/src/ld65/o65.c index aceb5158a..e36f40d36 100644 --- a/src/ld65/o65.c +++ b/src/ld65/o65.c @@ -784,7 +784,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite) S = Seg [I]; /* Keep the user happy */ - Print (stdout, 1, " Writing `%s'\n", GetString (S->Name)); + Print (stdout, 1, " Writing '%s'\n", GetString (S->Name)); /* Write this segment */ if (DoWrite) { @@ -805,7 +805,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite) /* Check the size of the segment for overflow */ if ((D->Header.Mode & MF_SIZE_MASK) == MF_SIZE_16BIT && D->SegSize > 0xFFFF) { - Error ("Segment overflow in file `%s'", D->Filename); + Error ("Segment overflow in file '%s'", D->Filename); } } @@ -940,7 +940,7 @@ static void O65WriteExports (O65Desc* D) */ Export* E = FindExport (NameIdx); if (E == 0 || IsUnresolvedExport (E)) { - Internal ("Unresolved export `%s' found in O65WriteExports", Name); + Internal ("Unresolved export '%s' found in O65WriteExports", Name); } /* Get the expression for the symbol */ @@ -958,7 +958,7 @@ static void O65WriteExports (O65Desc* D) /* Bail out if we cannot handle the expression */ if (ED.TooComplex) { - Error ("Expression for symbol `%s' is too complex", Name); + Error ("Expression for symbol '%s' is too complex", Name); } /* Determine the segment id for the expression */ @@ -977,7 +977,7 @@ static void O65WriteExports (O65Desc* D) /* For some reason, we didn't find this segment in the list of ** segments written to the o65 file. */ - Error ("Segment for symbol `%s' is undefined", Name); + Error ("Segment for symbol '%s' is undefined", Name); } SegmentID = O65SegType (Seg); @@ -1207,7 +1207,7 @@ void O65SetExport (O65Desc* D, unsigned Ident) */ Export* E = FindExport (Ident); if (E == 0 || IsUnresolvedExport (E)) { - Error ("Unresolved export: `%s'", GetString (Ident)); + Error ("Unresolved export: '%s'", GetString (Ident)); } /* Insert the entry into the table */ @@ -1370,11 +1370,11 @@ void O65WriteTarget (O65Desc* D, File* F) /* Open the file */ D->F = fopen (D->Filename, "wb"); if (D->F == 0) { - Error ("Cannot open `%s': %s", D->Filename, strerror (errno)); + Error ("Cannot open '%s': %s", D->Filename, strerror (errno)); } /* Keep the user happy */ - Print (stdout, 1, "Opened `%s'...\n", D->Filename); + Print (stdout, 1, "Opened '%s'...\n", D->Filename); /* Define some more options: A timestamp, the linker version and the ** filename @@ -1428,7 +1428,7 @@ void O65WriteTarget (O65Desc* D, File* F) /* Close the file */ if (fclose (D->F) != 0) { - Error ("Cannot write to `%s': %s", D->Filename, strerror (errno)); + Error ("Cannot write to '%s': %s", D->Filename, strerror (errno)); } /* Reset the file and filename */ diff --git a/src/ld65/objdata.c b/src/ld65/objdata.c index 7e83f9107..88a7bded4 100644 --- a/src/ld65/objdata.c +++ b/src/ld65/objdata.c @@ -184,7 +184,7 @@ unsigned MakeGlobalStringId (const ObjData* O, unsigned Index) /* Convert a local string id into a global one and return it. */ { if (Index >= O->StringCount) { - Error ("Invalid string index (%u) in module `%s'", + Error ("Invalid string index (%u) in module '%s'", Index, GetObjFileName (O)); } return O->Strings[Index]; @@ -214,7 +214,7 @@ struct Section* GetObjSection (const ObjData* O, unsigned Id) /* Get a section from an object file checking for a valid index */ { if (Id >= CollCount (&O->Sections)) { - Error ("Invalid section index (%u) in module `%s'", + Error ("Invalid section index (%u) in module '%s'", Id, GetObjFileName (O)); } return CollAtUnchecked (&O->Sections, Id); @@ -226,7 +226,7 @@ struct Import* GetObjImport (const ObjData* O, unsigned Id) /* Get an import from an object file checking for a valid index */ { if (Id >= CollCount (&O->Imports)) { - Error ("Invalid import index (%u) in module `%s'", + Error ("Invalid import index (%u) in module '%s'", Id, GetObjFileName (O)); } return CollAtUnchecked (&O->Imports, Id); @@ -238,7 +238,7 @@ struct Export* GetObjExport (const ObjData* O, unsigned Id) /* Get an export from an object file checking for a valid index */ { if (Id >= CollCount (&O->Exports)) { - Error ("Invalid export index (%u) in module `%s'", + Error ("Invalid export index (%u) in module '%s'", Id, GetObjFileName (O)); } return CollAtUnchecked (&O->Exports, Id); @@ -250,7 +250,7 @@ struct DbgSym* GetObjDbgSym (const ObjData* O, unsigned Id) /* Get a debug symbol from an object file checking for a valid index */ { if (Id >= CollCount (&O->DbgSyms)) { - Error ("Invalid debug symbol index (%u) in module `%s'", + Error ("Invalid debug symbol index (%u) in module '%s'", Id, GetObjFileName (O)); } return CollAtUnchecked (&O->DbgSyms, Id); @@ -262,7 +262,7 @@ struct Scope* GetObjScope (const ObjData* O, unsigned Id) /* Get a scope from an object file checking for a valid index */ { if (Id >= CollCount (&O->Scopes)) { - Error ("Invalid scope index (%u) in module `%s'", + Error ("Invalid scope index (%u) in module '%s'", Id, GetObjFileName (O)); } return CollAtUnchecked (&O->Scopes, Id); diff --git a/src/ld65/objfile.c b/src/ld65/objfile.c index 870ca5221..a44e3239a 100644 --- a/src/ld65/objfile.c +++ b/src/ld65/objfile.c @@ -67,7 +67,7 @@ static unsigned GetModule (const char* Name) /* Make a module name from the file name */ const char* Module = FindName (Name); if (*Module == 0) { - Error ("Cannot make module name from `%s'", Name); + Error ("Cannot make module name from '%s'", Name); } return GetStringId (Module); } @@ -79,7 +79,7 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name) { H->Version = Read16 (Obj); if (H->Version != OBJ_VERSION) { - Error ("Object file `%s' has wrong version, expected %08X, got %08X", + Error ("Object file '%s' has wrong version, expected %08X, got %08X", Name, OBJ_VERSION, H->Version); } H->Flags = Read16 (Obj); diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index 3c2346aac..31f1c7a41 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -196,7 +196,7 @@ static void StrVal (void) default: CfgWarning (&CfgErrorPos, - "Unkown escape sequence `%%%c'", C); + "Unkown escape sequence '%%%c'", C); SB_AppendChar (&CfgSVal, '%'); SB_AppendChar (&CfgSVal, C); NextChar (); @@ -389,7 +389,7 @@ Again: break; default: - CfgError (&CfgErrorPos, "Invalid character `%c'", C); + CfgError (&CfgErrorPos, "Invalid character '%c'", C); } } @@ -410,7 +410,7 @@ void CfgConsume (cfgtok_t T, const char* Msg) void CfgConsumeSemi (void) /* Consume a semicolon */ { - CfgConsume (CFGTOK_SEMI, "`;' expected"); + CfgConsume (CFGTOK_SEMI, "';' expected"); } @@ -418,7 +418,7 @@ void CfgConsumeSemi (void) void CfgConsumeColon (void) /* Consume a colon */ { - CfgConsume (CFGTOK_COLON, "`:' expected"); + CfgConsume (CFGTOK_COLON, "':' expected"); } @@ -556,7 +556,7 @@ void CfgOpenInput (void) /* Open the file */ InputFile = fopen (CfgName, "r"); if (InputFile == 0) { - Error ("Cannot open `%s': %s", CfgName, strerror (errno)); + Error ("Cannot open '%s': %s", CfgName, strerror (errno)); } /* Initialize variables */ diff --git a/src/ld65/scanner.h b/src/ld65/scanner.h index 2df952ebb..aeabbdca8 100644 --- a/src/ld65/scanner.h +++ b/src/ld65/scanner.h @@ -93,6 +93,8 @@ typedef enum { CFGTOK_ID, CFGTOK_VERSION, CFGTOK_FORMAT, + CFGTOK_RUNAD, + CFGTOK_INITAD, CFGTOK_LOAD, CFGTOK_RUN, @@ -107,6 +109,7 @@ typedef enum { CFGTOK_ZP, CFGTOK_OVERWRITE, + CFGTOK_ATARIEXE, CFGTOK_O65, CFGTOK_BIN, diff --git a/src/ld65/scopes.c b/src/ld65/scopes.c index edf0d0da2..cf40fac01 100644 --- a/src/ld65/scopes.c +++ b/src/ld65/scopes.c @@ -147,7 +147,7 @@ void PrintDbgScopes (FILE* F) case SCOPE_ENUM: fputs (",type=enum", F); break; default: - Error ("Module `%s': Unknown scope type %u", + Error ("Module '%s': Unknown scope type %u", GetObjFileName (O), S->Type); } diff --git a/src/ld65/segments.c b/src/ld65/segments.c index 9c3972ac5..56a4719ad 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -144,7 +144,7 @@ Segment* GetSegment (unsigned Name, unsigned char AddrSize, const char* ObjName) if (ObjName == 0) { ObjName = "[linker generated]"; } - Error ("Module `%s': Type mismatch for segment `%s'", ObjName, + Error ("Module '%s': Type mismatch for segment '%s'", ObjName, GetString (Name)); } } @@ -210,7 +210,7 @@ Section* ReadSection (FILE* F, ObjData* O) /* Print some data */ Print (stdout, 2, - "Module `%s': Found segment `%s', size = %u, alignment = %lu, type = %u\n", + "Module '%s': Found segment '%s', size = %u, alignment = %lu, type = %u\n", GetObjFileName (O), GetString (Name), Size, Alignment, Type); /* Get the segment for this section */ @@ -226,13 +226,13 @@ Section* ReadSection (FILE* F, ObjData* O) if (Sec->Alignment > 1) { Alignment = LeastCommonMultiple (S->Alignment, Sec->Alignment); if (Alignment > MAX_ALIGNMENT) { - Error ("Combined alignment for segment `%s' is %lu which exceeds " - "%lu. Last module requiring alignment was `%s'.", + Error ("Combined alignment for segment '%s' is %lu which exceeds " + "%lu. Last module requiring alignment was '%s'.", GetString (Name), Alignment, MAX_ALIGNMENT, GetObjFileName (O)); } else if (Alignment >= LARGE_ALIGNMENT) { - Warning ("Combined alignment for segment `%s' is suspiciously " - "large (%lu). Last module requiring alignment was `%s'.", + Warning ("Combined alignment for segment '%s' is suspiciously " + "large (%lu). Last module requiring alignment was '%s'.", GetString (Name), Alignment, GetObjFileName (O)); } S->Alignment = Alignment; @@ -270,7 +270,7 @@ Section* ReadSection (FILE* F, ObjData* O) break; default: - Error ("Unknown fragment type in module `%s', segment `%s': %02X", + Error ("Unknown fragment type in module '%s', segment '%s': %02X", GetObjFileName (O), GetString (S->Name), Type); /* NOTREACHED */ return 0; @@ -502,19 +502,19 @@ void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* break; case SEG_EXPR_RANGE_ERROR: - Error ("Range error in module `%s', line %u", + Error ("Range error in module '%s', line %u", GetFragmentSourceName (Frag), GetFragmentSourceLine (Frag)); break; case SEG_EXPR_TOO_COMPLEX: - Error ("Expression too complex in module `%s', line %u", + Error ("Expression too complex in module '%s', line %u", GetFragmentSourceName (Frag), GetFragmentSourceLine (Frag)); break; case SEG_EXPR_INVALID: - Error ("Invalid expression in module `%s', line %u", + Error ("Invalid expression in module '%s', line %u", GetFragmentSourceName (Frag), GetFragmentSourceLine (Frag)); break; @@ -657,7 +657,7 @@ void CheckSegments (void) /* Check it */ if (S->Size > 0 && S->Dumped == 0) { - Error ("Missing memory area assignment for segment `%s'", + Error ("Missing memory area assignment for segment '%s'", GetString (S->Name)); } } diff --git a/src/ld65/xex.c b/src/ld65/xex.c new file mode 100644 index 000000000..c57fa0a8c --- /dev/null +++ b/src/ld65/xex.c @@ -0,0 +1,436 @@ +/*****************************************************************************/ +/* */ +/* xex.c */ +/* */ +/* Module to handle the Atari XEX binary format */ +/* */ +/* */ +/* */ +/* (C) 2018 Daniel Serpell */ +/* */ +/* */ +/* 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 +#include +#include + +/* common */ +#include "alignment.h" +#include "print.h" +#include "xmalloc.h" + +/* ld65 */ +#include "xex.h" +#include "config.h" +#include "exports.h" +#include "expr.h" +#include "error.h" +#include "global.h" +#include "fileio.h" +#include "lineinfo.h" +#include "memarea.h" +#include "segments.h" +#include "spool.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + +/* Linked list of memory area initialization addresses */ +typedef struct XexInitAd { + MemoryArea *InitMem; + Import *InitAd; + struct XexInitAd *next; +} XexInitAd; + + +struct XexDesc { + unsigned Undef; /* Count of undefined externals */ + FILE* F; /* Output file */ + const char* Filename; /* Name of output file */ + Import* RunAd; /* Run Address */ + XexInitAd* InitAds; /* List of Init Addresses */ + unsigned long HeadPos; /* Position in the file of current header */ + unsigned long HeadEnd; /* End address of current header */ + unsigned long HeadSize; /* Last header size, can be removed if zero */ +}; + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +XexDesc* NewXexDesc (void) +/* Create a new XEX format descriptor */ +{ + /* Allocate memory for a new XexDesc struct */ + XexDesc* D = xmalloc (sizeof (XexDesc)); + + /* Initialize the fields */ + D->Undef = 0; + D->F = 0; + D->Filename = 0; + D->RunAd = 0; + D->InitAds = 0; + D->HeadPos = 0; + D->HeadEnd = 0; + D->HeadSize = 0; + + /* Return the created struct */ + return D; +} + + + +void FreeXexDesc (XexDesc* D) +/* Free a XEX format descriptor */ +{ + xfree (D); +} + + + +void XexSetRunAd (XexDesc* D, Import *RunAd) +/* Set the RUNAD export */ +{ + D->RunAd = RunAd; +} + +XexInitAd* XexSearchInitMem(XexDesc* D, MemoryArea *InitMem) +{ + XexInitAd* I; + for (I=D->InitAds; I != 0; I=I->next) + { + if (I->InitMem == InitMem) + return I; + } + return NULL; +} + + +int XexAddInitAd (XexDesc* D, MemoryArea *InitMem, Import *InitAd) +/* Sets and INITAD for the given memory area */ +{ + XexInitAd* I; + + /* Search for repeated entry */ + if (XexSearchInitMem (D, InitMem)) + return 1; + + I = xmalloc (sizeof (XexInitAd)); + I->InitAd = InitAd; + I->InitMem = InitMem; + I->next = D->InitAds; + D->InitAds = I; + return 0; +} + +static unsigned XexWriteExpr (ExprNode* E, int Signed, unsigned Size, + unsigned long Offs attribute ((unused)), + void* Data) +/* Called from SegWrite for an expression. Evaluate the expression, check the +** range and write the expression value to the file. +*/ +{ + /* There's a predefined function to handle constant expressions */ + return SegWriteConstExpr (((XexDesc*)Data)->F, E, Signed, Size); +} + + + +static void PrintNumVal (const char* Name, unsigned long V) +/* Print a numerical value for debugging */ +{ + Print (stdout, 2, " %s = 0x%lx\n", Name, V); +} + + + +static void XexStartSegment (XexDesc *D, unsigned long Addr, unsigned long Size) +{ + /* Skip segment without size */ + if (!Size) + return; + + /* Store current position */ + unsigned long Pos = ftell (D->F); + unsigned long End = Addr + Size - 1; + + /* See if last header can be expanded into this one */ + if (D->HeadPos && ((D->HeadEnd + 1) == Addr)) { + /* Expand current header */ + D->HeadEnd = End; + D->HeadSize += Size; + fseek (D->F, D->HeadPos + 2, SEEK_SET); + Write16 (D->F, End); + /* Seek to old position */ + fseek (D->F, Pos, SEEK_SET); + } + else + { + if (D->HeadSize == 0) { + /* Last header had no data, replace */ + Pos = D->HeadPos; + fseek (D->F, Pos, SEEK_SET); + } + + /* If we are at start of file, write XEX heder */ + if (Pos == 0) + Write16 (D->F, 0xFFFF); + + /* Writes a new segment header */ + D->HeadPos = ftell (D->F); + D->HeadEnd = End; + D->HeadSize = Size; + Write16 (D->F, Addr); + Write16 (D->F, End); + } +} + + + +static void XexFakeSegment (XexDesc *D, unsigned long Addr) +{ + /* See if last header can be expanded into this one, we are done */ + if (D->HeadPos && ((D->HeadEnd + 1) == Addr)) + return; + + /* If we are at start of file, write XEX heder */ + if (ftell (D->F) == 0) + Write16 (D->F, 0xFFFF); + + /* Writes a new (invalid) segment header */ + D->HeadPos = ftell (D->F); + D->HeadEnd = Addr - 1; + D->HeadSize = 0; + Write16 (D->F, Addr); + Write16 (D->F, D->HeadEnd); +} + + + +static unsigned long XexWriteMem (XexDesc* D, MemoryArea* M) +/* Write the segments of one memory area to a file */ +{ + unsigned I; + + /* Store initial position to get total file size */ + unsigned long StartPos = ftell (D->F); + + /* Always write a segment header for each memory area */ + D->HeadPos = 0; + + /* Get the start address and size of this memory area */ + unsigned long Addr = M->Start; + + /* Walk over all segments in this memory area */ + for (I = 0; I < CollCount (&M->SegList); ++I) { + + int DoWrite; + + /* Get the segment */ + SegDesc* S = CollAtUnchecked (&M->SegList, I); + + /* Keep the user happy */ + Print (stdout, 1, " ATARI EXE Writing `%s'\n", GetString (S->Name)); + + /* Writes do only occur in the load area and not for BSS segments */ + DoWrite = (S->Flags & SF_BSS) == 0 && /* No BSS segment */ + S->Load == M && /* LOAD segment */ + S->Seg->Dumped == 0; /* Not already written */ + + /* If this is the run memory area, we must apply run alignment. If + ** this is not the run memory area but the load memory area (which + ** means that both are different), we must apply load alignment. + ** Beware: DoWrite may be true even if this is the run memory area, + ** because it may be also the load memory area. + */ + if (S->Run == M) { + + /* Handle ALIGN and OFFSET/START */ + if (S->Flags & SF_ALIGN) { + /* Align the address */ + unsigned long NewAddr = AlignAddr (Addr, S->RunAlignment); + if (DoWrite || (M->Flags & MF_FILL) != 0) { + XexStartSegment (D, Addr, NewAddr - Addr); + WriteMult (D->F, M->FillVal, NewAddr - Addr); + PrintNumVal ("SF_ALIGN", NewAddr - Addr); + } + Addr = NewAddr; + } else if (S->Flags & (SF_OFFSET | SF_START)) { + unsigned long NewAddr = S->Addr; + if (S->Flags & SF_OFFSET) { + /* It's an offset, not a fixed address, make an address */ + NewAddr += M->Start; + } + if (DoWrite || (M->Flags & MF_FILL) != 0) { + /* "overwrite" segments are not supported */ + if (S->Flags & SF_OVERWRITE) { + Error ("ATARI file format does not support overwrite for segment '%s'.", + GetString (S->Name)); + } else { + XexStartSegment (D, Addr, NewAddr - Addr); + WriteMult (D->F, M->FillVal, NewAddr-Addr); + PrintNumVal ("SF_OFFSET", NewAddr - Addr); + } + } + Addr = NewAddr; + } + + } else if (S->Load == M) { + + /* Handle ALIGN_LOAD */ + if (S->Flags & SF_ALIGN_LOAD) { + /* Align the address */ + unsigned long NewAddr = AlignAddr (Addr, S->LoadAlignment); + if (DoWrite || (M->Flags & MF_FILL) != 0) { + XexStartSegment (D, Addr, NewAddr - Addr); + WriteMult (D->F, M->FillVal, NewAddr - Addr); + PrintNumVal ("SF_ALIGN_LOAD", NewAddr - Addr); + } + Addr = NewAddr; + } + + } + + /* Now write the segment to disk if it is not a BSS type segment and + ** if the memory area is the load area. + */ + if (DoWrite) { + /* Start a segment with only one byte, will fix later */ + XexFakeSegment (D, Addr); + unsigned long P = ftell (D->F); + SegWrite (D->Filename, D->F, S->Seg, XexWriteExpr, D); + unsigned long Size = ftell (D->F) - P; + /* Fix segment size */ + XexStartSegment (D, Addr, Size); + PrintNumVal ("Wrote", Size); + } else if (M->Flags & MF_FILL) { + XexStartSegment (D, Addr, S->Seg->Size); + WriteMult (D->F, S->Seg->FillVal, S->Seg->Size); + PrintNumVal ("Filled", (unsigned long) S->Seg->Size); + } + + /* If this was the load memory area, mark the segment as dumped */ + if (S->Load == M) { + S->Seg->Dumped = 1; + } + + /* Calculate the new address */ + Addr += S->Seg->Size; + } + + /* If a fill was requested, fill the remaining space */ + if ((M->Flags & MF_FILL) != 0 && M->FillLevel < M->Size) { + unsigned long ToFill = M->Size - M->FillLevel; + Print (stdout, 2, " Filling 0x%lx bytes with 0x%02x\n", + ToFill, M->FillVal); + XexStartSegment (D, Addr, ToFill); + WriteMult (D->F, M->FillVal, ToFill); + M->FillLevel = M->Size; + } + + /* If the last segment is empty, remove */ + if (D->HeadSize == 0 && D->HeadPos) { + fseek (D->F, D->HeadPos, SEEK_SET); + } + + return ftell (D->F) - StartPos; +} + + + +static int XexUnresolved (unsigned Name attribute ((unused)), void* D) +/* Called if an unresolved symbol is encountered */ +{ + /* Unresolved symbols are an error in XEX format. Bump the counter + ** and return zero telling the caller that the symbol is indeed + ** unresolved. + */ + ((XexDesc*) D)->Undef++; + return 0; +} + + + +void XexWriteTarget (XexDesc* D, struct File* F) +/* Write a XEX output file */ +{ + unsigned I; + + /* Place the filename in the control structure */ + D->Filename = GetString (F->Name); + + /* Check for unresolved symbols. The function XexUnresolved is called + ** if we get an unresolved symbol. + */ + D->Undef = 0; /* Reset the counter */ + CheckUnresolvedImports (XexUnresolved, D); + if (D->Undef > 0) { + /* We had unresolved symbols, cannot create output file */ + Error ("%u unresolved external(s) found - cannot create output file", D->Undef); + } + + /* Open the file */ + D->F = fopen (D->Filename, "wb"); + if (D->F == 0) { + Error ("Cannot open `%s': %s", D->Filename, strerror (errno)); + } + + /* Keep the user happy */ + Print (stdout, 1, "Opened `%s'...\n", D->Filename); + + /* Dump all memory areas */ + for (I = 0; I < CollCount (&F->MemoryAreas); ++I) { + /* Get this entry */ + MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I); + /* See if we have an init address for this area */ + XexInitAd* I = XexSearchInitMem (D, M); + Print (stdout, 1, " ATARI EXE Dumping `%s'\n", GetString (M->Name)); + if (XexWriteMem (D, M) && I) { + Write16 (D->F, 0x2E2); + Write16 (D->F, 0x2E3); + Write16 (D->F, GetExportVal (I->InitAd->Exp)); + } + } + + /* Write RUNAD at file end */ + if (D->RunAd) { + Write16 (D->F, 0x2E0); + Write16 (D->F, 0x2E1); + Write16 (D->F, GetExportVal (D->RunAd->Exp)); + } + + /* Close the file */ + if (fclose (D->F) != 0) { + Error ("Cannot write to `%s': %s", D->Filename, strerror (errno)); + } + + /* Reset the file and filename */ + D->F = 0; + D->Filename = 0; +} diff --git a/src/ld65/xex.h b/src/ld65/xex.h new file mode 100644 index 000000000..2eb80de86 --- /dev/null +++ b/src/ld65/xex.h @@ -0,0 +1,77 @@ +/*****************************************************************************/ +/* */ +/* xex.h */ +/* */ +/* Module to handle the Atari EXE binary format */ +/* */ +/* */ +/* */ +/* (C) 2018 Daniel Serpell */ +/* */ +/* */ +/* 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 XEX_H +#define XEX_H + + + +#include "config.h" +#include "exports.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Structure describing the format */ +typedef struct XexDesc XexDesc; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +XexDesc* NewXexDesc (void); +/* Create a new XEX format descriptor */ + +void FreeXexDesc (XexDesc* D); +/* Free a XEX format descriptor */ + +void XexWriteTarget (XexDesc* D, File* F); +/* Write a XEX output file */ + +void XexSetRunAd (XexDesc* D, Import *RunAd); +/* Set the RUNAD export */ + +int XexAddInitAd (XexDesc* D, MemoryArea *InitMem, Import *InitAd); +/* Sets and INITAD for the given memory area */ + +/* End of xex.h */ + +#endif diff --git a/src/od65.vcxproj b/src/od65.vcxproj index 2ace26001..03ea41fce 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD} Win32Proj od65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/od65/main.c b/src/od65/main.c index 2d23f4202..ce71608ed 100644 --- a/src/od65/main.c +++ b/src/od65/main.c @@ -222,7 +222,7 @@ static void DumpFile (const char* Name) /* Try to open the file */ FILE* F = fopen (Name, "rb"); if (F == 0) { - Error ("Cannot open `%s': %s", Name, strerror (errno)); + Error ("Cannot open '%s': %s", Name, strerror (errno)); } /* Read the magic word */ diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index 9ba0980ba..9dc61e53f 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {002A366E-2863-46A8-BDDE-DDF534AAEC73} Win32Proj sim65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/sim65/6502.c b/src/sim65/6502.c index bfbfbd78c..b3c06293a 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -37,8 +37,6 @@ BBRx, BBSx, RMBx, SMBx, WAI, and STP are unsupported * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for 6502) - * one cycle win for fetch-modify-write instructions ignored - (e.g., ROL abs,x takes only 6 cycles if no page break occurs) */ #include "memory.h" @@ -629,6 +627,8 @@ static void OPC_6502_1E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; + if (CPU != CPU_6502 && !PAGE_CROSS (Addr, Regs.XR)) + --Cycles; Val = MemReadByte (Addr) << 1; MemWriteByte (Addr, (unsigned char) Val); TEST_ZF (Val & 0xFF); @@ -898,6 +898,8 @@ static void OPC_6502_3E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; + if (CPU != CPU_6502 && !PAGE_CROSS (Addr, Regs.XR)) + --Cycles; Val = MemReadByte (Addr); ROL (Val); MemWriteByte (Addr, Val); @@ -1132,6 +1134,8 @@ static void OPC_6502_5E (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; + if (CPU != CPU_6502 && !PAGE_CROSS (Addr, Regs.XR)) + --Cycles; Val = MemReadByte (Addr); SET_CF (Val & 0x01); Val >>= 1; @@ -1462,6 +1466,8 @@ static void OPC_6502_7E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; + if (CPU != CPU_6502 && !PAGE_CROSS (Addr, Regs.XR)) + --Cycles; Val = MemReadByte (Addr); ROR (Val); MemWriteByte (Addr, Val); diff --git a/src/sim65/main.c b/src/sim65/main.c index f7f73165a..a1bbc5561 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -141,13 +141,13 @@ static void ReadProgramFile (void) /* Open the file */ FILE* F = fopen (ProgramFile, "rb"); if (F == 0) { - Error ("Cannot open `%s': %s", ProgramFile, strerror (errno)); + Error ("Cannot open '%s': %s", ProgramFile, strerror (errno)); } /* Get the CPU type from the file header */ if ((Val = fgetc(F)) != EOF) { if (Val != CPU_6502 && Val != CPU_65C02) { - Error ("`%s': Invalid CPU type", ProgramFile); + Error ("'%s': Invalid CPU type", ProgramFile); } CPU = Val; } @@ -155,20 +155,20 @@ static void ReadProgramFile (void) /* Read the file body into memory */ while ((Val = fgetc(F)) != EOF) { if (Addr == 0xFF00) { - Error ("`%s': To large to fit into $0200-$FFF0", ProgramFile); + Error ("'%s': To large to fit into $0200-$FFF0", ProgramFile); } MemWriteByte (Addr++, (unsigned char) Val); } /* Check for errors */ if (ferror (F)) { - Error ("Error reading from `%s': %s", ProgramFile, strerror (errno)); + Error ("Error reading from '%s': %s", ProgramFile, strerror (errno)); } /* Close the file */ fclose (F); - Print (stderr, 1, "Loaded `%s' at $0200-$%04X\n", ProgramFile, Addr - 1); + Print (stderr, 1, "Loaded '%s' at $0200-$%04X\n", ProgramFile, Addr - 1); } diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 6e7d992d4..3b770ec57 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -14,16 +14,17 @@ {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF} Win32Proj sp65 + 10.0.16299.0 true - v140 + v141 false true - v140 + v141 diff --git a/src/sp65/asm.c b/src/sp65/asm.c index 8f520cb9e..74c9bc023 100644 --- a/src/sp65/asm.c +++ b/src/sp65/asm.c @@ -89,7 +89,7 @@ static unsigned GetBytesPerLine (const Collection* A) const char* V = GetAttrVal (A, "bytesperline"); if ((V && sscanf (V, "%u%c", &BytesPerLine, &C) != 1) || (BytesPerLine < 1 || BytesPerLine > 64)) { - Error ("Invalid value for attribute `bytesperline'"); + Error ("Invalid value for attribute 'bytesperline'"); } return BytesPerLine; } @@ -106,7 +106,7 @@ static unsigned GetBase (const Collection* A) const char* V = GetAttrVal (A, "base"); if ((V && sscanf (V, "%u%c", &Base, &C) != 1) || (Base != 2 && Base != 10 && Base != 16)) { - Error ("Invalid value for attribute `base'"); + Error ("Invalid value for attribute 'base'"); } return Base; } @@ -119,7 +119,7 @@ static const char* GetIdentifier (const Collection* A) /* Check for a ident attribute */ const char* Ident = GetAttrVal (A, "ident"); if (Ident && !ValidIdentifier (Ident)) { - Error ("Invalid value for attribute `ident'"); + Error ("Invalid value for attribute 'ident'"); } return Ident; } @@ -152,7 +152,7 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Open the output file */ F = fopen (Name, "w"); if (F == 0) { - Error ("Cannot open output file `%s': %s", Name, strerror (errno)); + Error ("Cannot open output file '%s': %s", Name, strerror (errno)); } /* Write a readable header */ @@ -235,6 +235,6 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing output file `%s': %s", Name, strerror (errno)); + Error ("Error closing output file '%s': %s", Name, strerror (errno)); } } diff --git a/src/sp65/attr.c b/src/sp65/attr.c index e57b86973..1b7883c47 100644 --- a/src/sp65/attr.c +++ b/src/sp65/attr.c @@ -160,7 +160,7 @@ const Attr* NeedAttr (const Collection* C, const char* Name, const char* Op) /* Search for the attribute and return it */ unsigned Index; if (!FindAttr (C, Name, &Index)) { - Error ("Found no attribute named `%s' for operation %s", Name, Op); + Error ("Found no attribute named '%s' for operation %s", Name, Op); } return CollConstAt (C, Index); } @@ -201,7 +201,7 @@ void AddAttr (Collection* C, const char* Name, const char* Value) */ unsigned Index; if (FindAttr (C, Name, &Index)) { - Error ("Duplicate command line attribute `%s'", Name); + Error ("Duplicate command line attribute '%s'", Name); } /* Insert the attribute */ @@ -221,7 +221,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name) if (Pos == 0) { /* Combined is actually a value */ if (Name == 0) { - Error ("Command line attribute `%s' doesn't contain a name", Combined); + Error ("Command line attribute '%s' doesn't contain a name", Combined); } AddAttr (C, Name, Combined); } else { diff --git a/src/sp65/bin.c b/src/sp65/bin.c index fdf7ddee0..a3f856340 100644 --- a/src/sp65/bin.c +++ b/src/sp65/bin.c @@ -65,7 +65,7 @@ void WriteBinFile (const StrBuf* Data, const Collection* A, /* Open the output file */ FILE* F = fopen (Name, "wb"); if (F == 0) { - Error ("Cannot open output file `%s': %s", Name, strerror (errno)); + Error ("Cannot open output file '%s': %s", Name, strerror (errno)); } /* Write to the file. We will use fwrite here instead of the fileio @@ -75,11 +75,11 @@ void WriteBinFile (const StrBuf* Data, const Collection* A, */ Size = SB_GetLen (Data); if (fwrite (SB_GetConstBuf (Data), 1, Size, F) != Size) { - Error ("Error writing to output file `%s': %s", Name, strerror (errno)); + Error ("Error writing to output file '%s': %s", Name, strerror (errno)); } /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing output file `%s': %s", Name, strerror (errno)); + Error ("Error closing output file '%s': %s", Name, strerror (errno)); } } diff --git a/src/sp65/c.c b/src/sp65/c.c index d4d6ee00b..57950ca6d 100644 --- a/src/sp65/c.c +++ b/src/sp65/c.c @@ -89,7 +89,7 @@ static unsigned GetBytesPerLine (const Collection* A) const char* V = GetAttrVal (A, "bytesperline"); if ((V && sscanf (V, "%u%c", &BytesPerLine, &C) != 1) || (BytesPerLine < 1 || BytesPerLine > 64)) { - Error ("Invalid value for attribute `bytesperline'"); + Error ("Invalid value for attribute 'bytesperline'"); } return BytesPerLine; } @@ -105,7 +105,7 @@ static unsigned GetBase (const Collection* A) /* Check for a base attribute */ const char* V = GetAttrVal (A, "base"); if ((V && sscanf (V, "%u%c", &Base, &C) != 1) || (Base != 10 && Base != 16)) { - Error ("Invalid value for attribute `base'"); + Error ("Invalid value for attribute 'base'"); } return Base; } @@ -118,7 +118,7 @@ static const char* GetIdentifier (const Collection* A) /* Check for a ident attribute */ const char* Ident = GetAttrVal (A, "ident"); if (Ident && !ValidIdentifier (Ident)) { - Error ("Invalid value for attribute `ident'"); + Error ("Invalid value for attribute 'ident'"); } return Ident; } @@ -151,7 +151,7 @@ void WriteCFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Open the output file */ F = fopen (Name, "w"); if (F == 0) { - Error ("Cannot open output file `%s': %s", Name, strerror (errno)); + Error ("Cannot open output file '%s': %s", Name, strerror (errno)); } /* Write a readable header */ @@ -220,6 +220,6 @@ void WriteCFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Close the file */ if (fclose (F) != 0) { - Error ("Error closing output file `%s': %s", Name, strerror (errno)); + Error ("Error closing output file '%s': %s", Name, strerror (errno)); } } diff --git a/src/sp65/convert.c b/src/sp65/convert.c index 45b40f1ef..a9047ffb0 100644 --- a/src/sp65/convert.c +++ b/src/sp65/convert.c @@ -106,7 +106,7 @@ StrBuf* ConvertTo (const Bitmap* B, const Collection* A) sizeof (ConverterMap[0]), Compare); if (E == 0) { - Error ("No such target format: `%s'", Format); + Error ("No such target format: '%s'", Format); } /* Do the conversion */ diff --git a/src/sp65/input.c b/src/sp65/input.c index 381adf6b9..f1df247ae 100644 --- a/src/sp65/input.c +++ b/src/sp65/input.c @@ -103,7 +103,7 @@ Bitmap* ReadInputFile (const Collection* A) sizeof (FormatTable[0]), CompareFileId); if (F == 0) { - Error ("Unknown input format `%s'", Format); + Error ("Unknown input format '%s'", Format); } } else { /* No format given, use file name extension */ @@ -112,7 +112,7 @@ Bitmap* ReadInputFile (const Collection* A) sizeof (FormatTable) / sizeof (FormatTable[0])); /* Found? */ if (F == 0) { - Error ("Cannot determine file format of input file `%s'", Name); + Error ("Cannot determine file format of input file '%s'", Name); } } diff --git a/src/sp65/lynxsprite.c b/src/sp65/lynxsprite.c index e4afc7773..4d7669faf 100644 --- a/src/sp65/lynxsprite.c +++ b/src/sp65/lynxsprite.c @@ -80,7 +80,7 @@ static enum Mode GetMode (const Collection* A) } else if (strcmp (Mode, "shaped") == 0) { return smShaped; } else { - Error ("Invalid value for attribute `mode'"); + Error ("Invalid value for attribute 'mode'"); } } diff --git a/src/sp65/main.c b/src/sp65/main.c index 5c9724a8a..1dda696d6 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -392,7 +392,7 @@ int main (int argc, char* argv []) } } else { /* We don't accept anything else */ - AbEnd ("Don't know what to do with `%s'", Arg); + AbEnd ("Don't know what to do with '%s'", Arg); } /* Next argument */ diff --git a/src/sp65/output.c b/src/sp65/output.c index 3ffa38dcc..c12d1f612 100644 --- a/src/sp65/output.c +++ b/src/sp65/output.c @@ -124,7 +124,7 @@ void WriteOutputFile (const StrBuf* Data, const Collection* A, const Bitmap* B) sizeof (FormatTable[0]), CompareFileId); if (F == 0) { - Error ("Unknown output format `%s'", Format); + Error ("Unknown output format '%s'", Format); } } else { /* No format given, use file name extension */ @@ -133,7 +133,7 @@ void WriteOutputFile (const StrBuf* Data, const Collection* A, const Bitmap* B) sizeof (FormatTable) / sizeof (FormatTable[0])); /* Found? */ if (F == 0) { - Error ("Cannot determine file format of output file `%s'", Name); + Error ("Cannot determine file format of output file '%s'", Name); } } diff --git a/src/sp65/pcx.c b/src/sp65/pcx.c index 273ad8cf0..d721671b3 100644 --- a/src/sp65/pcx.c +++ b/src/sp65/pcx.c @@ -146,10 +146,10 @@ static PCXHeader* ReadPCXHeader (FILE* F, const char* Name) /* Check the header data */ if (P->Id != PCX_MAGIC_ID || P->FileVersion == 1 || P->FileVersion > 5) { - Error ("`%s' is not a PCX file", Name); + Error ("'%s' is not a PCX file", Name); } if (P->Compressed > 1) { - Error ("Unsupported compression (%d) in PCX file `%s'", + Error ("Unsupported compression (%d) in PCX file '%s'", P->Compressed, Name); } /* We support: @@ -160,15 +160,15 @@ static PCXHeader* ReadPCXHeader (FILE* F, const char* Name) if (!((P->BPP == 1 && P->Planes == 1) || (P->BPP == 8 && (P->Planes == 1 || P->Planes == 3 || P->Planes == 4)))) { /* We could support others, but currently we don't */ - Error ("Unsupported PCX format: %u planes, %u bpp in PCX file `%s'", + Error ("Unsupported PCX format: %u planes, %u bpp in PCX file '%s'", P->Planes, P->BPP, Name); } if (P->PalInfo != 1 && P->PalInfo != 2) { - Error ("Unsupported palette info (%u) in PCX file `%s'", + Error ("Unsupported palette info (%u) in PCX file '%s'", P->PalInfo, Name); } if (!ValidBitmapSize (P->Width, P->Height)) { - Error ("PCX file `%s' has an unsupported size (w=%u, h=%d)", + Error ("PCX file '%s' has an unsupported size (w=%u, h=%d)", Name, P->Width, P->Height); } @@ -261,7 +261,7 @@ Bitmap* ReadPCXFile (const Collection* A) /* Open the file */ FILE* F = fopen (Name, "rb"); if (F == 0) { - Error ("Cannot open PCX file `%s': %s", Name, strerror (errno)); + Error ("Cannot open PCX file '%s': %s", Name, strerror (errno)); } /* Read the PCX header */ @@ -357,7 +357,7 @@ Bitmap* ReadPCXFile (const Collection* A) /* Check for palette marker */ if (Read8 (F) != 0x0C) { - Error ("Invalid palette marker in PCX file `%s'", Name); + Error ("Invalid palette marker in PCX file '%s'", Name); } } else if (EndPos == CurPos) { @@ -367,12 +367,12 @@ Bitmap* ReadPCXFile (const Collection* A) /* Check the maximum index for safety */ if (MaxIdx > 15) { - Error ("PCX file `%s' contains more than 16 indexed colors " + Error ("PCX file '%s' contains more than 16 indexed colors " "but no extra palette", Name); } } else { - Error ("Error in PCX file `%s': %lu bytes at end of pixel data", + Error ("Error in PCX file '%s': %lu bytes at end of pixel data", Name, EndPos - CurPos); } diff --git a/src/sp65/vic2sprite.c b/src/sp65/vic2sprite.c index 3e99ec7b2..94a9ad499 100644 --- a/src/sp65/vic2sprite.c +++ b/src/sp65/vic2sprite.c @@ -81,7 +81,7 @@ static enum Mode GetMode (const Collection* A) } else if (strcmp (Mode, "multicolor") == 0) { return smMultiColor; } else { - Error ("Invalid value for attribute `mode'"); + Error ("Invalid value for attribute 'mode'"); } } diff --git a/test/err/front.c b/test/err/front.c index dde8d47ec..af59209b7 100644 --- a/test/err/front.c +++ b/test/err/front.c @@ -5,25 +5,25 @@ */ main() { - return 0; + return 0; } nested(a,b) { - if ((a<4 && b == 'r') - || (a == 1 && (b == 'h' || b == 'i')) - || (a == 2 && (b == 'o' || b == 'y')) - ) a=b; + if ((a<4 && b == 'r') + || (a == 1 && (b == 'h' || b == 'i')) + || (a == 2 && (b == 'o' || b == 'y')) + ) a=b; } /* type name scope */ -void s(struct D *d) {} /* this struct D differs from the one below */ +void s(struct D *d) {} /* this struct D differs from the one below */ typedef struct D D; struct D {int x, y;} Dy={0}; D Dz={1}; Dfunc(){ - D a; a.y=1; - s(&Dy); /* error */ + D a; a.y=1; + s(&Dy); /* error */ } /* qualifiers */ @@ -33,39 +33,39 @@ const int a, *x; int b, *y; volatile unsigned z; f() { - x = y; - z = z + z; /* should be 2 references to z's r-value */ + x = y; + z = z + z; /* should be 2 references to z's r-value */ } f1() { - x = &a; - x = &b; - y = &a; /* error */ - y = &b; + x = &a; + x = &b; + y = &a; /* error */ + y = &b; } f2(int **a, int **b) { - f(&x, &y); - **a = 0; - return **b; + f(&x, &y); + **a = 0; + return **b; } g(const int *p) { - g(&a); - g(&b); - return *p; + g(&a); + g(&b); + return *p; } h(int *p) { - f(&a); - f(&b); - return *p; + f(&a); + f(&b); + return *p; } h1(const int x, int y) { - h1(a,b); - h1(b,a); - return x + y; + h1(a,b); + h1(b,a); + return x + y; } h2() { - char *b; const void *p; - p = b; - b = p; /* error (incompatible pointer type) */ + char *b; const void *p; + p = b; + b = p; /* error (incompatible pointer type) */ } /* static naming */ @@ -120,14 +120,14 @@ extern int strcmp(const char*, const char*); extern void qsort(void*, int, int, int (*)(const void*, const void*)); extern int cmp(char**a, char**b) { return strcmp(*a,*b); } sort() { - int n; char *a[100]; - qsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp); + int n; char *a[100]; + qsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp); qsort(a, n, sizeof(char*), cmp); /* error (incompatible pointer type) */ } /* nasty calls */ onearg(){ - int a,b,c,d; - f( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) ); /* 1 argument */ + int a,b,c,d; + f( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) ); /* 1 argument */ } diff --git a/test/misc/fields.c b/test/misc/fields.c index 83bee82b7..acc561ce7 100644 --- a/test/misc/fields.c +++ b/test/misc/fields.c @@ -20,11 +20,11 @@ main() #ifdef REFCC #include struct foo { - int16_t a; - char b; - int16_t x : 12, y : 4; - int16_t zz : 1, : 0, : 4, z : 3; - char c; + int16_t a; + char b; + int16_t x : 12, y : 4; + int16_t zz : 1, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { uint16_t a:2, b:4, c:16;} y = { 7, 8, 9}; @@ -33,11 +33,11 @@ int16_t i = 8; #else struct foo { - int a; - char b; - int x : 12, y : 4; - int zz : 1, : 0, : 4, z : 3; - char c; + int a; + char b; + int x : 12, y : 4; + int zz : 1, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { unsigned int a:2, b:4, c:16;} y = { 7, 8, 9}; @@ -46,10 +46,10 @@ int i = 8; #else struct foo { - int a; - char b; - int x : 12, y : 4, : 0, : 4, z : 3; - char c; + int a; + char b; + int x : 12, y : 4, : 0, : 4, z : 3; + char c; } x = { 1, 2, 3, 4, 5, 6 }; struct baz { unsigned int a:2, b:4, c:32;} y = { 7, 8, 9}; @@ -63,32 +63,32 @@ f2(struct baz *p); main() { - printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); - printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); - x.y = i; - x.z = 070; - printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); - y.a = 2; - y.c = i; - printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); + printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); + printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); + x.y = i; + x.z = 070; + printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c); + y.a = 2; + y.c = i; + printf("y = %d b:%d c:%d\n", y.a, y.b, y.c); #ifdef CAST_STRUCT_PTR - f2((struct baz *)&x); + f2((struct baz *)&x); #else - f2(&x); + f2(&x); #endif - return 0; + return 0; } f1(struct baz *p) { - p->a = p->b = 0; - if (p->b) - printf("p->b != 0!\n"); - p->a = 0x3; p->b = 0xf; - printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b); + p->a = p->b = 0; + if (p->b) + printf("p->b != 0!\n"); + p->a = 0x3; p->b = 0xf; + printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b); } f2(struct baz *p) { - p->a = (i==0); - p->b = (f1(p),0); + p->a = (i==0); + p->b = (f1(p),0); } #endif diff --git a/test/misc/goto.ref b/test/misc/goto.ref index ad69cdfe2..85dc20a61 100644 --- a/test/misc/goto.ref +++ b/test/misc/goto.ref @@ -1,7 +1,7 @@ goto.c(8): Warning: Goto at line 8 to label start jumps into a block with initialization of an object that has automatic storage duration -goto.c(97): Warning: `a' is defined but never used -goto.c(117): Warning: `a' is defined but never used -goto.c(137): Warning: `a' is defined but never used +goto.c(97): Warning: 'a' is defined but never used +goto.c(117): Warning: 'a' is defined but never used +goto.c(137): Warning: 'a' is defined but never used goto.c(159): Warning: Goto at line 23 to label l8 jumps into a block with initialization of an object that has automatic storage duration goto.c(159): Warning: Goto at line 44 to label l8 jumps into a block with initialization of an object that has automatic storage duration goto.c(159): Warning: Goto at line 65 to label l8 jumps into a block with initialization of an object that has automatic storage duration diff --git a/test/misc/limits.c b/test/misc/limits.c index 613d6bd09..427c54d23 100644 --- a/test/misc/limits.c +++ b/test/misc/limits.c @@ -7,9 +7,9 @@ #include #include -#define SSHRT_MAX SHRT_MAX -#define SINT_MAX INT_MAX -#define SLONG_MAX LONG_MAX +#define SSHRT_MAX SHRT_MAX +#define SINT_MAX INT_MAX +#define SLONG_MAX LONG_MAX #define UCHAR_MIN 0 #define USHRT_MIN 0 diff --git a/test/misc/sitest.c b/test/misc/sitest.c index 9570f4989..3332c064e 100644 --- a/test/misc/sitest.c +++ b/test/misc/sitest.c @@ -5,29 +5,29 @@ */ /* - sitest -- exercise features of C99 and + sitest -- exercise features of C99 and - This source code has been placed into the PUBLIC DOMAIN by its author. + This source code has been placed into the PUBLIC DOMAIN by its author. - last edit: 1999/11/05 gwyn@arl.mil + last edit: 1999/11/05 gwyn@arl.mil - Tries to accommodate pre-C99 versions of . + Tries to accommodate pre-C99 versions of . - Takes advantage of __Q8_* symbols defined by a particular - implementation of , but doesn't require them. + Takes advantage of __Q8_* symbols defined by a particular + implementation of , but doesn't require them. - NOTE: This is not a thorough validation test of the facilities. + NOTE: This is not a thorough validation test of the facilities. */ #define NO_INTERNAL_WCHAR /*#define STANDALONE*/ -#include -#include /* for CHAR_BIT */ -#include -#include /* for ptrdiff_t */ -#include -#include +#include +#include /* for CHAR_BIT */ +#include +#include /* for ptrdiff_t */ +#include +#include #if !defined(STANDARD_C99) && !defined(STANDARD_CC65) @@ -41,15 +41,15 @@ #endif -#include /* embeds */ +#include /* embeds */ -#include /* for sig_atomic_t */ +#include /* for sig_atomic_t */ -#if defined(INTMAX_MAX) /* has C99 features */ -#include +#if defined(INTMAX_MAX) /* has C99 features */ +#include #endif -#include /* test idempotency */ +#include /* test idempotency */ #ifdef STANDALONE @@ -61,1531 +61,1531 @@ FILE *outfile=NULL; #endif -#if __STDC_VERSION__ >= 199901 -#ifndef __Q8_QT -#define __Q8_QT long long +#if __STDC_VERSION__ >= 199901 +#ifndef __Q8_QT +#define __Q8_QT long long #endif #endif -#ifdef PRIdMAX -#define HAVE_PRIdMAX -#ifndef __Q8_MT -#define __Q8_MT intmax_t +#ifdef PRIdMAX +#define HAVE_PRIdMAX +#ifndef __Q8_MT +#define __Q8_MT intmax_t #endif #else -#ifdef PRIdLEAST64 -#ifndef __Q8_MT -#define __Q8_MT int_least64_t +#ifdef PRIdLEAST64 +#ifndef __Q8_MT +#define __Q8_MT int_least64_t #endif -#define PRIdMAX PRIdLEAST64 +#define PRIdMAX PRIdLEAST64 #else -#ifndef __Q8_MT -#define __Q8_MT long +#ifndef __Q8_MT +#define __Q8_MT long #endif -#define PRIdMAX "ld" +#define PRIdMAX "ld" #endif #endif -#ifdef PRIuMAX -#define HAVE_PRIuMAX -#define U__Q8_MT uintmax_t +#ifdef PRIuMAX +#define HAVE_PRIuMAX +#define U__Q8_MT uintmax_t #else -#ifdef PRIuLEAST64 -#define U__Q8_MT uint_least64_t -#define PRIuMAX PRIuLEAST64 +#ifdef PRIuLEAST64 +#define U__Q8_MT uint_least64_t +#define PRIuMAX PRIuLEAST64 #else -#define U__Q8_MT unsigned long -#define PRIuMAX "lu" +#define U__Q8_MT unsigned long +#define PRIuMAX "lu" #endif #endif -#define STR_SUB(s) # s -#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ +#define STR_SUB(s) # s +#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ -#if defined(SCNo32) || defined(PRIo32) -static int32_t int32; +#if defined(SCNo32) || defined(PRIo32) +static int32_t int32; #endif -static int_least16_t intl16; -static uint_least16_t uintl16; -static uint_fast16_t uintf16; -static intmax_t intmax; -static uintmax_t uintmax; +static int_least16_t intl16; +static uint_least16_t uintl16; +static uint_fast16_t uintf16; +static intmax_t intmax; +static uintmax_t uintmax; int -main() { - int status = 0; /* exit status to be returned */ +main() { + int status = 0; /* exit status to be returned */ - - /* features: */ + + /* features: */ - printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); - printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ - printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); - printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); - printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); -#ifdef __Q8_QT - printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); + printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); + printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ + printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); + printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); + printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); +#ifdef __Q8_QT + printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); #else - printf("*** long long isn't defined ***\n"); + printf("*** long long isn't defined ***\n"); #endif - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); - printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); - printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); - printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); -#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 - printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); + printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); + printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); + printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); +#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 + printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); #else - printf("*** wint_t isn't defined ***\n"); - status = EXIT_FAILURE; + printf("*** wint_t isn't defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INT8_MAX - printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); - printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); +#ifdef INT8_MAX + printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); + printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); #endif -#ifdef INT9_MAX - printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); - printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); +#ifdef INT9_MAX + printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); + printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); #endif -#ifdef INT12_MAX - printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); - printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); +#ifdef INT12_MAX + printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); + printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); #endif -#ifdef INT16_MAX - printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); - printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); +#ifdef INT16_MAX + printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); + printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); #endif -#ifdef INT18_MAX - printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); - printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); +#ifdef INT18_MAX + printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); + printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); #endif -#ifdef INT24_MAX - printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); - printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); +#ifdef INT24_MAX + printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); + printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); #endif -#ifdef INT32_MAX - printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); - printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); +#ifdef INT32_MAX + printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); + printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); #endif -#ifdef INT36_MAX - printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); - printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); +#ifdef INT36_MAX + printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); + printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); #endif -#ifdef INT40_MAX - printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); - printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); +#ifdef INT40_MAX + printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); + printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); #endif -#ifdef INT48_MAX - printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); - printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); +#ifdef INT48_MAX + printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); + printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); #endif -#ifdef INT60_MAX - printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); - printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); +#ifdef INT60_MAX + printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); + printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); #endif -#ifdef INT64_MAX - printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); - printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); +#ifdef INT64_MAX + printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); + printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); #endif -#ifdef INT72_MAX - printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); - printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); +#ifdef INT72_MAX + printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); + printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); #endif -#ifdef INT128_MAX - printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); - printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); +#ifdef INT128_MAX + printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); + printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); #endif - printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); - printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); - printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); - printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); - printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); - printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); -#ifdef INT_LEAST64_MAX - printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); - printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); + printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); + printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); + printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); + printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); + printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); + printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); +#ifdef INT_LEAST64_MAX + printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); + printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); #else - printf("*** uint_least64_t isn't defined ***\n"); - status = EXIT_FAILURE; + printf("*** uint_least64_t isn't defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INT_LEAST128_MAX - printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); - printf("sizeof(uint_least128_t)=%u\n", - (unsigned)sizeof(uint_least128_t)); +#ifdef INT_LEAST128_MAX + printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); + printf("sizeof(uint_least128_t)=%u\n", + (unsigned)sizeof(uint_least128_t)); #endif - printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); - printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); - printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); - printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); - printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); - printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); -#ifdef INT_FAST64_MAX - printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); - printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); + printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); + printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); + printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); + printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); + printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); + printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); +#ifdef INT_FAST64_MAX + printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); + printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); #else - printf("*** int_fast64_t isn't defined ***\n"); - status = EXIT_FAILURE; + printf("*** int_fast64_t isn't defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INT_FAST128_MAX - printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); - printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); +#ifdef INT_FAST128_MAX + printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); + printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); #endif -#if defined(INTPTR_MAX) - printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); -#if defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); +#if defined(INTPTR_MAX) + printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); +#if defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); #else - printf("*** intptr_t is defined but uintptr_t isn't ***\n"); - status = EXIT_FAILURE; + printf("*** intptr_t is defined but uintptr_t isn't ***\n"); + status = EXIT_FAILURE; #endif -#elif defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); - printf("*** uintptr_t is defined but intptr_t isn't ***\n"); - status = EXIT_FAILURE; +#elif defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); + printf("*** uintptr_t is defined but intptr_t isn't ***\n"); + status = EXIT_FAILURE; #else - printf("*** neither intptr_t nor uintptr_t is defined ***\n"); - status = EXIT_FAILURE; + printf("*** neither intptr_t nor uintptr_t is defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INTMAX_MAX - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); +#ifdef INTMAX_MAX + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); #else - printf("*** intmax_t isn't defined ***\n"); - status = EXIT_FAILURE; + printf("*** intmax_t isn't defined ***\n"); + status = EXIT_FAILURE; #endif -#ifdef INT8_MAX - printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); - printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); - printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); +#ifdef INT8_MAX + printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); + printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); + printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); #endif -#ifdef INT9_MAX - printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); - printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); - printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); +#ifdef INT9_MAX + printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); + printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); + printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); #endif -#ifdef INT12_MAX - printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); - printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); - printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); +#ifdef INT12_MAX + printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); + printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); + printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); #endif -#ifdef INT16_MAX - printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); - printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); - printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); +#ifdef INT16_MAX + printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); + printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); + printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); #endif -#ifdef INT18_MAX - printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); - printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); - printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); +#ifdef INT18_MAX + printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); + printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); + printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); #endif -#ifdef INT24_MAX - printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); - printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); - printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); +#ifdef INT24_MAX + printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); + printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); + printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); #endif -#ifdef INT32_MAX - printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); - printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); - printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); +#ifdef INT32_MAX + printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); + printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); + printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); #endif -#ifdef INT36_MAX - printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); - printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); - printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); +#ifdef INT36_MAX + printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); + printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); + printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); #endif -#ifdef INT40_MAX - printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); - printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); - printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); +#ifdef INT40_MAX + printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); + printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); + printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); #endif -#ifdef INT48_MAX - printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); - printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); - printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); +#ifdef INT48_MAX + printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); + printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); + printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); #endif -#ifdef INT60_MAX - printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); - printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); - printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); +#ifdef INT60_MAX + printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); + printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); + printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); #endif -#ifdef INT64_MAX - printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); - printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); - printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); +#ifdef INT64_MAX + printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); + printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); + printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); #endif -#ifdef INT72_MAX - printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); - printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); - printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); +#ifdef INT72_MAX + printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); + printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); + printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); #endif -#ifdef INT128_MAX - printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); - printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); - printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); +#ifdef INT128_MAX + printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); + printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); + printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); #endif - printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); - printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); - printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST8_MAX); - printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); - printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); - printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST16_MAX); - printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); - printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); - printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST32_MAX); -#ifdef INT_LEAST64_MAX - printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); - printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); - printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); + printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); + printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); + printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST8_MAX); + printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); + printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); + printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST16_MAX); + printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); + printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); + printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST32_MAX); +#ifdef INT_LEAST64_MAX + printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); + printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); + printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); #endif -#ifdef INT_LEAST128_MAX - printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); - printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); - printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); +#ifdef INT_LEAST128_MAX + printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); + printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); + printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); #endif - printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); - printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); - printf("UINT_FAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST8_MAX); - printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); - printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); - printf("UINT_FAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST16_MAX); - printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); - printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); - printf("UINT_FAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST32_MAX); -#ifdef INT_FAST64_MAX - printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); - printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); - printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); + printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); + printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); + printf("UINT_FAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST8_MAX); + printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); + printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); + printf("UINT_FAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST16_MAX); + printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); + printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); + printf("UINT_FAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST32_MAX); +#ifdef INT_FAST64_MAX + printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); + printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); + printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); #endif -#ifdef INT_FAST128_MAX - printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); - printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); - printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); +#ifdef INT_FAST128_MAX + printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); + printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); + printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); #endif -#ifdef INTPTR_MAX - printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); - printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); +#ifdef INTPTR_MAX + printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); + printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); #endif -#ifdef UINTPTR_MAX - printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); +#ifdef UINTPTR_MAX + printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); #endif -#ifdef INTMAX_MAX - printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); - printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); - printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); +#ifdef INTMAX_MAX + printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); + printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); + printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); #endif -#ifdef PTRDIFF_MAX - printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); - printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); +#ifdef PTRDIFF_MAX + printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); + printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); #endif -#ifdef SIG_ATOMIC_MAX -#if SIG_ATOMIC_MIN < 0 - printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); +#ifdef SIG_ATOMIC_MAX +#if SIG_ATOMIC_MIN < 0 + printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); #else - printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); + printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); #endif #endif -#ifdef SIZE_MAX - printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); +#ifdef SIZE_MAX + printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); #endif -#ifdef WCHAR_MAX -#if WCHAR_MIN < 0 - printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); +#ifdef WCHAR_MAX +#if WCHAR_MIN < 0 + printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); #else - printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); + printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); #endif #endif -#ifdef WINT_MAX -#if WINT_MIN < 0 - printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); +#ifdef WINT_MAX +#if WINT_MIN < 0 + printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); #else - printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); + printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); #endif #endif - /* - 7.18.4 Macros for integer constants - */ + /* + 7.18.4 Macros for integer constants + */ - /* INTn_C for n=8 and 16 were at one point unimplementable - on most platforms, so they're treated as "optional": */ -#ifdef INT8_C - if ( INT8_C(-123) != -123 ) - printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT8_C(-123) - ); - if ( UINT8_C(123) != 123 ) - printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT8_C(123) - ); + /* INTn_C for n=8 and 16 were at one point unimplementable + on most platforms, so they're treated as "optional": */ +#ifdef INT8_C + if ( INT8_C(-123) != -123 ) + printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT8_C(-123) + ); + if ( UINT8_C(123) != 123 ) + printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT8_C(123) + ); #endif -#ifdef INT16_C - if ( INT16_C(-12345) != -12345 ) - printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT16_C(-12345) - ); - if ( UINT16_C(12345) != 12345 ) - printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT16_C(12345) - ); +#ifdef INT16_C + if ( INT16_C(-12345) != -12345 ) + printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT16_C(-12345) + ); + if ( UINT16_C(12345) != 12345 ) + printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT16_C(12345) + ); #endif - if ( INT32_C(-123456789) != -123456789 ) - printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT32_C(-123456789) - ); - if ( UINT32_C(123456789) != 123456789 ) - printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT32_C(123456789) - ); -#ifdef INT_LEAST64_MAX - if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INT64_C(-1234567890123456789) - ); - if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINT64_C(1234567890123456789) - ); + if ( INT32_C(-123456789) != -123456789 ) + printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT32_C(-123456789) + ); + if ( UINT32_C(123456789) != 123456789 ) + printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT32_C(123456789) + ); +#ifdef INT_LEAST64_MAX + if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INT64_C(-1234567890123456789) + ); + if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINT64_C(1234567890123456789) + ); #endif -#ifdef INTMAX_MAX - if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INTMAX_C(-1234567890123456789) - ); - if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINTMAX_C(1234567890123456789) - ); +#ifdef INTMAX_MAX + if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INTMAX_C(-1234567890123456789) + ); + if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINTMAX_C(1234567890123456789) + ); #endif - /* features: */ + /* features: */ -#if __STDC_VERSION__ >= 199901 - printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); +#if __STDC_VERSION__ >= 199901 + printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); #endif - /* - 7.8.1 Macros for format specifiers - */ + /* + 7.8.1 Macros for format specifiers + */ - { - /* scanf these strings */ - static const char in_dn[] = "Z119bZ"; - static const char in_dmo[] = "Z-0119bZ"; - static const char in_dspx[] = "Z \t\n +0X119bZ"; - static const char in_dsmx[] = "Z \t\n -0x119bZ"; - static const char in_dsn[] = "Z \t\n 119bZ"; - static const char in_dp[] = "Z+119bZ"; - static const char in_dpx[] = "Z+0X119bz"; + { + /* scanf these strings */ + static const char in_dn[] = "Z119bZ"; + static const char in_dmo[] = "Z-0119bZ"; + static const char in_dspx[] = "Z \t\n +0X119bZ"; + static const char in_dsmx[] = "Z \t\n -0x119bZ"; + static const char in_dsn[] = "Z \t\n 119bZ"; + static const char in_dp[] = "Z+119bZ"; + static const char in_dpx[] = "Z+0X119bz"; - /* sprintf into this */ - static char buffer[1024]; + /* sprintf into this */ + static char buffer[1024]; #if 1 -#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( var != (exp) ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %" fs " ***\n", var \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ +#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( var != (exp) ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %" fs " ***\n", var \ + ); \ + status = EXIT_FAILURE; \ + } \ + else /* for trailing semicolon */ -#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ - { \ - printf("***%s=",fs, STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %s ***\n", buffer \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ +#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ + { \ + printf("***%s=",fs, STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %s ***\n", buffer \ + ); \ + status = EXIT_FAILURE; \ + } \ + else /* for trailing semicolon */ #else - -#define SCAN(buf,fs,var,exp) -#define PRINT(fs,var,exp) + +#define SCAN(buf,fs,var,exp) +#define PRINT(fs,var,exp) #endif - -#ifdef SCNo32 + +#ifdef SCNo32 - SCAN(in_dn, SCNo32, int32, 9); + SCAN(in_dn, SCNo32, int32, 9); #endif -#ifdef PRIo32 - PRINT(PRIo32, int32, 11); +#ifdef PRIo32 + PRINT(PRIo32, int32, 11); #endif - SCAN(in_dmo, SCNiLEAST16, intl16, -9); - SCAN(in_dspx, SCNdLEAST16, intl16, 0); - SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); - PRINT(PRIdLEAST16, intl16, -4507); - PRINT(PRIiLEAST16, intl16, -4507); - SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); - PRINT(PRIoLEAST16, uintl16, 10633); - PRINT(PRIuLEAST16, uintl16, 4507); - PRINT(PRIxLEAST16, uintl16, 119b); - PRINT(PRIXLEAST16, uintl16, 119B); - SCAN(in_dp, SCNxFAST16, uintf16, 4507); - PRINT(PRIxFAST16, uintf16, 119b); -#ifdef SCNdMAX - SCAN(in_dp, SCNdMAX, intmax, 119); + SCAN(in_dmo, SCNiLEAST16, intl16, -9); + SCAN(in_dspx, SCNdLEAST16, intl16, 0); + SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); + PRINT(PRIdLEAST16, intl16, -4507); + PRINT(PRIiLEAST16, intl16, -4507); + SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); + PRINT(PRIoLEAST16, uintl16, 10633); + PRINT(PRIuLEAST16, uintl16, 4507); + PRINT(PRIxLEAST16, uintl16, 119b); + PRINT(PRIXLEAST16, uintl16, 119B); + SCAN(in_dp, SCNxFAST16, uintf16, 4507); + PRINT(PRIxFAST16, uintf16, 119b); +#ifdef SCNdMAX + SCAN(in_dp, SCNdMAX, intmax, 119); #endif -#ifdef PRIiMAX - PRINT(PRIiMAX, intmax, 119); +#ifdef PRIiMAX + PRINT(PRIiMAX, intmax, 119); #endif -#ifdef SCNoMAX - SCAN(in_dpx, SCNoMAX, uintmax, 0); +#ifdef SCNoMAX + SCAN(in_dpx, SCNoMAX, uintmax, 0); #endif -#ifdef PRIxMAX - PRINT(PRIxMAX, uintmax, 0); +#ifdef PRIxMAX + PRINT(PRIxMAX, uintmax, 0); #endif - /* Obviously there should be a much larger battery of such tests. */ - } + /* Obviously there should be a much larger battery of such tests. */ + } -#if defined(INTMAX_MAX) /* has C99 features */ - /* - 7.8.2 Functions for greatest-width integer types - */ +#if defined(INTMAX_MAX) /* has C99 features */ + /* + 7.8.2 Functions for greatest-width integer types + */ - { - static struct - { - intmax_t input; - intmax_t expect; - } abs_data[] = - { -#ifdef INT8_MAX - { INT8_MAX, INT8_MAX, }, - { -INT8_MAX, INT8_MAX, }, - { UINT8_MAX, UINT8_MAX, }, + { + static struct + { + intmax_t input; + intmax_t expect; + } abs_data[] = + { +#ifdef INT8_MAX + { INT8_MAX, INT8_MAX, }, + { -INT8_MAX, INT8_MAX, }, + { UINT8_MAX, UINT8_MAX, }, #endif #if 0 -#ifdef INT16_MAX - { INT16_MAX, INT16_MAX, }, - { -INT16_MAX, INT16_MAX, }, - { UINT16_MAX, UINT16_MAX, }, +#ifdef INT16_MAX + { INT16_MAX, INT16_MAX, }, + { -INT16_MAX, INT16_MAX, }, + { UINT16_MAX, UINT16_MAX, }, #endif -#ifdef INT32_MAX - { INT32_MAX, INT32_MAX, }, - { -INT32_MAX, INT32_MAX, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { UINT32_MAX, UINT32_MAX, }, +#ifdef INT32_MAX + { INT32_MAX, INT32_MAX, }, + { -INT32_MAX, INT32_MAX, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { UINT32_MAX, UINT32_MAX, }, #endif #endif -#ifdef INT64_MAX - { INT64_MAX, INT64_MAX, }, - { -INT64_MAX, INT64_MAX, }, +#ifdef INT64_MAX + { INT64_MAX, INT64_MAX, }, + { -INT64_MAX, INT64_MAX, }, #endif - { INT_LEAST8_MAX, INT_LEAST8_MAX, }, - { -INT_LEAST8_MAX, INT_LEAST8_MAX, }, - { UINT_LEAST8_MAX, UINT_LEAST8_MAX, }, - { INT_LEAST16_MAX, INT_LEAST16_MAX, }, - { -INT_LEAST16_MAX, INT_LEAST16_MAX, }, - { UINT_LEAST16_MAX, UINT_LEAST16_MAX, }, - { INT_LEAST32_MAX, INT_LEAST32_MAX, }, - { -INT_LEAST32_MAX, INT_LEAST32_MAX, }, -#ifdef INT_LEAST64_MAX - { UINT_LEAST32_MAX, UINT_LEAST32_MAX, }, - { INT_LEAST64_MAX, INT_LEAST64_MAX, }, - { -INT_LEAST64_MAX, INT_LEAST64_MAX, }, + { INT_LEAST8_MAX, INT_LEAST8_MAX, }, + { -INT_LEAST8_MAX, INT_LEAST8_MAX, }, + { UINT_LEAST8_MAX, UINT_LEAST8_MAX, }, + { INT_LEAST16_MAX, INT_LEAST16_MAX, }, + { -INT_LEAST16_MAX, INT_LEAST16_MAX, }, + { UINT_LEAST16_MAX, UINT_LEAST16_MAX, }, + { INT_LEAST32_MAX, INT_LEAST32_MAX, }, + { -INT_LEAST32_MAX, INT_LEAST32_MAX, }, +#ifdef INT_LEAST64_MAX + { UINT_LEAST32_MAX, UINT_LEAST32_MAX, }, + { INT_LEAST64_MAX, INT_LEAST64_MAX, }, + { -INT_LEAST64_MAX, INT_LEAST64_MAX, }, #endif - { INT_FAST8_MAX, INT_FAST8_MAX, }, - { -INT_FAST8_MAX, INT_FAST8_MAX, }, - { UINT_FAST8_MAX, UINT_FAST8_MAX, }, - { INT_FAST16_MAX, INT_FAST16_MAX, }, - { -INT_FAST16_MAX, INT_FAST16_MAX, }, - { UINT_FAST16_MAX, UINT_FAST16_MAX, }, - { INT_FAST32_MAX, INT_FAST32_MAX, }, - { -INT_FAST32_MAX, INT_FAST32_MAX, }, -#ifdef INT_FAST64_MAX - { UINT_FAST32_MAX, UINT_FAST32_MAX, }, - { INT_FAST64_MAX, INT_FAST64_MAX, }, - { -INT_FAST64_MAX, INT_FAST64_MAX, }, + { INT_FAST8_MAX, INT_FAST8_MAX, }, + { -INT_FAST8_MAX, INT_FAST8_MAX, }, + { UINT_FAST8_MAX, UINT_FAST8_MAX, }, + { INT_FAST16_MAX, INT_FAST16_MAX, }, + { -INT_FAST16_MAX, INT_FAST16_MAX, }, + { UINT_FAST16_MAX, UINT_FAST16_MAX, }, + { INT_FAST32_MAX, INT_FAST32_MAX, }, + { -INT_FAST32_MAX, INT_FAST32_MAX, }, +#ifdef INT_FAST64_MAX + { UINT_FAST32_MAX, UINT_FAST32_MAX, }, + { INT_FAST64_MAX, INT_FAST64_MAX, }, + { -INT_FAST64_MAX, INT_FAST64_MAX, }, #endif -#ifdef INTPTR_MAX - { INTPTR_MAX, INTPTR_MAX, }, - { -INTPTR_MAX, INTPTR_MAX, }, +#ifdef INTPTR_MAX + { INTPTR_MAX, INTPTR_MAX, }, + { -INTPTR_MAX, INTPTR_MAX, }, #endif -#ifdef UINTPTR_MAX - { UINTPTR_MAX, UINTPTR_MAX, }, +#ifdef UINTPTR_MAX + { UINTPTR_MAX, UINTPTR_MAX, }, #endif - { INTMAX_MAX, INTMAX_MAX, }, -#ifdef PTRDIFF_MAX - { PTRDIFF_MAX, PTRDIFF_MAX, }, + { INTMAX_MAX, INTMAX_MAX, }, +#ifdef PTRDIFF_MAX + { PTRDIFF_MAX, PTRDIFF_MAX, }, #endif -#ifdef SIG_ATOMIC_MAX - { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, -#if SIG_ATOMIC_MIN < 0 - { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, +#ifdef SIG_ATOMIC_MAX + { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, +#if SIG_ATOMIC_MIN < 0 + { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, }, #endif #endif -#ifdef SIZE_MAX - { SIZE_MAX, SIZE_MAX, }, +#ifdef SIZE_MAX + { SIZE_MAX, SIZE_MAX, }, #endif -#ifdef WCHAR_MAX - { WCHAR_MAX, WCHAR_MAX, }, -#if WCHAR_MIN < 0 - { -WCHAR_MAX, WCHAR_MAX, }, +#ifdef WCHAR_MAX + { WCHAR_MAX, WCHAR_MAX, }, +#if WCHAR_MIN < 0 + { -WCHAR_MAX, WCHAR_MAX, }, #endif #endif -#ifdef WINT_MAX - { WINT_MAX, WINT_MAX, }, -#if WINT_MIN < 0 - { -WINT_MAX, WINT_MAX, }, +#ifdef WINT_MAX + { WINT_MAX, WINT_MAX, }, +#if WINT_MIN < 0 + { -WINT_MAX, WINT_MAX, }, #endif #endif - { 127, 127, }, - { -127, 127, }, - { 128, 128, }, - { -127-1, 128, }, - { 255, 255, }, - { -256+1, 255, }, - { 256, 256, }, - { -256, 256, }, - { 32767, 32767, }, - { -32767, 32767, }, - { 32768, 32768, }, - { -32767-1, 32768, }, - { 65535, 65535, }, - { -65536+1, 65535, }, - { 65536, 65536, }, - { -65536, 65536, }, - { 2147483647, 2147483647, }, - { -2147483647, 2147483647, }, - { 2147483648, 2147483648, }, - { -2147483647-1, 2147483648, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { 4294967295, 4294967295, }, - { -4294967296+1, 4294967295, }, - { 4294967296, 4294967296, }, - { -4294967296, 4294967296, }, - { 9223372036854775807, 9223372036854775807, }, - { -9223372036854775807, 9223372036854775807, }, - { 1234567890123456789, 1234567890123456789, }, - { -1234567890123456789, 1234567890123456789, }, + { 127, 127, }, + { -127, 127, }, + { 128, 128, }, + { -127-1, 128, }, + { 255, 255, }, + { -256+1, 255, }, + { 256, 256, }, + { -256, 256, }, + { 32767, 32767, }, + { -32767, 32767, }, + { 32768, 32768, }, + { -32767-1, 32768, }, + { 65535, 65535, }, + { -65536+1, 65535, }, + { 65536, 65536, }, + { -65536, 65536, }, + { 2147483647, 2147483647, }, + { -2147483647, 2147483647, }, + { 2147483648, 2147483648, }, + { -2147483647-1, 2147483648, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { 4294967295, 4294967295, }, + { -4294967296+1, 4294967295, }, + { 4294967296, 4294967296, }, + { -4294967296, 4294967296, }, + { 9223372036854775807, 9223372036854775807, }, + { -9223372036854775807, 9223372036854775807, }, + { 1234567890123456789, 1234567890123456789, }, + { -1234567890123456789, 1234567890123456789, }, #endif - { 1, 1, }, - { -1, 1, }, - { 2, 2, }, - { -2, 2, }, - { 10, 10, }, - { -10, 10, }, - { 16, 16, }, - { -16, 16, }, + { 1, 1, }, + { -1, 1, }, + { 2, 2, }, + { -2, 2, }, + { 10, 10, }, + { -10, 10, }, + { 16, 16, }, + { -16, 16, }, #endif - /* Other test cases can be added here. */ - { 0, 0 /* terminates the list */ }, - }, *adp = abs_data; + /* Other test cases can be added here. */ + { 0, 0 /* terminates the list */ }, + }, *adp = abs_data; - do { - if ( (intmax = imaxabs(adp->input)) != adp->expect ) - { - printf("*** imaxabs(%"PRIdMAX") failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", - adp->input, adp->expect, intmax - ); - status = EXIT_FAILURE; - } -// } while ( adp++->input != 0 ); - } while ( (adp++)->input != 0 ); - } + do { + if ( (intmax = imaxabs(adp->input)) != adp->expect ) + { + printf("*** imaxabs(%"PRIdMAX") failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", + adp->input, adp->expect, intmax + ); + status = EXIT_FAILURE; + } +// } while ( adp++->input != 0 ); + } while ( (adp++)->input != 0 ); + } - { - imaxdiv_t result; - static struct - { - intmax_t numer; - intmax_t denom; - intmax_t exp_quot; - intmax_t exp_rem; - } div_data[] = - { - { 0, 1, 0, 0, }, + { + imaxdiv_t result; + static struct + { + intmax_t numer; + intmax_t denom; + intmax_t exp_quot; + intmax_t exp_rem; + } div_data[] = + { + { 0, 1, 0, 0, }, #if 0 - { 0, -1, 0, 0, }, - { 0, 2, 0, 0, }, - { 0, -2, 0, 0, }, - { 0, 5, 0, 0, }, - { 0, -5, 0, 0, }, - { 1, 1, 1, 0, }, - { 1, -1, -1, 0, }, - { 1, 2, 0, 1, }, - { 1, -2, 0, 1, }, - { 1, 5, 0, 1, }, - { 1, -5, 0, 1, }, - { -1, 1, -1, 0, }, - { -1, -1, 1, 0, }, - { -1, 2, 0, -1, }, - { -1, -2, 0, -1, }, - { -1, 5, 0, -1, }, - { -1, -5, 0, -1, }, - { 2, 1, 2, 0, }, - { 2, -1, -2, 0, }, - { 2, 2, 1, 0, }, - { 2, -2, -1, 0, }, - { 2, 5, 0, 2, }, - { 2, -5, 0, 2, }, - { -2, 1, -2, 0, }, - { -2, -1, 2, 0, }, - { -2, 2, -1, 0, }, - { -2, -2, 1, 0, }, - { -2, 5, 0, -2, }, - { -2, -5, 0, -2, }, - { 17, 5, 3, 2, }, - { -17, -5, 3, -2, }, - { 17, -5, -3, 2, }, - { -17, 5, -3, -2, }, - { 2147483647, 1, 2147483647, 0, }, - { -2147483647, 1, -2147483647, 0, }, - { 2147483648, 1, 2147483648, 0, }, - { -2147483647-1, 1, -2147483647-1, 0, }, - { 2147483647, 2, 1073741823, 1, }, - { -2147483647, 2, -1073741823, -1, }, - { 2147483648, 2, 1073741824, 0, }, - { -2147483647-1, 2, -1073741824, 0, }, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - { 4294967295, 1, 4294967295, 0, }, - { -4294967296+1, 1, -4294967296+1, 0, }, - { 4294967296, 1, 4294967296, 0, }, - { -4294967296, 1, -4294967296, 0, }, - { 4294967295, -1, -4294967296+1, 0, }, - { -4294967296+1, -1, 4294967295, 0, }, - { 4294967296, -1, -4294967296, 0, }, - { -4294967296, -1, 4294967296, 0, }, - { 4294967295, 2, 2147483647, 1, }, - { -4294967296+1, 2, -2147483647, -1, }, - { 4294967296, 2, 2147483648, 0, }, - { -4294967296, 2, -2147483647-1, 0, }, - { 4294967295, 2147483647, 2, 1, }, - { -4294967296+1, 2147483647, -2, -1, }, - { 4294967296, 2147483647, 2, 2, }, - { -4294967296, 2147483647, -2, -2, }, - { 4294967295, -2147483647, -2, 1, }, - { -4294967296+1, -2147483647, 2, -1, }, - { 4294967296, -2147483647, -2, 2, }, - { -4294967296, -2147483647, 2, -2, }, - { 4294967295, 2147483648, 1, 2147483647, }, - { -4294967296+1, 2147483648, -1, -2147483647, }, - { 4294967296, 2147483648, 2, 0, }, - { -4294967296, 2147483648, -2, 0, }, - { 4294967295, -2147483647-1, -1, 2147483647, }, - { -4294967296+1, -2147483647-1, 1, -2147483647,}, - { 4294967296, -2147483647-1, -2, 0, }, - { -4294967296, -2147483647-1, 2, 0, }, - { 9223372036854775807, 1, 9223372036854775807, 0, }, - { -9223372036854775807, 1, -9223372036854775807, 0, }, - { 9223372036854775807, 2, 4611686018427387903, 1, }, - { -9223372036854775807, 2, -4611686018427387903, -1, }, + { 0, -1, 0, 0, }, + { 0, 2, 0, 0, }, + { 0, -2, 0, 0, }, + { 0, 5, 0, 0, }, + { 0, -5, 0, 0, }, + { 1, 1, 1, 0, }, + { 1, -1, -1, 0, }, + { 1, 2, 0, 1, }, + { 1, -2, 0, 1, }, + { 1, 5, 0, 1, }, + { 1, -5, 0, 1, }, + { -1, 1, -1, 0, }, + { -1, -1, 1, 0, }, + { -1, 2, 0, -1, }, + { -1, -2, 0, -1, }, + { -1, 5, 0, -1, }, + { -1, -5, 0, -1, }, + { 2, 1, 2, 0, }, + { 2, -1, -2, 0, }, + { 2, 2, 1, 0, }, + { 2, -2, -1, 0, }, + { 2, 5, 0, 2, }, + { 2, -5, 0, 2, }, + { -2, 1, -2, 0, }, + { -2, -1, 2, 0, }, + { -2, 2, -1, 0, }, + { -2, -2, 1, 0, }, + { -2, 5, 0, -2, }, + { -2, -5, 0, -2, }, + { 17, 5, 3, 2, }, + { -17, -5, 3, -2, }, + { 17, -5, -3, 2, }, + { -17, 5, -3, -2, }, + { 2147483647, 1, 2147483647, 0, }, + { -2147483647, 1, -2147483647, 0, }, + { 2147483648, 1, 2147483648, 0, }, + { -2147483647-1, 1, -2147483647-1, 0, }, + { 2147483647, 2, 1073741823, 1, }, + { -2147483647, 2, -1073741823, -1, }, + { 2147483648, 2, 1073741824, 0, }, + { -2147483647-1, 2, -1073741824, 0, }, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { 4294967295, 1, 4294967295, 0, }, + { -4294967296+1, 1, -4294967296+1, 0, }, + { 4294967296, 1, 4294967296, 0, }, + { -4294967296, 1, -4294967296, 0, }, + { 4294967295, -1, -4294967296+1, 0, }, + { -4294967296+1, -1, 4294967295, 0, }, + { 4294967296, -1, -4294967296, 0, }, + { -4294967296, -1, 4294967296, 0, }, + { 4294967295, 2, 2147483647, 1, }, + { -4294967296+1, 2, -2147483647, -1, }, + { 4294967296, 2, 2147483648, 0, }, + { -4294967296, 2, -2147483647-1, 0, }, + { 4294967295, 2147483647, 2, 1, }, + { -4294967296+1, 2147483647, -2, -1, }, + { 4294967296, 2147483647, 2, 2, }, + { -4294967296, 2147483647, -2, -2, }, + { 4294967295, -2147483647, -2, 1, }, + { -4294967296+1, -2147483647, 2, -1, }, + { 4294967296, -2147483647, -2, 2, }, + { -4294967296, -2147483647, 2, -2, }, + { 4294967295, 2147483648, 1, 2147483647, }, + { -4294967296+1, 2147483648, -1, -2147483647, }, + { 4294967296, 2147483648, 2, 0, }, + { -4294967296, 2147483648, -2, 0, }, + { 4294967295, -2147483647-1, -1, 2147483647, }, + { -4294967296+1, -2147483647-1, 1, -2147483647,}, + { 4294967296, -2147483647-1, -2, 0, }, + { -4294967296, -2147483647-1, 2, 0, }, + { 9223372036854775807, 1, 9223372036854775807, 0, }, + { -9223372036854775807, 1, -9223372036854775807, 0, }, + { 9223372036854775807, 2, 4611686018427387903, 1, }, + { -9223372036854775807, 2, -4611686018427387903, -1, }, #endif #endif - /* There should be a much larger battery of such tests. */ - { 0, 0, 0, 0 }, /* 0 denom terminates the list */ - }, *ddp; + /* There should be a much larger battery of such tests. */ + { 0, 0, 0, 0 }, /* 0 denom terminates the list */ + }, *ddp; #if 0 - for ( ddp = div_data; ddp->denom != 0; ++ddp ) - if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot - != ddp->exp_quot || result.rem != ddp->exp_rem - ) { -// printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX -// ") failed; should be: (%"PRIdMAX",%"PRIdMAX -// "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", -// ddp->numer, ddp->denom, ddp->exp_quot, -// ddp->exp_rem, result.quot, result.rem -// ); - printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX - ") = (%"PRIdMAX",%"PRIdMAX - "), is: (%"PRIdMAX",%"PRIdMAX")\n", - ddp->numer, ddp->denom, ddp->exp_quot, - ddp->exp_rem, result.quot, result.rem - ); - status = EXIT_FAILURE; - } + for ( ddp = div_data; ddp->denom != 0; ++ddp ) + if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot + != ddp->exp_quot || result.rem != ddp->exp_rem + ) { +// printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX +// ") failed; should be: (%"PRIdMAX",%"PRIdMAX +// "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", +// ddp->numer, ddp->denom, ddp->exp_quot, +// ddp->exp_rem, result.quot, result.rem +// ); + printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX + ") = (%"PRIdMAX",%"PRIdMAX + "), is: (%"PRIdMAX",%"PRIdMAX")\n", + ddp->numer, ddp->denom, ddp->exp_quot, + ddp->exp_rem, result.quot, result.rem + ); + status = EXIT_FAILURE; + } #endif - } - - { - char *endptr; - wchar_t *wendptr; - static char saved[64]; /* holds copy of input string */ - static wchar_t wnptr[64]; /* holds wide copy of test string */ - static int warned; /* "warned for null endptr" flag */ - register int i; - static struct - { - char * nptr; - int base; - intmax_t exp_val; - int exp_len; - } str_data[] = - { - { "", 0, 0, 0, }, - { "", 2, 0, 0, }, - { "", 8, 0, 0, }, - { "", 9, 0, 0, }, - { "", 10, 0, 0, }, - { "", 16, 0, 0, }, - { "", 36, 0, 0, }, - { "0", 0, 0, 1, }, - { "0", 2, 0, 1, }, - { "0", 8, 0, 1, }, - { "0", 9, 0, 1, }, - { "0", 10, 0, 1, }, - { "0", 16, 0, 1, }, - { "0", 36, 0, 1, }, - { "+0", 0, 0, 2, }, - { "+0", 2, 0, 2, }, - { "+0", 8, 0, 2, }, - { "+0", 9, 0, 2, }, - { "+0", 10, 0, 2, }, - { "+0", 16, 0, 2, }, - { "+0", 36, 0, 2, }, - { "-0", 0, 0, 2, }, - { "-0", 2, 0, 2, }, - { "-0", 8, 0, 2, }, - { "-0", 9, 0, 2, }, - { "-0", 10, 0, 2, }, - { "-0", 16, 0, 2, }, - { "-0", 36, 0, 2, }, - { "Inf", 0, 0, 0, }, - { "Inf", 2, 0, 0, }, - { "Inf", 8, 0, 0, }, - { "Inf", 9, 0, 0, }, - { "Inf", 10, 0, 0, }, - { "Inf", 16, 0, 0, }, - { "Inf", 36, 24171, 3, }, - { "+Inf", 0, 0, 0, }, - { "+Inf", 2, 0, 0, }, - { "+Inf", 8, 0, 0, }, - { "+Inf", 9, 0, 0, }, - { "+Inf", 10, 0, 0, }, - { "+Inf", 16, 0, 0, }, - { "+Inf", 36, 24171, 4, }, - { "-Inf", 0, 0, 0, }, - { "-Inf", 2, 0, 0, }, - { "-Inf", 8, 0, 0, }, - { "-Inf", 9, 0, 0, }, - { "-Inf", 10, 0, 0, }, - { "-Inf", 16, 0, 0, }, - { "-Inf", 36, -24171, 4, }, - { "inf", 0, 0, 0, }, - { "inf", 2, 0, 0, }, - { "inf", 8, 0, 0, }, - { "inf", 9, 0, 0, }, - { "inf", 10, 0, 0, }, - { "inf", 16, 0, 0, }, - { "inf", 36, 24171, 3, }, - { "+inf", 0, 0, 0, }, - { "+inf", 2, 0, 0, }, - { "+inf", 8, 0, 0, }, - { "+inf", 9, 0, 0, }, - { "+inf", 10, 0, 0, }, - { "+inf", 16, 0, 0, }, - { "+inf", 36, 24171, 4, }, - { "-inf", 0, 0, 0, }, - { "-inf", 2, 0, 0, }, - { "-inf", 8, 0, 0, }, - { "-inf", 9, 0, 0, }, - { "-inf", 10, 0, 0, }, - { "-inf", 16, 0, 0, }, - { "-inf", 36, -24171, 4, }, - { "119b8Z", 0, 119, 3, }, - { "119bZ", 0, 119, 3, }, - { "-0119bZ", 0, -9, 4, }, - { " \t\n 0X119bZ", 0, 4507, 10, }, - { " \t\n +0X119bZ", 0, 4507, 11, }, - { " \t\n -0x119bZ", 0, -4507, 11, }, - { " \t\n 119bZ", 0, 119, 7, }, - { "+119bZ", 0, 119, 4, }, - { "+0X119bz", 0, 4507, 7, }, - { "119b8Z", 2, 3, 2, }, - { "119bZ", 2, 3, 2, }, - { "-0119bZ", 2, -3, 4, }, - { " \t\n 0X119bZ", 2, 0, 5, }, - { " \t\n +0X119bZ", 2, 0, 6, }, - { " \t\n -0x119bZ", 2, 0, 6, }, - { " \t\n 119bZ", 2, 3, 6, }, - { "+119bZ", 2, 3, 3, }, - { "+0X119bz", 2, 0, 2, }, - { "119b8Z", 8, 9, 2, }, - { "119bZ", 8, 9, 2, }, - { "-0119bZ", 8, -9, 4, }, - { " \t\n 0X119bZ", 8, 0, 5, }, - { " \t\n +0X119bZ", 8, 0, 6, }, - { " \t\n -0x119bZ", 8, 0, 6, }, - { " \t\n 119bZ", 8, 9, 6, }, - { "+119bZ", 8, 9, 3, }, - { "+0X119bz", 8, 0, 2, }, - { "119b8Z", 9, 10, 2, }, - { "119bZ", 9, 10, 2, }, - { "-0119bZ", 9, -10, 4, }, - { " \t\n 0X119bZ", 9, 0, 5, }, - { " \t\n +0X119bZ", 9, 0, 6, }, - { " \t\n -0x119bZ", 9, 0, 6, }, - { " \t\n 119bZ", 9, 10, 6, }, - { "+119bZ", 9, 10, 3, }, - { "+0X119bz", 9, 0, 2, }, - { "119b8Z", 10, 119, 3, }, - { "119bZ", 10, 119, 3, }, - { "-0119bZ", 10, -119, 5, }, - { " \t\n 0X119bZ", 10, 0, 5, }, - { " \t\n +0X119bZ", 10, 0, 6, }, - { " \t\n -0x119bZ", 10, 0, 6, }, - { " \t\n 119bZ", 10, 119, 7, }, - { "+119bZ", 10, 119, 4, }, - { "+0X119bz", 10, 0, 2, }, - { "119b8Z", 16, 72120, 5, }, - { "119bZ", 16, 4507, 4, }, - { "-0119bZ", 16, -4507, 6, }, - { " \t\n 0X119bZ", 16, 4507, 10, }, - { " \t\n +0X119bZ", 16, 4507, 11, }, - { " \t\n -0x119bZ", 16, -4507, 11, }, - { " \t\n 119bZ", 16, 4507,8, }, - { "+119bZ", 16, 4507, 5, }, - { "+0X119bz", 16, 4507, 7, }, - { "119b8Z", 36, 62580275, 6, }, - { "119bZ", 36, 1738367, 5, }, - { "-0119bZ", 36, -1738367, 7, }, - { " \t\n 0X119bZ", 36, 1997122175, 11, }, - { " \t\n +0X119bZ", 36, 1997122175, 12, }, - { " \t\n -0x119bZ", 36, -1997122175, 12, }, - { " \t\n 119bZ", 36, 1738367, 9, }, - { "+119bZ", 36, 1738367, 6, }, - { "+0X119bz", 36, 1997122175, 8, }, - /* There should be a much larger battery of such tests. */ - { "127", 0, 127, 3, }, - { "-127", 0, -127, 4, }, - { "128", 0, 128, 3, }, - { "-128", 0, -127-1, 4, }, - { "255", 0, 255, 3, }, - { "-255", 0, -255, 4, }, - { "256", 0, 256, 3, }, - { "-256", 0, -255-1, 4, }, - { "32767", 0, 32767, 5, }, - { "-32767", 0, -32767, 6, }, - { "32768", 0, 32768, 5, }, - { "-32768", 0, -32767-1, 6, }, - { "65535", 0, 65535, 5, }, - { "-65535", 0, -65536+1, 6, }, - { "65536", 0, 65536, 5, }, - { "-65536", 0, -65536, 6, }, - { "2147483647", 0, 2147483647, 10, }, - { "-2147483647", 0, -2147483647, 11, }, - { "2147483648", 0, 2147483648, 10, }, - { "-2147483648", 0, -2147483647-1, 11, }, - { "4294967295", 0, 4294967295, 10, }, - { "-4294967295", 0, -4294967296+1, 11, }, - { "4294967296", 0, 4294967296, 10, }, - { "-4294967296", 0, -4294967296, 11, }, - { "9223372036854775807", 0, 9223372036854775807, 19, }, - { "-9223372036854775807", 0, -9223372036854775807, 20, }, - { "1234567890123456789", 0, 1234567890123456789, 19, }, - { "-1234567890123456789", 0, -1234567890123456789, 20, }, - { "1", 0, 1, 1, }, - { "-1", 0, -1, 2, }, - { "2", 0, 2, 1, }, - { "-2", 0, -2, 2, }, - { "10", 0, 10, 2, }, - { "-10", 0, -10, 3, }, - { "16", 0, 16, 2, }, - { "-16", 0, -16, 3, }, - /* Other test cases can be added here. */ - { NULL, 0, 0, 0 }, /* terminates the list */ - }, *sdp; - - for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) - { - /* - 7.8.2.3 The strtoimax and strtoumax functions - */ - - strcpy(saved, sdp->nptr); - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* tests for null endptr */ - -#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoimax(%s,NULL,%d) failed; " - "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", - sdp->nptr, sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions - */ - - for ( i = 0; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - - /* tests for null endptr */ - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - } - - /* - 7.8.2.3 The strtoimax and strtoumax functions (continued) - */ - - if ( (intmax = strtoimax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** strtoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions (continued) - */ + } + + { + char *endptr; + wchar_t *wendptr; + static char saved[64]; /* holds copy of input string */ + static wchar_t wnptr[64]; /* holds wide copy of test string */ + static int warned; /* "warned for null endptr" flag */ + register int i; + static struct + { + char * nptr; + int base; + intmax_t exp_val; + int exp_len; + } str_data[] = + { + { "", 0, 0, 0, }, + { "", 2, 0, 0, }, + { "", 8, 0, 0, }, + { "", 9, 0, 0, }, + { "", 10, 0, 0, }, + { "", 16, 0, 0, }, + { "", 36, 0, 0, }, + { "0", 0, 0, 1, }, + { "0", 2, 0, 1, }, + { "0", 8, 0, 1, }, + { "0", 9, 0, 1, }, + { "0", 10, 0, 1, }, + { "0", 16, 0, 1, }, + { "0", 36, 0, 1, }, + { "+0", 0, 0, 2, }, + { "+0", 2, 0, 2, }, + { "+0", 8, 0, 2, }, + { "+0", 9, 0, 2, }, + { "+0", 10, 0, 2, }, + { "+0", 16, 0, 2, }, + { "+0", 36, 0, 2, }, + { "-0", 0, 0, 2, }, + { "-0", 2, 0, 2, }, + { "-0", 8, 0, 2, }, + { "-0", 9, 0, 2, }, + { "-0", 10, 0, 2, }, + { "-0", 16, 0, 2, }, + { "-0", 36, 0, 2, }, + { "Inf", 0, 0, 0, }, + { "Inf", 2, 0, 0, }, + { "Inf", 8, 0, 0, }, + { "Inf", 9, 0, 0, }, + { "Inf", 10, 0, 0, }, + { "Inf", 16, 0, 0, }, + { "Inf", 36, 24171, 3, }, + { "+Inf", 0, 0, 0, }, + { "+Inf", 2, 0, 0, }, + { "+Inf", 8, 0, 0, }, + { "+Inf", 9, 0, 0, }, + { "+Inf", 10, 0, 0, }, + { "+Inf", 16, 0, 0, }, + { "+Inf", 36, 24171, 4, }, + { "-Inf", 0, 0, 0, }, + { "-Inf", 2, 0, 0, }, + { "-Inf", 8, 0, 0, }, + { "-Inf", 9, 0, 0, }, + { "-Inf", 10, 0, 0, }, + { "-Inf", 16, 0, 0, }, + { "-Inf", 36, -24171, 4, }, + { "inf", 0, 0, 0, }, + { "inf", 2, 0, 0, }, + { "inf", 8, 0, 0, }, + { "inf", 9, 0, 0, }, + { "inf", 10, 0, 0, }, + { "inf", 16, 0, 0, }, + { "inf", 36, 24171, 3, }, + { "+inf", 0, 0, 0, }, + { "+inf", 2, 0, 0, }, + { "+inf", 8, 0, 0, }, + { "+inf", 9, 0, 0, }, + { "+inf", 10, 0, 0, }, + { "+inf", 16, 0, 0, }, + { "+inf", 36, 24171, 4, }, + { "-inf", 0, 0, 0, }, + { "-inf", 2, 0, 0, }, + { "-inf", 8, 0, 0, }, + { "-inf", 9, 0, 0, }, + { "-inf", 10, 0, 0, }, + { "-inf", 16, 0, 0, }, + { "-inf", 36, -24171, 4, }, + { "119b8Z", 0, 119, 3, }, + { "119bZ", 0, 119, 3, }, + { "-0119bZ", 0, -9, 4, }, + { " \t\n 0X119bZ", 0, 4507, 10, }, + { " \t\n +0X119bZ", 0, 4507, 11, }, + { " \t\n -0x119bZ", 0, -4507, 11, }, + { " \t\n 119bZ", 0, 119, 7, }, + { "+119bZ", 0, 119, 4, }, + { "+0X119bz", 0, 4507, 7, }, + { "119b8Z", 2, 3, 2, }, + { "119bZ", 2, 3, 2, }, + { "-0119bZ", 2, -3, 4, }, + { " \t\n 0X119bZ", 2, 0, 5, }, + { " \t\n +0X119bZ", 2, 0, 6, }, + { " \t\n -0x119bZ", 2, 0, 6, }, + { " \t\n 119bZ", 2, 3, 6, }, + { "+119bZ", 2, 3, 3, }, + { "+0X119bz", 2, 0, 2, }, + { "119b8Z", 8, 9, 2, }, + { "119bZ", 8, 9, 2, }, + { "-0119bZ", 8, -9, 4, }, + { " \t\n 0X119bZ", 8, 0, 5, }, + { " \t\n +0X119bZ", 8, 0, 6, }, + { " \t\n -0x119bZ", 8, 0, 6, }, + { " \t\n 119bZ", 8, 9, 6, }, + { "+119bZ", 8, 9, 3, }, + { "+0X119bz", 8, 0, 2, }, + { "119b8Z", 9, 10, 2, }, + { "119bZ", 9, 10, 2, }, + { "-0119bZ", 9, -10, 4, }, + { " \t\n 0X119bZ", 9, 0, 5, }, + { " \t\n +0X119bZ", 9, 0, 6, }, + { " \t\n -0x119bZ", 9, 0, 6, }, + { " \t\n 119bZ", 9, 10, 6, }, + { "+119bZ", 9, 10, 3, }, + { "+0X119bz", 9, 0, 2, }, + { "119b8Z", 10, 119, 3, }, + { "119bZ", 10, 119, 3, }, + { "-0119bZ", 10, -119, 5, }, + { " \t\n 0X119bZ", 10, 0, 5, }, + { " \t\n +0X119bZ", 10, 0, 6, }, + { " \t\n -0x119bZ", 10, 0, 6, }, + { " \t\n 119bZ", 10, 119, 7, }, + { "+119bZ", 10, 119, 4, }, + { "+0X119bz", 10, 0, 2, }, + { "119b8Z", 16, 72120, 5, }, + { "119bZ", 16, 4507, 4, }, + { "-0119bZ", 16, -4507, 6, }, + { " \t\n 0X119bZ", 16, 4507, 10, }, + { " \t\n +0X119bZ", 16, 4507, 11, }, + { " \t\n -0x119bZ", 16, -4507, 11, }, + { " \t\n 119bZ", 16, 4507,8, }, + { "+119bZ", 16, 4507, 5, }, + { "+0X119bz", 16, 4507, 7, }, + { "119b8Z", 36, 62580275, 6, }, + { "119bZ", 36, 1738367, 5, }, + { "-0119bZ", 36, -1738367, 7, }, + { " \t\n 0X119bZ", 36, 1997122175, 11, }, + { " \t\n +0X119bZ", 36, 1997122175, 12, }, + { " \t\n -0x119bZ", 36, -1997122175, 12, }, + { " \t\n 119bZ", 36, 1738367, 9, }, + { "+119bZ", 36, 1738367, 6, }, + { "+0X119bz", 36, 1997122175, 8, }, + /* There should be a much larger battery of such tests. */ + { "127", 0, 127, 3, }, + { "-127", 0, -127, 4, }, + { "128", 0, 128, 3, }, + { "-128", 0, -127-1, 4, }, + { "255", 0, 255, 3, }, + { "-255", 0, -255, 4, }, + { "256", 0, 256, 3, }, + { "-256", 0, -255-1, 4, }, + { "32767", 0, 32767, 5, }, + { "-32767", 0, -32767, 6, }, + { "32768", 0, 32768, 5, }, + { "-32768", 0, -32767-1, 6, }, + { "65535", 0, 65535, 5, }, + { "-65535", 0, -65536+1, 6, }, + { "65536", 0, 65536, 5, }, + { "-65536", 0, -65536, 6, }, + { "2147483647", 0, 2147483647, 10, }, + { "-2147483647", 0, -2147483647, 11, }, + { "2147483648", 0, 2147483648, 10, }, + { "-2147483648", 0, -2147483647-1, 11, }, + { "4294967295", 0, 4294967295, 10, }, + { "-4294967295", 0, -4294967296+1, 11, }, + { "4294967296", 0, 4294967296, 10, }, + { "-4294967296", 0, -4294967296, 11, }, + { "9223372036854775807", 0, 9223372036854775807, 19, }, + { "-9223372036854775807", 0, -9223372036854775807, 20, }, + { "1234567890123456789", 0, 1234567890123456789, 19, }, + { "-1234567890123456789", 0, -1234567890123456789, 20, }, + { "1", 0, 1, 1, }, + { "-1", 0, -1, 2, }, + { "2", 0, 2, 1, }, + { "-2", 0, -2, 2, }, + { "10", 0, 10, 2, }, + { "-10", 0, -10, 3, }, + { "16", 0, 16, 2, }, + { "-16", 0, -16, 3, }, + /* Other test cases can be added here. */ + { NULL, 0, 0, 0 }, /* terminates the list */ + }, *sdp; + + for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) + { + /* + 7.8.2.3 The strtoimax and strtoumax functions + */ + + strcpy(saved, sdp->nptr); + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* tests for null endptr */ + +#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoimax(%s,NULL,%d) failed; " + "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", + sdp->nptr, sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions + */ + + for ( i = 0; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + + /* tests for null endptr */ + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + } + + /* + 7.8.2.3 The strtoimax and strtoumax functions (continued) + */ + + if ( (intmax = strtoimax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** strtoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions (continued) + */ #ifdef NO_INTERNAL_WCHAR - printf("NO_INTERNAL_WCHAR\n"); + printf("NO_INTERNAL_WCHAR\n"); #else - if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } - if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } - if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** wcstoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** wcstoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } - if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } - if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } - if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } + if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } #endif // NO_INTERNAL_WCHAR - } -#endif /* defined(INTMAX_MAX) */ + } +#endif /* defined(INTMAX_MAX) */ - if ( status != 0 ) - printf("sitest failed.\n"); + if ( status != 0 ) + printf("sitest failed.\n"); - return status; + return status; } #endif \ No newline at end of file diff --git a/test/ref/8q.c b/test/ref/8q.c index e8bd1ca2e..2055b5fd5 100644 --- a/test/ref/8q.c +++ b/test/ref/8q.c @@ -12,38 +12,38 @@ void print(void); int main(void) { - int i; - for (i = 0; i < 15; i++) - up[i] = down[i] = 1; - for (i = 0; i < 8; i++) - rows[i] = 1; - queens(0); - return 0; + int i; + for (i = 0; i < 15; i++) + up[i] = down[i] = 1; + for (i = 0; i < 8; i++) + rows[i] = 1; + queens(0); + return 0; } void queens(int c) { - int r; + int r; - for (r = 0; r < 8; r++) - if (rows[r] && up[r-c+7] && down[r+c]) { - rows[r] = up[r-c+7] = down[r+c] = 0; - x[c] = r; - if (c == 7) - print(); - else - queens(c + 1); - rows[r] = up[r-c+7] = down[r+c] = 1; - } + for (r = 0; r < 8; r++) + if (rows[r] && up[r-c+7] && down[r+c]) { + rows[r] = up[r-c+7] = down[r+c] = 0; + x[c] = r; + if (c == 7) + print(); + else + queens(c + 1); + rows[r] = up[r-c+7] = down[r+c] = 1; + } } void print(void) { - int k; + int k; - for (k = 0; k < 8; k++) { - printf("%c", x[k]+'1'); - if(k<7) printf(" "); - } - printf("\n"); + for (k = 0; k < 8; k++) { + printf("%c", x[k]+'1'); + if(k<7) printf(" "); + } + printf("\n"); } diff --git a/test/ref/array.c b/test/ref/array.c index 9d170aaa9..96bf22c3a 100644 --- a/test/ref/array.c +++ b/test/ref/array.c @@ -14,49 +14,49 @@ int g(int x[][4],int *y[]); int x[3][4], *y[3]; main() { - int z[3][4]; - int i, j, *p; + int z[3][4]; + int i, j, *p; - for (i = 0; i < 3; i++) { - for (j = 0; j < 4; j++) - x[i][j] = 1000*i + j; - y[i] = x[i]; - } - f(); - for (i = 0; i < 3; i++) { - y[i] = p = &z[i][0]; - for (j = 0; j < 4; j++) - p[j] = x[i][j]; - } - g(z, y); - - return 0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 4; j++) + x[i][j] = 1000*i + j; + y[i] = x[i]; + } + f(); + for (i = 0; i < 3; i++) { + y[i] = p = &z[i][0]; + for (j = 0; j < 4; j++) + p[j] = x[i][j]; + } + g(z, y); + + return 0; } f() { - int i, j; + int i, j; - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", x[i][j]); - printf("\n"); - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", y[i][j]); - printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", x[i][j]); + printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", y[i][j]); + printf("\n"); } g(x, y) int x[][4], *y[]; { - int i, j; + int i, j; - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", x[i][j]); - printf("\n"); - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - printf(" %d", y[i][j]); - printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", x[i][j]); + printf("\n"); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + printf(" %d", y[i][j]); + printf("\n"); } diff --git a/test/ref/cc65070303.c b/test/ref/cc65070303.c index c0404dab8..6dbceeefc 100644 --- a/test/ref/cc65070303.c +++ b/test/ref/cc65070303.c @@ -9,17 +9,17 @@ typedef signed int TypA[3]; typedef struct TypB { - TypA Data[2]; + TypA Data[2]; } sTypB; sTypB Bs[10]; TypA * APtr; int main(int argc, char* argv[]) { - Bs[7].Data[1][2]=11; - APtr=&(Bs[7].Data[1]); - printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] ); - return 0; + Bs[7].Data[1][2]=11; + APtr=&(Bs[7].Data[1]); + printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] ); + return 0; } /* diff --git a/test/ref/cc65090124.c b/test/ref/cc65090124.c index 3f8279b27..3a75b28fa 100644 --- a/test/ref/cc65090124.c +++ b/test/ref/cc65090124.c @@ -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 b260f0afd..609594dc4 100644 --- a/test/ref/cc65090726.c +++ b/test/ref/cc65090726.c @@ -17,26 +17,26 @@ typedef RecordType *RecordPtr; void Proc3(RecordPtr *PtrParOut) { - /* whatever */ + /* whatever */ } void Proc1(RecordPtr PtrParIn) { #define NextRecord (*(PtrParIn->PtrComp)) - Proc3((RecordPtr *)NextRecord.PtrComp); - Proc3(&NextRecord.PtrComp); - Proc3(&PtrParIn->PtrComp->PtrComp); + Proc3((RecordPtr *)NextRecord.PtrComp); + Proc3(&NextRecord.PtrComp); + Proc3(&PtrParIn->PtrComp->PtrComp); #ifdef CAST_STRUCT_PTR - Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp); - Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp); - Proc3((RecordPtr *) NextRecord.PtrComp); + Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp); + Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp); + Proc3((RecordPtr *) NextRecord.PtrComp); #else - Proc3(PtrParIn->PtrComp->PtrComp); - Proc3((*(PtrParIn->PtrComp)).PtrComp); - Proc3(NextRecord.PtrComp); + Proc3(PtrParIn->PtrComp->PtrComp); + Proc3((*(PtrParIn->PtrComp)).PtrComp); + Proc3(NextRecord.PtrComp); #endif - + #undef NextRecord } diff --git a/test/ref/cc65090910.c b/test/ref/cc65090910.c index 6ac5d9dcb..d68c2b8e6 100644 --- a/test/ref/cc65090910.c +++ b/test/ref/cc65090910.c @@ -17,7 +17,7 @@ with compiler option -O but does _not_ show up with -Oi. unsigned htons(unsigned val) { - return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8); + return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8); } int main(void) diff --git a/test/ref/cc65090913.c b/test/ref/cc65090913.c index da6e37ef3..3a92dc6ec 100644 --- a/test/ref/cc65090913.c +++ b/test/ref/cc65090913.c @@ -25,7 +25,7 @@ int foo=0,bar=2; int main(void) { while(foo /* -...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl. +...gives "test.c(2): Error: Variable 'foo' has unknown size" using -Cl. Is it really unknown? cc65 V2.13.0, SVN version: 4384 diff --git a/test/ref/cc65101102.c b/test/ref/cc65101102.c index 4faa7c12b..1f87f65b5 100644 --- a/test/ref/cc65101102.c +++ b/test/ref/cc65101102.c @@ -11,12 +11,12 @@ Compiler is build from cc65-snapshot-2.13.9.20101031 sources. Expected results and also what I get from this without any optimisations are: 48663 and 49218 -When I turn on ``-O``: 58096 and 58096. After swapping the two variable -declaration lines in `calculate_checksum()` the results are correct -with ``-O``. +When I turn on ''-O'': 58096 and 58096. After swapping the two variable +declaration lines in 'calculate_checksum()' the results are correct +with ''-O''. -But with ``--O --static-locals`` the results are incorrect again (31757 -and 15408). ``--static-locals`` alone works though. +But with ''--O --static-locals'' the results are incorrect again (31757 +and 15408). ''--static-locals'' alone works though. */ #include diff --git a/test/ref/cc65110210.c b/test/ref/cc65110210.c index 2c7853556..ca5b39203 100644 --- a/test/ref/cc65110210.c +++ b/test/ref/cc65110210.c @@ -8,15 +8,15 @@ with SVN version: 4973M $ cl65 -v -o test.prg tests/cc65110210.c -Opened include file `/usr/local/lib/cc65/include/stdio.h' -Opened include file `/usr/local/lib/cc65/include/stddef.h' -Opened include file `/usr/local/lib/cc65/include/stdarg.h' -Opened include file `/usr/local/lib/cc65/include/limits.h' +Opened include file '/usr/local/lib/cc65/include/stdio.h' +Opened include file '/usr/local/lib/cc65/include/stddef.h' +Opened include file '/usr/local/lib/cc65/include/stdarg.h' +Opened include file '/usr/local/lib/cc65/include/limits.h' 0 errors, 0 warnings -Opened output file `tests/cc65110210.s' -Wrote output to `tests/cc65110210.s' -Closed output file `tests/cc65110210.s' -cl65: Subprocess `ld65' aborted by signal 11 +Opened output file 'tests/cc65110210.s' +Wrote output to 'tests/cc65110210.s' +Closed output file 'tests/cc65110210.s' +cl65: Subprocess 'ld65' aborted by signal 11 */ diff --git a/test/ref/cf.c b/test/ref/cf.c index 66fb42b10..bb0c13e8b 100644 --- a/test/ref/cf.c +++ b/test/ref/cf.c @@ -33,9 +33,9 @@ int argc; char *argv[]; #endif { - int i, c, nc; + int i, c, nc; #ifndef NO_FLOATS - float cutoff, atof(); + float cutoff, atof(); #else signed cutoff; #endif @@ -45,22 +45,22 @@ char *argv[]; return EXIT_FAILURE; } - if (argc <= 1) + if (argc <= 1) #ifndef NO_FLOATS - cutoff = 0.0; + cutoff = 0.0; #else cutoff = 0; #endif - else + else #ifndef NO_FLOATS - cutoff = atof(argv[1])/100; + cutoff = atof(argv[1])/100; #else cutoff = atoi(argv[1])/100; #endif - for (i = 0; i < 0x100; ) + for (i = 0; i < 0x100; ) { #ifndef NO_FLOATS - f[i++] = 0.0; + f[i++] = 0.0; #else f[i++] = 0; #endif @@ -87,13 +87,13 @@ char *argv[]; printf("a-z char:freq\n\n"); /* first round ... lowercase characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= 'a') && (i <= 'z')) + if ((i >= 'a') && (i <= 'z')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -101,19 +101,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("A-Z char:freq\n\n"); /* second round ... uppercase characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= 'A') && (i <= 'Z')) + if ((i >= 'A') && (i <= 'Z')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -121,19 +121,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("0-9 char:freq\n\n"); /* third round ... numbers */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if ((i >= '0') && (i <= '9')) + if ((i >= '0') && (i <= '9')) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -141,19 +141,19 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("isprint char:freq\n\n"); /* second last round ... remaining printable characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { - if(isprint(i)) + if(isprint(i)) { - printf("%c", i); + printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else @@ -161,30 +161,30 @@ char *argv[]; #endif f[i]=0; } - } + } } printf("rest char:freq\n\n"); /* last round ... remaining non printable characters */ - for (i = 0; i < 0x100; ++i) + for (i = 0; i < 0x100; ++i) { - if ((f[i]) && ((f[i]/nc) >= cutoff)) + if ((f[i]) && ((f[i]/nc) >= cutoff)) { if(i=='\n') { - printf("newline"); + printf("newline"); } else { - printf("%03o", i); + printf("%03o", i); } #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif - } + } } fclose(in); return 0; diff --git a/test/ref/charconst.c b/test/ref/charconst.c index 65ebc70be..1a2f5303d 100644 --- a/test/ref/charconst.c +++ b/test/ref/charconst.c @@ -14,23 +14,23 @@ void backslash(unsigned char c) switch (c) { - case 'b': - c = '\b'; - case 'f': - c = '\f'; - case 'n': - c = '\n'; - case 'r': - c = '\r'; - case 't': - c = '\t'; - case 'v': + case 'b': + c = '\b'; + case 'f': + c = '\f'; + case 'n': + c = '\n'; + case 'r': + c = '\r'; + case 't': + c = '\t'; + case 'v': #ifndef NO_BACKSLASH_V c = '\v'; #else c = 0x0b; #endif - } + } if(!isprint(c)) { @@ -54,7 +54,7 @@ void testbackslash(void) int main(void) { - testbackslash(); + testbackslash(); - return 0; + return 0; } diff --git a/test/ref/charset.c b/test/ref/charset.c index 59b7c4c54..8bd1675c8 100644 --- a/test/ref/charset.c +++ b/test/ref/charset.c @@ -12,82 +12,82 @@ /* this kind of line-continuation for strings doesnt work properly for cc65 */ const unsigned char characters[]={ - /*0123456789abcdef0123456789abcdef*/ - /* iso646-us control-characters */ - " " /* 00-1f */ - /* iso646-us printable characters */ - " !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */ - "0123456789" /* 30-39 0123456789 */ - ":;<=>?@" /* 3a-40 :;<=>?@ */ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */ - "[\\]^_`" /* 5b-60 [\]^_` */ - "abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */ - "{|}~ " /* 7b-7f {|}~ */ - /* iso8859-15 extended characters */ + /*0123456789abcdef0123456789abcdef*/ + /* iso646-us control-characters */ + " " /* 00-1f */ + /* iso646-us printable characters */ + " !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */ + "0123456789" /* 30-39 0123456789 */ + ":;<=>?@" /* 3a-40 :;<=>?@ */ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */ + "[\\]^_`" /* 5b-60 [\]^_` */ + "abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */ + "{|}~ " /* 7b-7f {|}~ */ + /* iso8859-15 extended characters */ }; #endif const unsigned char characters[]={ - /*0123456789abcdef0123456789abcdef*/ - /* iso646-us control-characters */ - /* 00-1f */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /* iso646-us printable characters */ - /* 20-2f !"#$%&'()*+,-./ */ - ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', - /* 30-39 0123456789 */ - '0','1','2','3','4','5','6','7','8','9', - /* 3a-40 :;<=>?@ */ - ':',';','<','=','>','?','@', - /* 41-5a A-Z */ - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - /* 5b-60 [\]^_` */ - '[','\\',']','^','_','`', - /* 61-7a a-z */ - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', - /* 7b-7f {|}~ */ - '{','|','}','~',' ' - /* iso8859-15 extended characters */ + /*0123456789abcdef0123456789abcdef*/ + /* iso646-us control-characters */ + /* 00-1f */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* iso646-us printable characters */ + /* 20-2f !"#$%&'()*+,-./ */ + ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', + /* 30-39 0123456789 */ + '0','1','2','3','4','5','6','7','8','9', + /* 3a-40 :;<=>?@ */ + ':',';','<','=','>','?','@', + /* 41-5a A-Z */ + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + /* 5b-60 [\]^_` */ + '[','\\',']','^','_','`', + /* 61-7a a-z */ + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', + /* 7b-7f {|}~ */ + '{','|','}','~',' ' + /* iso8859-15 extended characters */ }; void printchars(unsigned char a,unsigned char b){ - for(b++;a!=b;a++) + for(b++;a!=b;a++) /* printf("%02x ",a); */ /* printf("%02x ",characters[a]); */ - printf("%c",characters[a]); - printf("\n"); + printf("%c",characters[a]); + printf("\n"); } int main(void) { - printf("characters:\n\n"); - printchars(0x61,0x7a); - printchars(0x41,0x5a); - printf("numbers:\n\n"); - printchars(0x30,0x39); - printf("other:\n\n"); - printchars(0x20,0x2f); - /*printchars(0x3a,0x40);*/ - printchars(0x3a,0x3f); - /*printchars(0x5b,0x60);*/ - /*printchars(0x7b,0x7f);*/ - printf("\n\n"); - printf("slash: '%c'\n",'/'); - printf("backslash: '%c'\n",'\\'); - printf("curly braces open: '%c'\n",'{'); - printf("curly braces close: '%c'\n",'}'); - printf("square braces open: '%c'\n",'['); - printf("square braces close: '%c'\n",']'); - printf("underscore: '%c'\n",'_'); - printf("tilde: '%c'\n",'~'); - printf("pipe: '%c'\n",'|'); - printf("apostroph: '%c'\n",'\''); - printf("single quote '%c'\n",'`'); - printf("xor '%c'\n",'^'); - printf("at '%c'\n",'@'); + printf("characters:\n\n"); + printchars(0x61,0x7a); + printchars(0x41,0x5a); + printf("numbers:\n\n"); + printchars(0x30,0x39); + printf("other:\n\n"); + printchars(0x20,0x2f); + /*printchars(0x3a,0x40);*/ + printchars(0x3a,0x3f); + /*printchars(0x5b,0x60);*/ + /*printchars(0x7b,0x7f);*/ + printf("\n\n"); + printf("slash: '%c'\n",'/'); + printf("backslash: '%c'\n",'\\'); + printf("curly braces open: '%c'\n",'{'); + printf("curly braces close: '%c'\n",'}'); + printf("square braces open: '%c'\n",'['); + printf("square braces close: '%c'\n",']'); + printf("underscore: '%c'\n",'_'); + printf("tilde: '%c'\n",'~'); + printf("pipe: '%c'\n",'|'); + printf("apostroph: '%c'\n",'\''); + printf("single quote '%c'\n",'`'); + printf("xor '%c'\n",'^'); + printf("at '%c'\n",'@'); - return 0; + return 0; } diff --git a/test/ref/divmod.c b/test/ref/divmod.c index 8fcc951a6..e5535ebc4 100644 --- a/test/ref/divmod.c +++ b/test/ref/divmod.c @@ -8,31 +8,31 @@ void printc(signed char a,signed char b){ signed char x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); } void prints(short a,short b){ short x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); } void printl(long a,long b){ long x=a/b,y=a%b,z=a*b; - printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); + printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); } int main(void) { - printl( 3,-2); - printl(-3,-2); - printl(-3, 2); - printl( 3, 2); - printf("-\n"); - prints( 3,-2); - prints(-3,-2); - prints(-3, 2); - prints( 3, 2); - printf("-\n"); - printc( 3,-2); - printc(-3,-2); - printc(-3, 2); - printc( 3, 2); - return 0; + printl( 3,-2); + printl(-3,-2); + printl(-3, 2); + printl( 3, 2); + printf("-\n"); + prints( 3,-2); + prints(-3,-2); + prints(-3, 2); + prints( 3, 2); + printf("-\n"); + printc( 3,-2); + printc(-3,-2); + printc(-3, 2); + printc( 3, 2); + return 0; } diff --git a/test/ref/hanoi.c b/test/ref/hanoi.c index 234ac41e4..5198c5c61 100644 --- a/test/ref/hanoi.c +++ b/test/ref/hanoi.c @@ -11,8 +11,8 @@ ******************************************************************************* * Bug reports, patches, comments, suggestions should be sent to: * - * Ben Smith, Rick Grehan or Tom Yager - * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com + * Ben Smith, Rick Grehan or Tom Yager + * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com * ******************************************************************************* * Modification Log: @@ -38,53 +38,53 @@ void mov(unsigned char n,unsigned char f,unsigned char t) { char o; - if(n == 1) - { - num[f]--; - num[t]++; - } - else - { - o = (6-(f+t)); - mov(n-1,f,o); - mov(1,f,t); - mov(n-1,o,t); - } + if(n == 1) + { + num[f]--; + num[t]++; + } + else + { + o = (6-(f+t)); + mov(n-1,f,o); + mov(1,f,t); + mov(n-1,o,t); + } - #ifdef VERBOSE - printf("%2d: %2d %2d %2d %2d\n", - (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); - #endif + #ifdef VERBOSE + printf("%2d: %2d %2d %2d %2d\n", + (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); + #endif } int main(int argc,char **argv) { - #ifdef USECMDLINE - if (argc < 2) { - printf("Usage: %s [duration] [disks]\n", argv[0]); - exit(1); - } - else - { - if(argc > 1) duration = atoi(argv[1]); - if(argc > 2) disk = atoi(argv[2]); - } - #endif + #ifdef USECMDLINE + if (argc < 2) { + printf("Usage: %s [duration] [disks]\n", argv[0]); + exit(1); + } + else + { + if(argc > 1) duration = atoi(argv[1]); + if(argc > 2) disk = atoi(argv[2]); + } + #endif - printf("towers of hanoi\ndisks: %d\n\n",disk); + printf("towers of hanoi\ndisks: %d\n\n",disk); - num[1] = disk; + num[1] = disk; - #ifdef VERBOSE - printf("%2d: %2d %2d %2d %2d\n", - (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); - #endif + #ifdef VERBOSE + printf("%2d: %2d %2d %2d %2d\n", + (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]); + #endif - while(num[3]codes[0]; p++) { - for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) - printf("%d ", p->codes[i]); - printf("%s\n", p->name); - } - h(); + for ( ; p->codes[0]; p++) { + for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) + printf("%d ", p->codes[i]); + printf("%s\n", p->name); + } + h(); } h() { - int i; + int i; - for (i = 0; i < sizeof(words)/sizeof(Word); i++) - printf("%d %d %d %s\n", words[i].codes[0], - words[i].codes[1], words[i].codes[2], - &words[i].name[0]); + for (i = 0; i < sizeof(words)/sizeof(Word); i++) + printf("%d %d %d %s\n", words[i].codes[0], + words[i].codes[1], words[i].codes[2], + &words[i].name[0]); } diff --git a/test/ref/macro.c b/test/ref/macro.c index 1650b98db..c1346b939 100644 --- a/test/ref/macro.c +++ b/test/ref/macro.c @@ -14,17 +14,17 @@ unsigned long a=3; unsigned long _func(unsigned long x,unsigned long y) { - printf("x:%ld y:%ld\n",x,y); - return 0; + printf("x:%ld y:%ld\n",x,y); + return 0; } -#define func(x,y) _func(x,y) +#define func(x,y) _func(x,y) int main(void) { - fs= func( (fd/a) , func(2,0x0082c90f) ); - printf("fs:%ld\n",fs); - fs=_func( (fd/a) , _func(2,0x0082c90f) ); - printf("fs:%ld\n",fs); - return 0; + fs= func( (fd/a) , func(2,0x0082c90f) ); + printf("fs:%ld\n",fs); + fs=_func( (fd/a) , _func(2,0x0082c90f) ); + printf("fs:%ld\n",fs); + return 0; } diff --git a/test/ref/paranoia.c b/test/ref/paranoia.c index e9a47dd71..1021264a5 100644 --- a/test/ref/paranoia.c +++ b/test/ref/paranoia.c @@ -18,39 +18,39 @@ main() #undef V9 #define NOPAUSE -/* A C version of Kahan's Floating Point Test "Paranoia" +/* A C version of Kahan's Floating Point Test "Paranoia" - Thos Sumner, UCSF, Feb. 1985 - David Gay, BTL, Jan. 1986 + Thos Sumner, UCSF, Feb. 1985 + David Gay, BTL, Jan. 1986 - This is a rewrite from the Pascal version by + This is a rewrite from the Pascal version by - B. A. Wichmann, 18 Jan. 1985 + B. A. Wichmann, 18 Jan. 1985 - (and does NOT exhibit good C programming style). + (and does NOT exhibit good C programming style). (C) Apr 19 1983 in BASIC version by: - Professor W. M. Kahan, - 567 Evans Hall - Electrical Engineering & Computer Science Dept. - University of California - Berkeley, California 94720 - USA + Professor W. M. Kahan, + 567 Evans Hall + Electrical Engineering & Computer Science Dept. + University of California + Berkeley, California 94720 + USA converted to Pascal by: - B. A. Wichmann - National Physical Laboratory - Teddington Middx - TW11 OLW - UK + B. A. Wichmann + National Physical Laboratory + Teddington Middx + TW11 OLW + UK converted to C by: - David M. Gay and Thos Sumner - AT&T Bell Labs Computer Center, Rm. U-76 - 600 Mountain Avenue University of California - Murray Hill, NJ 07974 San Francisco, CA 94143 - USA USA + David M. Gay and Thos Sumner + AT&T Bell Labs Computer Center, Rm. U-76 + 600 Mountain Avenue University of California + Murray Hill, NJ 07974 San Francisco, CA 94143 + USA USA with simultaneous corrections to the Pascal source (reflected in the Pascal source available over netlib). @@ -282,11 +282,11 @@ int NoTrials = 20; /*Number of tests for commutativity. */ #define True 1 /* Definitions for declared types - Guard == (Yes, No); - Rounding == (Chopped, Rounded, Other); - Message == packed array [1..40] of char; - Class == (Flaw, Defect, Serious, Failure); - */ + Guard == (Yes, No); + Rounding == (Chopped, Rounded, Other); + Message == packed array [1..40] of char; + Class == (Flaw, Defect, Serious, Failure); + */ #define Yes 1 #define No 0 #define Chopped 2 @@ -331,7 +331,7 @@ int M, N, N1; Guard GMult, GDiv, GAddSub; Rounding RMult, RDiv, RAddSub, RSqrt; int Break, Done, NotMonot, Monot, Anomaly, IEEE, - SqRWrng, UfNGrad; + SqRWrng, UfNGrad; /* Computed constants. */ /*U1 gap below 1.0, i.e, 1.0-U1 is next number below 1.0 */ /*U2 gap above 1.0, i.e, 1.0+U2 is next number above 1.0 */ @@ -340,1518 +340,1518 @@ int Break, Done, NotMonot, Monot, Anomaly, IEEE, void sigfpe(i) { - fpecount++; - printf("\n* * * FLOATING-POINT ERROR * * *\n"); - fflush(stdout); - if (sigsave) { + fpecount++; + printf("\n* * * FLOATING-POINT ERROR * * *\n"); + fflush(stdout); + if (sigsave) { #ifndef NOSIGNAL - signal(SIGFPE, sigsave); + signal(SIGFPE, sigsave); #endif - sigsave = 0; - longjmp(ovfl_buf, 1); - } - abort(); + sigsave = 0; + longjmp(ovfl_buf, 1); + } + abort(); } main() { #ifdef mc - char *out; - ieee_flags("set", "precision", "double", &out); + char *out; + ieee_flags("set", "precision", "double", &out); #endif - /* First two assignments use integer right-hand sides. */ - Zero = 0; - One = 1; - Two = One + One; - Three = Two + One; - Four = Three + One; - Five = Four + One; - Eight = Four + Four; - Nine = Three * Three; - TwentySeven = Nine * Three; - ThirtyTwo = Four * Eight; - TwoForty = Four * Five * Three * Four; - MinusOne = -One; - Half = One / Two; - OneAndHalf = One + Half; - ErrCnt[Failure] = 0; - ErrCnt[Serious] = 0; - ErrCnt[Defect] = 0; - ErrCnt[Flaw] = 0; - PageNo = 1; - /*=============================================*/ - Milestone = 0; - /*=============================================*/ + /* First two assignments use integer right-hand sides. */ + Zero = 0; + One = 1; + Two = One + One; + Three = Two + One; + Four = Three + One; + Five = Four + One; + Eight = Four + Four; + Nine = Three * Three; + TwentySeven = Nine * Three; + ThirtyTwo = Four * Eight; + TwoForty = Four * Five * Three * Four; + MinusOne = -One; + Half = One / Two; + OneAndHalf = One + Half; + ErrCnt[Failure] = 0; + ErrCnt[Serious] = 0; + ErrCnt[Defect] = 0; + ErrCnt[Flaw] = 0; + PageNo = 1; + /*=============================================*/ + Milestone = 0; + /*=============================================*/ #ifndef NOSIGNAL - signal(SIGFPE, sigfpe); + signal(SIGFPE, sigfpe); #endif - Instructions(); - Pause(); - Heading(); - Pause(); - Characteristics(); - Pause(); - History(); - Pause(); - /*=============================================*/ - Milestone = 7; - /*=============================================*/ - printf("Program is now RUNNING tests on small integers:\n"); + Instructions(); + Pause(); + Heading(); + Pause(); + Characteristics(); + Pause(); + History(); + Pause(); + /*=============================================*/ + Milestone = 7; + /*=============================================*/ + printf("Program is now RUNNING tests on small integers:\n"); - TstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero) - && (One > Zero) && (One + One == Two), - "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2"); - Z = - Zero; - if (Z != 0.0) { - ErrCnt[Failure] = ErrCnt[Failure] + 1; - printf("Comparison alleges that -0.0 is Non-zero!\n"); - U1 = 0.001; - Radix = 1; - TstPtUf(); - } - TstCond (Failure, (Three == Two + One) && (Four == Three + One) - && (Four + Two * (- Two) == Zero) - && (Four - Three - One == Zero), - "3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0"); - TstCond (Failure, (MinusOne == (0 - One)) - && (MinusOne + One == Zero ) && (One + MinusOne == Zero) - && (MinusOne + FABS(One) == Zero) - && (MinusOne + MinusOne * MinusOne == Zero), - "-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0"); - TstCond (Failure, Half + MinusOne + Half == Zero, - "1/2 + (-1) + 1/2 != 0"); - /*=============================================*/ - /*SPLIT - part2(); - part3(); - part4(); - part5(); - part6(); - part7(); - part8(); - } + TstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero) + && (One > Zero) && (One + One == Two), + "0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2"); + Z = - Zero; + if (Z != 0.0) { + ErrCnt[Failure] = ErrCnt[Failure] + 1; + printf("Comparison alleges that -0.0 is Non-zero!\n"); + U1 = 0.001; + Radix = 1; + TstPtUf(); + } + TstCond (Failure, (Three == Two + One) && (Four == Three + One) + && (Four + Two * (- Two) == Zero) + && (Four - Three - One == Zero), + "3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0"); + TstCond (Failure, (MinusOne == (0 - One)) + && (MinusOne + One == Zero ) && (One + MinusOne == Zero) + && (MinusOne + FABS(One) == Zero) + && (MinusOne + MinusOne * MinusOne == Zero), + "-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0"); + TstCond (Failure, Half + MinusOne + Half == Zero, + "1/2 + (-1) + 1/2 != 0"); + /*=============================================*/ + /*SPLIT + part2(); + part3(); + part4(); + part5(); + part6(); + part7(); + part8(); + } #include "paranoia.h" part2(){ */ - Milestone = 10; - /*=============================================*/ - TstCond (Failure, (Nine == Three * Three) - && (TwentySeven == Nine * Three) && (Eight == Four + Four) - && (ThirtyTwo == Eight * Four) - && (ThirtyTwo - TwentySeven - Four - One == Zero), - "9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0"); - TstCond (Failure, (Five == Four + One) && - (TwoForty == Four * Five * Three * Four) - && (TwoForty / Three - Four * Four * Five == Zero) - && ( TwoForty / Four - Five * Three * Four == Zero) - && ( TwoForty / Five - Four * Three * Four == Zero), - "5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48"); - if (ErrCnt[Failure] == 0) { - printf("-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n"); - printf("\n"); - } - printf("Searching for Radix and Precision.\n"); - W = One; - do { - W = W + W; - Y = W + One; - Z = Y - W; - Y = Z - One; - } while (MinusOne + FABS(Y) < Zero); - /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/ - Precision = Zero; - Y = One; - do { - Radix = W + Y; - Y = Y + Y; - Radix = Radix - W; - } while ( Radix == Zero); - if (Radix < Two) Radix = One; - printf("Radix = %f .\n", Radix); - if (Radix != 1) { - W = One; - do { - Precision = Precision + One; - W = W * Radix; - Y = W + One; - } while ((Y - W) == One); - } - /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1 - ...*/ - U1 = One / W; - U2 = Radix * U1; - printf("Closest relative separation found is U1 = %.7e .\n\n", U1); - printf("Recalculating radix and precision\n "); + Milestone = 10; + /*=============================================*/ + TstCond (Failure, (Nine == Three * Three) + && (TwentySeven == Nine * Three) && (Eight == Four + Four) + && (ThirtyTwo == Eight * Four) + && (ThirtyTwo - TwentySeven - Four - One == Zero), + "9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0"); + TstCond (Failure, (Five == Four + One) && + (TwoForty == Four * Five * Three * Four) + && (TwoForty / Three - Four * Four * Five == Zero) + && ( TwoForty / Four - Five * Three * Four == Zero) + && ( TwoForty / Five - Four * Three * Four == Zero), + "5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48"); + if (ErrCnt[Failure] == 0) { + printf("-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n"); + printf("\n"); + } + printf("Searching for Radix and Precision.\n"); + W = One; + do { + W = W + W; + Y = W + One; + Z = Y - W; + Y = Z - One; + } while (MinusOne + FABS(Y) < Zero); + /*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/ + Precision = Zero; + Y = One; + do { + Radix = W + Y; + Y = Y + Y; + Radix = Radix - W; + } while ( Radix == Zero); + if (Radix < Two) Radix = One; + printf("Radix = %f .\n", Radix); + if (Radix != 1) { + W = One; + do { + Precision = Precision + One; + W = W * Radix; + Y = W + One; + } while ((Y - W) == One); + } + /*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1 + ...*/ + U1 = One / W; + U2 = Radix * U1; + printf("Closest relative separation found is U1 = %.7e .\n\n", U1); + printf("Recalculating radix and precision\n "); - /*save old values*/ - E0 = Radix; - E1 = U1; - E9 = U2; - E3 = Precision; + /*save old values*/ + E0 = Radix; + E1 = U1; + E9 = U2; + E3 = Precision; - X = Four / Three; - Third = X - One; - F6 = Half - Third; - X = F6 + F6; - X = FABS(X - Third); - if (X < U2) X = U2; + X = Four / Three; + Third = X - One; + F6 = Half - Third; + X = F6 + F6; + X = FABS(X - Third); + if (X < U2) X = U2; - /*... now X = (unknown no.) ulps of 1+...*/ - do { - U2 = X; - Y = Half * U2 + ThirtyTwo * U2 * U2; - Y = One + Y; - X = Y - One; - } while ( ! ((U2 <= X) || (X <= Zero))); + /*... now X = (unknown no.) ulps of 1+...*/ + do { + U2 = X; + Y = Half * U2 + ThirtyTwo * U2 * U2; + Y = One + Y; + X = Y - One; + } while ( ! ((U2 <= X) || (X <= Zero))); - /*... now U2 == 1 ulp of 1 + ... */ - X = Two / Three; - F6 = X - Half; - Third = F6 + F6; - X = Third - Half; - X = FABS(X + F6); - if (X < U1) X = U1; + /*... now U2 == 1 ulp of 1 + ... */ + X = Two / Three; + F6 = X - Half; + Third = F6 + F6; + X = Third - Half; + X = FABS(X + F6); + if (X < U1) X = U1; - /*... now X == (unknown no.) ulps of 1 -... */ - do { - U1 = X; - Y = Half * U1 + ThirtyTwo * U1 * U1; - Y = Half - Y; - X = Half + Y; - Y = Half - X; - X = Half + Y; - } while ( ! ((U1 <= X) || (X <= Zero))); - /*... now U1 == 1 ulp of 1 - ... */ - if (U1 == E1) printf("confirms closest relative separation U1 .\n"); - else printf("gets better closest relative separation U1 = %.7e .\n", U1); - W = One / U1; - F9 = (Half - U1) + Half; - Radix = FLOOR(0.01 + U2 / U1); - if (Radix == E0) printf("Radix confirmed.\n"); - else printf("MYSTERY: recalculated Radix = %.7e .\n", Radix); - TstCond (Defect, Radix <= Eight + Eight, - "Radix is too big: roundoff problems"); - TstCond (Flaw, (Radix == Two) || (Radix == 10) - || (Radix == One), "Radix is not as good as 2 or 10"); - /*=============================================*/ - Milestone = 20; - /*=============================================*/ - TstCond (Failure, F9 - Half < Half, - "(1-U1)-1/2 < 1/2 is FALSE, prog. fails?"); - X = F9; - I = 1; - Y = X - Half; - Z = Y - Half; - TstCond (Failure, (X != One) - || (Z == Zero), "Comparison is fuzzy,X=1 but X-1/2-1/2 != 0"); - X = One + U2; - I = 0; - /*=============================================*/ - Milestone = 25; - /*=============================================*/ - /*... BMinusU2 = nextafter(Radix, 0) */ - BMinusU2 = Radix - One; - BMinusU2 = (BMinusU2 - U2) + One; - /* Purify Integers */ - if (Radix != One) { - X = - TwoForty * LOG(U1) / LOG(Radix); - Y = FLOOR(Half + X); - if (FABS(X - Y) * Four < One) X = Y; - Precision = X / TwoForty; - Y = FLOOR(Half + Precision); - if (FABS(Precision - Y) * TwoForty < Half) Precision = Y; - } - if ((Precision != FLOOR(Precision)) || (Radix == One)) { - printf("Precision cannot be characterized by an Integer number\n"); - printf("of significant digits but, by itself, this is a minor flaw.\n"); - } - if (Radix == One) - printf("logarithmic encoding has precision characterized solely by U1.\n"); - else printf("The number of significant digits of the Radix is %f .\n", - Precision); - TstCond (Serious, U2 * Nine * Nine * TwoForty < One, - "Precision worse than 5 decimal figures "); - /*=============================================*/ - Milestone = 30; - /*=============================================*/ - /* Test for extra-precise subepressions */ - X = FABS(((Four / Three - One) - One / Four) * Three - One / Four); - do { - Z2 = X; - X = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One; - } while ( ! ((Z2 <= X) || (X <= Zero))); - X = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four); - do { - Z1 = Z; - Z = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1)) - + One / Two)) + One / Two; - } while ( ! ((Z1 <= Z) || (Z <= Zero))); - do { - do { - Y1 = Y; - Y = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half - )) + Half; - } while ( ! ((Y1 <= Y) || (Y <= Zero))); - X1 = X; - X = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9; - } while ( ! ((X1 <= X) || (X <= Zero))); - if ((X1 != Y1) || (X1 != Z1)) { - BadCond(Serious, "Disagreements among the values X1, Y1, Z1,\n"); - printf("respectively %.7e, %.7e, %.7e,\n", X1, Y1, Z1); - printf("are symptoms of inconsistencies introduced\n"); - printf("by extra-precise evaluation of arithmetic subexpressions.\n"); - notify("Possibly some part of this"); - if ((X1 == U1) || (Y1 == U1) || (Z1 == U1)) printf( - "That feature is not tested further by this program.\n") ; - } - else { - if ((Z1 != U1) || (Z2 != U2)) { - if ((Z1 >= U1) || (Z2 >= U2)) { - BadCond(Failure, ""); - notify("Precision"); - printf("\tU1 = %.7e, Z1 - U1 = %.7e\n",U1,Z1-U1); - printf("\tU2 = %.7e, Z2 - U2 = %.7e\n",U2,Z2-U2); - } - else { - if ((Z1 <= Zero) || (Z2 <= Zero)) { - printf("Because of unusual Radix = %f", Radix); - printf(", or exact rational arithmetic a result\n"); - printf("Z1 = %.7e, or Z2 = %.7e ", Z1, Z2); - notify("of an\nextra-precision"); - } - if (Z1 != Z2 || Z1 > Zero) { - X = Z1 / U1; - Y = Z2 / U2; - if (Y > X) X = Y; - Q = - LOG(X); - printf("Some subexpressions appear to be calculated extra\n"); - printf("precisely with about %g extra B-digits, i.e.\n", - (Q / LOG(Radix))); - printf("roughly %g extra significant decimals.\n", - Q / LOG(10.)); - } - printf("That feature is not tested further by this program.\n"); - } - } - } - Pause(); - /*=============================================*/ - /*SPLIT - } + /*... now X == (unknown no.) ulps of 1 -... */ + do { + U1 = X; + Y = Half * U1 + ThirtyTwo * U1 * U1; + Y = Half - Y; + X = Half + Y; + Y = Half - X; + X = Half + Y; + } while ( ! ((U1 <= X) || (X <= Zero))); + /*... now U1 == 1 ulp of 1 - ... */ + if (U1 == E1) printf("confirms closest relative separation U1 .\n"); + else printf("gets better closest relative separation U1 = %.7e .\n", U1); + W = One / U1; + F9 = (Half - U1) + Half; + Radix = FLOOR(0.01 + U2 / U1); + if (Radix == E0) printf("Radix confirmed.\n"); + else printf("MYSTERY: recalculated Radix = %.7e .\n", Radix); + TstCond (Defect, Radix <= Eight + Eight, + "Radix is too big: roundoff problems"); + TstCond (Flaw, (Radix == Two) || (Radix == 10) + || (Radix == One), "Radix is not as good as 2 or 10"); + /*=============================================*/ + Milestone = 20; + /*=============================================*/ + TstCond (Failure, F9 - Half < Half, + "(1-U1)-1/2 < 1/2 is FALSE, prog. fails?"); + X = F9; + I = 1; + Y = X - Half; + Z = Y - Half; + TstCond (Failure, (X != One) + || (Z == Zero), "Comparison is fuzzy,X=1 but X-1/2-1/2 != 0"); + X = One + U2; + I = 0; + /*=============================================*/ + Milestone = 25; + /*=============================================*/ + /*... BMinusU2 = nextafter(Radix, 0) */ + BMinusU2 = Radix - One; + BMinusU2 = (BMinusU2 - U2) + One; + /* Purify Integers */ + if (Radix != One) { + X = - TwoForty * LOG(U1) / LOG(Radix); + Y = FLOOR(Half + X); + if (FABS(X - Y) * Four < One) X = Y; + Precision = X / TwoForty; + Y = FLOOR(Half + Precision); + if (FABS(Precision - Y) * TwoForty < Half) Precision = Y; + } + if ((Precision != FLOOR(Precision)) || (Radix == One)) { + printf("Precision cannot be characterized by an Integer number\n"); + printf("of significant digits but, by itself, this is a minor flaw.\n"); + } + if (Radix == One) + printf("logarithmic encoding has precision characterized solely by U1.\n"); + else printf("The number of significant digits of the Radix is %f .\n", + Precision); + TstCond (Serious, U2 * Nine * Nine * TwoForty < One, + "Precision worse than 5 decimal figures "); + /*=============================================*/ + Milestone = 30; + /*=============================================*/ + /* Test for extra-precise subepressions */ + X = FABS(((Four / Three - One) - One / Four) * Three - One / Four); + do { + Z2 = X; + X = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One; + } while ( ! ((Z2 <= X) || (X <= Zero))); + X = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four); + do { + Z1 = Z; + Z = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1)) + + One / Two)) + One / Two; + } while ( ! ((Z1 <= Z) || (Z <= Zero))); + do { + do { + Y1 = Y; + Y = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half + )) + Half; + } while ( ! ((Y1 <= Y) || (Y <= Zero))); + X1 = X; + X = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9; + } while ( ! ((X1 <= X) || (X <= Zero))); + if ((X1 != Y1) || (X1 != Z1)) { + BadCond(Serious, "Disagreements among the values X1, Y1, Z1,\n"); + printf("respectively %.7e, %.7e, %.7e,\n", X1, Y1, Z1); + printf("are symptoms of inconsistencies introduced\n"); + printf("by extra-precise evaluation of arithmetic subexpressions.\n"); + notify("Possibly some part of this"); + if ((X1 == U1) || (Y1 == U1) || (Z1 == U1)) printf( + "That feature is not tested further by this program.\n") ; + } + else { + if ((Z1 != U1) || (Z2 != U2)) { + if ((Z1 >= U1) || (Z2 >= U2)) { + BadCond(Failure, ""); + notify("Precision"); + printf("\tU1 = %.7e, Z1 - U1 = %.7e\n",U1,Z1-U1); + printf("\tU2 = %.7e, Z2 - U2 = %.7e\n",U2,Z2-U2); + } + else { + if ((Z1 <= Zero) || (Z2 <= Zero)) { + printf("Because of unusual Radix = %f", Radix); + printf(", or exact rational arithmetic a result\n"); + printf("Z1 = %.7e, or Z2 = %.7e ", Z1, Z2); + notify("of an\nextra-precision"); + } + if (Z1 != Z2 || Z1 > Zero) { + X = Z1 / U1; + Y = Z2 / U2; + if (Y > X) X = Y; + Q = - LOG(X); + printf("Some subexpressions appear to be calculated extra\n"); + printf("precisely with about %g extra B-digits, i.e.\n", + (Q / LOG(Radix))); + printf("roughly %g extra significant decimals.\n", + Q / LOG(10.)); + } + printf("That feature is not tested further by this program.\n"); + } + } + } + Pause(); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part3(){ */ - Milestone = 35; - /*=============================================*/ - if (Radix >= Two) { - X = W / (Radix * Radix); - Y = X + One; - Z = Y - X; - T = Z + U2; - X = T - Z; - TstCond (Failure, X == U2, - "Subtraction is not normalized X=Y,X+Z != Y+Z!"); - if (X == U2) printf( - "Subtraction appears to be normalized, as it should be."); - } - printf("\nChecking for guard digit in *, /, and -.\n"); - Y = F9 * One; - Z = One * F9; - X = F9 - Half; - Y = (Y - Half) - X; - Z = (Z - Half) - X; - X = One + U2; - T = X * Radix; - R = Radix * X; - X = T - Radix; - X = X - Radix * U2; - T = R - Radix; - T = T - Radix * U2; - X = X * (Radix - One); - T = T * (Radix - One); - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes; - else { - GMult = No; - TstCond (Serious, False, - "* lacks a Guard Digit, so 1*X != X"); - } - Z = Radix * U2; - X = One + Z; - Y = FABS((X + Z) - X * X) - U2; - X = One - U2; - Z = FABS((X - U2) - X * X) - U1; - TstCond (Failure, (Y <= Zero) - && (Z <= Zero), "* gets too many final digits wrong.\n"); - Y = One - U2; - X = One + U2; - Z = One / Y; - Y = Z - X; - X = One / Three; - Z = Three / Nine; - X = X - Z; - T = Nine / TwentySeven; - Z = Z - T; - TstCond(Defect, X == Zero && Y == Zero && Z == Zero, - "Division lacks a Guard Digit, so error can exceed 1 ulp\nor 1/3 and 3/9 and 9/27 may disagree"); - Y = F9 / One; - X = F9 - Half; - Y = (Y - Half) - X; - X = One + U2; - T = X / One; - X = T - X; - if ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes; - else { - GDiv = No; - TstCond (Serious, False, - "Division lacks a Guard Digit, so X/1 != X"); - } - X = One / (One + U2); - Y = X - Half - Half; - TstCond (Serious, Y < Zero, - "Computed value of 1/1.000..1 >= 1"); - X = One - U2; - Y = One + Radix * U2; - Z = X * Radix; - T = Y * Radix; - R = Z / Radix; - StickyBit = T / Radix; - X = R - X; - Y = StickyBit - Y; - TstCond (Failure, X == Zero && Y == Zero, - "* and/or / gets too many last digits wrong"); - Y = One - U1; - X = One - F9; - Y = One - Y; - T = Radix - U2; - Z = Radix - BMinusU2; - T = Radix - T; - if ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes; - else { - GAddSub = No; - TstCond (Serious, False, - "- lacks Guard Digit, so cancellation is obscured"); - } - if (F9 != One && F9 - One >= Zero) { - BadCond(Serious, "comparison alleges (1-U1) < 1 although\n"); - printf(" subtraction yields (1-U1) - 1 = 0 , thereby vitiating\n"); - printf(" such precautions against division by zero as\n"); - printf(" ... if (X == 1.0) {.....} else {.../(X-1.0)...}\n"); - } - if (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf( - " *, /, and - appear to have guard digits, as they should.\n"); - /*=============================================*/ - Milestone = 40; - /*=============================================*/ - Pause(); - printf("Checking rounding on multiply, divide and add/subtract.\n"); - RMult = Other; - RDiv = Other; - RAddSub = Other; - RadixD2 = Radix / Two; - A1 = Two; - Done = False; - do { - AInvrse = Radix; - do { - X = AInvrse; - AInvrse = AInvrse / A1; - } while ( ! (FLOOR(AInvrse) != AInvrse)); - Done = (X == One) || (A1 > Three); - if (! Done) A1 = Nine + One; - } while ( ! (Done)); - if (X == One) A1 = Radix; - AInvrse = One / A1; - X = A1; - Y = AInvrse; - Done = False; - do { - Z = X * Y - Half; - TstCond (Failure, Z == Half, - "X * (1/X) differs from 1"); - Done = X == Radix; - X = Radix; - Y = One / X; - } while ( ! (Done)); - Y2 = One + U2; - Y1 = One - U2; - X = OneAndHalf - U2; - Y = OneAndHalf + U2; - Z = (X - U2) * Y2; - T = Y * Y1; - Z = Z - X; - T = T - X; - X = X * Y2; - Y = (Y + U2) * Y1; - X = X - OneAndHalf; - Y = Y - OneAndHalf; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) { - X = (OneAndHalf + U2) * Y2; - Y = OneAndHalf - U2 - U2; - Z = OneAndHalf + U2 + U2; - T = (OneAndHalf - U2) * Y1; - X = X - (Z + U2); - StickyBit = Y * Y1; - S = Z * Y2; - T = T - Y; - Y = (U2 - Y) + StickyBit; - Z = S - (Z + U2 + U2); - StickyBit = (Y2 + U2) * Y1; - Y1 = Y2 * Y1; - StickyBit = StickyBit - Y2; - Y1 = Y1 - Half; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) - && ( StickyBit == Zero) && (Y1 == Half)) { - RMult = Rounded; - printf("Multiplication appears to round correctly.\n"); - } - else if ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero) - && (T < Zero) && (StickyBit + U2 == Zero) - && (Y1 < Half)) { - RMult = Chopped; - printf("Multiplication appears to chop.\n"); - } - else printf("* is neither chopped nor correctly rounded.\n"); - if ((RMult == Rounded) && (GMult == No)) notify("Multiplication"); - } - else printf("* is neither chopped nor correctly rounded.\n"); - /*=============================================*/ - Milestone = 45; - /*=============================================*/ - Y2 = One + U2; - Y1 = One - U2; - Z = OneAndHalf + U2 + U2; - X = Z / Y2; - T = OneAndHalf - U2 - U2; - Y = (T - U2) / Y1; - Z = (Z + U2) / Y2; - X = X - OneAndHalf; - Y = Y - T; - T = T / Y1; - Z = Z - (OneAndHalf + U2); - T = (U2 - OneAndHalf) + T; - if (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) { - X = OneAndHalf / Y2; - Y = OneAndHalf - U2; - Z = OneAndHalf + U2; - X = X - Y; - T = OneAndHalf / Y1; - Y = Y / Y1; - T = T - (Z + U2); - Y = Y - Z; - Z = Z / Y2; - Y1 = (Y2 + U2) / Y2; - Z = Z - OneAndHalf; - Y2 = Y1 - Y2; - Y1 = (F9 - U1) / F9; - if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) - && (Y2 == Zero) && (Y2 == Zero) - && (Y1 - Half == F9 - Half )) { - RDiv = Rounded; - printf("Division appears to round correctly.\n"); - if (GDiv == No) notify("Division"); - } - else if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero) - && (Y2 < Zero) && (Y1 - Half < F9 - Half)) { - RDiv = Chopped; - printf("Division appears to chop.\n"); - } - } - if (RDiv == Other) printf("/ is neither chopped nor correctly rounded.\n"); - BInvrse = One / Radix; - TstCond (Failure, (BInvrse * Radix - Half == Half), - "Radix * ( 1 / Radix ) differs from 1"); - /*=============================================*/ - /*SPLIT - } + Milestone = 35; + /*=============================================*/ + if (Radix >= Two) { + X = W / (Radix * Radix); + Y = X + One; + Z = Y - X; + T = Z + U2; + X = T - Z; + TstCond (Failure, X == U2, + "Subtraction is not normalized X=Y,X+Z != Y+Z!"); + if (X == U2) printf( + "Subtraction appears to be normalized, as it should be."); + } + printf("\nChecking for guard digit in *, /, and -.\n"); + Y = F9 * One; + Z = One * F9; + X = F9 - Half; + Y = (Y - Half) - X; + Z = (Z - Half) - X; + X = One + U2; + T = X * Radix; + R = Radix * X; + X = T - Radix; + X = X - Radix * U2; + T = R - Radix; + T = T - Radix * U2; + X = X * (Radix - One); + T = T * (Radix - One); + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes; + else { + GMult = No; + TstCond (Serious, False, + "* lacks a Guard Digit, so 1*X != X"); + } + Z = Radix * U2; + X = One + Z; + Y = FABS((X + Z) - X * X) - U2; + X = One - U2; + Z = FABS((X - U2) - X * X) - U1; + TstCond (Failure, (Y <= Zero) + && (Z <= Zero), "* gets too many final digits wrong.\n"); + Y = One - U2; + X = One + U2; + Z = One / Y; + Y = Z - X; + X = One / Three; + Z = Three / Nine; + X = X - Z; + T = Nine / TwentySeven; + Z = Z - T; + TstCond(Defect, X == Zero && Y == Zero && Z == Zero, + "Division lacks a Guard Digit, so error can exceed 1 ulp\nor 1/3 and 3/9 and 9/27 may disagree"); + Y = F9 / One; + X = F9 - Half; + Y = (Y - Half) - X; + X = One + U2; + T = X / One; + X = T - X; + if ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes; + else { + GDiv = No; + TstCond (Serious, False, + "Division lacks a Guard Digit, so X/1 != X"); + } + X = One / (One + U2); + Y = X - Half - Half; + TstCond (Serious, Y < Zero, + "Computed value of 1/1.000..1 >= 1"); + X = One - U2; + Y = One + Radix * U2; + Z = X * Radix; + T = Y * Radix; + R = Z / Radix; + StickyBit = T / Radix; + X = R - X; + Y = StickyBit - Y; + TstCond (Failure, X == Zero && Y == Zero, + "* and/or / gets too many last digits wrong"); + Y = One - U1; + X = One - F9; + Y = One - Y; + T = Radix - U2; + Z = Radix - BMinusU2; + T = Radix - T; + if ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes; + else { + GAddSub = No; + TstCond (Serious, False, + "- lacks Guard Digit, so cancellation is obscured"); + } + if (F9 != One && F9 - One >= Zero) { + BadCond(Serious, "comparison alleges (1-U1) < 1 although\n"); + printf(" subtraction yields (1-U1) - 1 = 0 , thereby vitiating\n"); + printf(" such precautions against division by zero as\n"); + printf(" ... if (X == 1.0) {.....} else {.../(X-1.0)...}\n"); + } + if (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf( + " *, /, and - appear to have guard digits, as they should.\n"); + /*=============================================*/ + Milestone = 40; + /*=============================================*/ + Pause(); + printf("Checking rounding on multiply, divide and add/subtract.\n"); + RMult = Other; + RDiv = Other; + RAddSub = Other; + RadixD2 = Radix / Two; + A1 = Two; + Done = False; + do { + AInvrse = Radix; + do { + X = AInvrse; + AInvrse = AInvrse / A1; + } while ( ! (FLOOR(AInvrse) != AInvrse)); + Done = (X == One) || (A1 > Three); + if (! Done) A1 = Nine + One; + } while ( ! (Done)); + if (X == One) A1 = Radix; + AInvrse = One / A1; + X = A1; + Y = AInvrse; + Done = False; + do { + Z = X * Y - Half; + TstCond (Failure, Z == Half, + "X * (1/X) differs from 1"); + Done = X == Radix; + X = Radix; + Y = One / X; + } while ( ! (Done)); + Y2 = One + U2; + Y1 = One - U2; + X = OneAndHalf - U2; + Y = OneAndHalf + U2; + Z = (X - U2) * Y2; + T = Y * Y1; + Z = Z - X; + T = T - X; + X = X * Y2; + Y = (Y + U2) * Y1; + X = X - OneAndHalf; + Y = Y - OneAndHalf; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) { + X = (OneAndHalf + U2) * Y2; + Y = OneAndHalf - U2 - U2; + Z = OneAndHalf + U2 + U2; + T = (OneAndHalf - U2) * Y1; + X = X - (Z + U2); + StickyBit = Y * Y1; + S = Z * Y2; + T = T - Y; + Y = (U2 - Y) + StickyBit; + Z = S - (Z + U2 + U2); + StickyBit = (Y2 + U2) * Y1; + Y1 = Y2 * Y1; + StickyBit = StickyBit - Y2; + Y1 = Y1 - Half; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) + && ( StickyBit == Zero) && (Y1 == Half)) { + RMult = Rounded; + printf("Multiplication appears to round correctly.\n"); + } + else if ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero) + && (T < Zero) && (StickyBit + U2 == Zero) + && (Y1 < Half)) { + RMult = Chopped; + printf("Multiplication appears to chop.\n"); + } + else printf("* is neither chopped nor correctly rounded.\n"); + if ((RMult == Rounded) && (GMult == No)) notify("Multiplication"); + } + else printf("* is neither chopped nor correctly rounded.\n"); + /*=============================================*/ + Milestone = 45; + /*=============================================*/ + Y2 = One + U2; + Y1 = One - U2; + Z = OneAndHalf + U2 + U2; + X = Z / Y2; + T = OneAndHalf - U2 - U2; + Y = (T - U2) / Y1; + Z = (Z + U2) / Y2; + X = X - OneAndHalf; + Y = Y - T; + T = T / Y1; + Z = Z - (OneAndHalf + U2); + T = (U2 - OneAndHalf) + T; + if (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) { + X = OneAndHalf / Y2; + Y = OneAndHalf - U2; + Z = OneAndHalf + U2; + X = X - Y; + T = OneAndHalf / Y1; + Y = Y / Y1; + T = T - (Z + U2); + Y = Y - Z; + Z = Z / Y2; + Y1 = (Y2 + U2) / Y2; + Z = Z - OneAndHalf; + Y2 = Y1 - Y2; + Y1 = (F9 - U1) / F9; + if ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero) + && (Y2 == Zero) && (Y2 == Zero) + && (Y1 - Half == F9 - Half )) { + RDiv = Rounded; + printf("Division appears to round correctly.\n"); + if (GDiv == No) notify("Division"); + } + else if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero) + && (Y2 < Zero) && (Y1 - Half < F9 - Half)) { + RDiv = Chopped; + printf("Division appears to chop.\n"); + } + } + if (RDiv == Other) printf("/ is neither chopped nor correctly rounded.\n"); + BInvrse = One / Radix; + TstCond (Failure, (BInvrse * Radix - Half == Half), + "Radix * ( 1 / Radix ) differs from 1"); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part4(){ */ - Milestone = 50; - /*=============================================*/ - TstCond (Failure, ((F9 + U1) - Half == Half) - && ((BMinusU2 + U2 ) - One == Radix - One), - "Incomplete carry-propagation in Addition"); - X = One - U1 * U1; - Y = One + U2 * (One - U2); - Z = F9 - Half; - X = (X - Half) - Z; - Y = Y - One; - if ((X == Zero) && (Y == Zero)) { - RAddSub = Chopped; - printf("Add/Subtract appears to be chopped.\n"); - } - if (GAddSub == Yes) { - X = (Half + U2) * U2; - Y = (Half - U2) * U2; - X = One + X; - Y = One + Y; - X = (One + U2) - X; - Y = One - Y; - if ((X == Zero) && (Y == Zero)) { - X = (Half + U2) * U1; - Y = (Half - U2) * U1; - X = One - X; - Y = One - Y; - X = F9 - X; - Y = One - Y; - if ((X == Zero) && (Y == Zero)) { - RAddSub = Rounded; - printf("Addition/Subtraction appears to round correctly.\n"); - if (GAddSub == No) notify("Add/Subtract"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - } - else printf("Addition/Subtraction neither rounds nor chops.\n"); - S = One; - X = One + Half * (One + Half); - Y = (One + U2) * Half; - Z = X - Y; - T = Y - X; - StickyBit = Z + T; - if (StickyBit != Zero) { - S = Zero; - BadCond(Flaw, "(X - Y) + (Y - X) is non zero!\n"); - } - StickyBit = Zero; - if ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes) - && (RMult == Rounded) && (RDiv == Rounded) - && (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) { - printf("Checking for sticky bit.\n"); - X = (Half + U1) * U2; - Y = Half * U2; - Z = One + Y; - T = One + X; - if ((Z - One <= Zero) && (T - One >= U2)) { - Z = T + Y; - Y = Z - X; - if ((Z - T >= U2) && (Y - T == Zero)) { - X = (Half + U1) * U1; - Y = Half * U1; - Z = One - Y; - T = One - X; - if ((Z - One == Zero) && (T - F9 == Zero)) { - Z = (Half - U1) * U1; - T = F9 - Z; - Q = F9 - Y; - if ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) { - Z = (One + U2) * OneAndHalf; - T = (OneAndHalf + U2) - Z + U2; - X = One + Half / Radix; - Y = One + Radix * U2; - Z = X * Y; - if (T == Zero && X + Radix * U2 - Z == Zero) { - if (Radix != Two) { - X = Two + U2; - Y = X / Two; - if ((Y - One == Zero)) StickyBit = S; - } - else StickyBit = S; - } - } - } - } - } - } - if (StickyBit == One) printf("Sticky bit apparently used correctly.\n"); - else printf("Sticky bit used incorrectly or not at all.\n"); - TstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No || - RMult == Other || RDiv == Other || RAddSub == Other), - "lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below"); - /*=============================================*/ - Milestone = 60; - /*=============================================*/ - printf("\n"); - printf("Does Multiplication commute? "); - printf("Testing on %d random pairs.\n", NoTrials); - Random9 = SQRT(3.0); - Random1 = Third; - I = 1; - do { - X = Random(); - Y = Random(); - Z9 = Y * X; - Z = X * Y; - Z9 = Z - Z9; - I = I + 1; - } while ( ! ((I > NoTrials) || (Z9 != Zero))); - if (I == NoTrials) { - Random1 = One + Half / Three; - Random2 = (U2 + U1) + One; - Z = Random1 * Random2; - Y = Random2 * Random1; - Z9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half / - Three) * ((U2 + U1) + One); - } - if (! ((I == NoTrials) || (Z9 == Zero))) - BadCond(Defect, "X * Y == Y * X trial fails.\n"); - else printf(" No failures found in %d integer pairs.\n", NoTrials); - /*=============================================*/ - Milestone = 70; - /*=============================================*/ - printf("\nRunning test of square root(x).\n"); - TstCond (Failure, (Zero == SQRT(Zero)) - && (- Zero == SQRT(- Zero)) - && (One == SQRT(One)), "Square root of 0.0, -0.0 or 1.0 wrong"); - MinSqEr = Zero; - MaxSqEr = Zero; - J = Zero; - X = Radix; - OneUlp = U2; - SqXMinX (Serious); - X = BInvrse; - OneUlp = BInvrse * U1; - SqXMinX (Serious); - X = U1; - OneUlp = U1 * U1; - SqXMinX (Serious); - if (J != Zero) Pause(); - printf("Testing if sqrt(X * X) == X for %d Integers X.\n", NoTrials); - J = Zero; - X = Two; - Y = Radix; - if ((Radix != One)) do { - X = Y; - Y = Radix * Y; - } while ( ! ((Y - X >= NoTrials))); - OneUlp = X * U2; - I = 1; - while (I <= NoTrials) { - X = X + One; - SqXMinX (Defect); - if (J > Zero) break; - I = I + 1; - } - printf("Test for sqrt monotonicity.\n"); - I = - 1; - X = BMinusU2; - Y = Radix; - Z = Radix + Radix * U2; - NotMonot = False; - Monot = False; - while ( ! (NotMonot || Monot)) { - I = I + 1; - X = SQRT(X); - Q = SQRT(Y); - Z = SQRT(Z); - if ((X > Q) || (Q > Z)) NotMonot = True; - else { - Q = FLOOR(Q + Half); - if ((I > 0) || (Radix == Q * Q)) Monot = True; - else if (I > 0) { - if (I > 1) Monot = True; - else { - Y = Y * BInvrse; - X = Y - U1; - Z = Y + U1; - } - } - else { - Y = Q; - X = Y - U2; - Z = Y + U2; - } - } - } - if (Monot) printf("sqrt has passed a test for Monotonicity.\n"); - else { - BadCond(Defect, ""); - printf("sqrt(X) is non-monotonic for X near %.7e .\n", Y); - } - /*=============================================*/ - /*SPLIT - } + Milestone = 50; + /*=============================================*/ + TstCond (Failure, ((F9 + U1) - Half == Half) + && ((BMinusU2 + U2 ) - One == Radix - One), + "Incomplete carry-propagation in Addition"); + X = One - U1 * U1; + Y = One + U2 * (One - U2); + Z = F9 - Half; + X = (X - Half) - Z; + Y = Y - One; + if ((X == Zero) && (Y == Zero)) { + RAddSub = Chopped; + printf("Add/Subtract appears to be chopped.\n"); + } + if (GAddSub == Yes) { + X = (Half + U2) * U2; + Y = (Half - U2) * U2; + X = One + X; + Y = One + Y; + X = (One + U2) - X; + Y = One - Y; + if ((X == Zero) && (Y == Zero)) { + X = (Half + U2) * U1; + Y = (Half - U2) * U1; + X = One - X; + Y = One - Y; + X = F9 - X; + Y = One - Y; + if ((X == Zero) && (Y == Zero)) { + RAddSub = Rounded; + printf("Addition/Subtraction appears to round correctly.\n"); + if (GAddSub == No) notify("Add/Subtract"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + } + else printf("Addition/Subtraction neither rounds nor chops.\n"); + S = One; + X = One + Half * (One + Half); + Y = (One + U2) * Half; + Z = X - Y; + T = Y - X; + StickyBit = Z + T; + if (StickyBit != Zero) { + S = Zero; + BadCond(Flaw, "(X - Y) + (Y - X) is non zero!\n"); + } + StickyBit = Zero; + if ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes) + && (RMult == Rounded) && (RDiv == Rounded) + && (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) { + printf("Checking for sticky bit.\n"); + X = (Half + U1) * U2; + Y = Half * U2; + Z = One + Y; + T = One + X; + if ((Z - One <= Zero) && (T - One >= U2)) { + Z = T + Y; + Y = Z - X; + if ((Z - T >= U2) && (Y - T == Zero)) { + X = (Half + U1) * U1; + Y = Half * U1; + Z = One - Y; + T = One - X; + if ((Z - One == Zero) && (T - F9 == Zero)) { + Z = (Half - U1) * U1; + T = F9 - Z; + Q = F9 - Y; + if ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) { + Z = (One + U2) * OneAndHalf; + T = (OneAndHalf + U2) - Z + U2; + X = One + Half / Radix; + Y = One + Radix * U2; + Z = X * Y; + if (T == Zero && X + Radix * U2 - Z == Zero) { + if (Radix != Two) { + X = Two + U2; + Y = X / Two; + if ((Y - One == Zero)) StickyBit = S; + } + else StickyBit = S; + } + } + } + } + } + } + if (StickyBit == One) printf("Sticky bit apparently used correctly.\n"); + else printf("Sticky bit used incorrectly or not at all.\n"); + TstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No || + RMult == Other || RDiv == Other || RAddSub == Other), + "lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below"); + /*=============================================*/ + Milestone = 60; + /*=============================================*/ + printf("\n"); + printf("Does Multiplication commute? "); + printf("Testing on %d random pairs.\n", NoTrials); + Random9 = SQRT(3.0); + Random1 = Third; + I = 1; + do { + X = Random(); + Y = Random(); + Z9 = Y * X; + Z = X * Y; + Z9 = Z - Z9; + I = I + 1; + } while ( ! ((I > NoTrials) || (Z9 != Zero))); + if (I == NoTrials) { + Random1 = One + Half / Three; + Random2 = (U2 + U1) + One; + Z = Random1 * Random2; + Y = Random2 * Random1; + Z9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half / + Three) * ((U2 + U1) + One); + } + if (! ((I == NoTrials) || (Z9 == Zero))) + BadCond(Defect, "X * Y == Y * X trial fails.\n"); + else printf(" No failures found in %d integer pairs.\n", NoTrials); + /*=============================================*/ + Milestone = 70; + /*=============================================*/ + printf("\nRunning test of square root(x).\n"); + TstCond (Failure, (Zero == SQRT(Zero)) + && (- Zero == SQRT(- Zero)) + && (One == SQRT(One)), "Square root of 0.0, -0.0 or 1.0 wrong"); + MinSqEr = Zero; + MaxSqEr = Zero; + J = Zero; + X = Radix; + OneUlp = U2; + SqXMinX (Serious); + X = BInvrse; + OneUlp = BInvrse * U1; + SqXMinX (Serious); + X = U1; + OneUlp = U1 * U1; + SqXMinX (Serious); + if (J != Zero) Pause(); + printf("Testing if sqrt(X * X) == X for %d Integers X.\n", NoTrials); + J = Zero; + X = Two; + Y = Radix; + if ((Radix != One)) do { + X = Y; + Y = Radix * Y; + } while ( ! ((Y - X >= NoTrials))); + OneUlp = X * U2; + I = 1; + while (I <= NoTrials) { + X = X + One; + SqXMinX (Defect); + if (J > Zero) break; + I = I + 1; + } + printf("Test for sqrt monotonicity.\n"); + I = - 1; + X = BMinusU2; + Y = Radix; + Z = Radix + Radix * U2; + NotMonot = False; + Monot = False; + while ( ! (NotMonot || Monot)) { + I = I + 1; + X = SQRT(X); + Q = SQRT(Y); + Z = SQRT(Z); + if ((X > Q) || (Q > Z)) NotMonot = True; + else { + Q = FLOOR(Q + Half); + if ((I > 0) || (Radix == Q * Q)) Monot = True; + else if (I > 0) { + if (I > 1) Monot = True; + else { + Y = Y * BInvrse; + X = Y - U1; + Z = Y + U1; + } + } + else { + Y = Q; + X = Y - U2; + Z = Y + U2; + } + } + } + if (Monot) printf("sqrt has passed a test for Monotonicity.\n"); + else { + BadCond(Defect, ""); + printf("sqrt(X) is non-monotonic for X near %.7e .\n", Y); + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part5(){ */ - Milestone = 80; - /*=============================================*/ - MinSqEr = MinSqEr + Half; - MaxSqEr = MaxSqEr - Half; - Y = (SQRT(One + U2) - One) / U2; - SqEr = (Y - One) + U2 / Eight; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - SqEr = Y + U2 / Eight; - if (SqEr < MinSqEr) MinSqEr = SqEr; - Y = ((SQRT(F9) - U2) - (One - U2)) / U1; - SqEr = Y + U1 / Eight; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - SqEr = (Y + One) + U1 / Eight; - if (SqEr < MinSqEr) MinSqEr = SqEr; - OneUlp = U2; - X = OneUlp; - for( Indx = 1; Indx <= 3; ++Indx) { - Y = SQRT((X + U1 + X) + F9); - Y = ((Y - U2) - ((One - U2) + X)) / OneUlp; - Z = ((U1 - X) + F9) * Half * X * X / OneUlp; - SqEr = (Y + Half) + Z; - if (SqEr < MinSqEr) MinSqEr = SqEr; - SqEr = (Y - Half) + Z; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - if (((Indx == 1) || (Indx == 3))) - X = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp))); - else { - OneUlp = U1; - X = - OneUlp; - } - } - /*=============================================*/ - Milestone = 85; - /*=============================================*/ - SqRWrng = False; - Anomaly = False; - RSqrt = Other; /* ~dgh */ - if (Radix != One) { - printf("Testing whether sqrt is rounded or chopped.\n"); - D = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision))); - /* ... == Radix^(1 + fract) if (Precision == Integer + fract. */ - X = D / Radix; - Y = D / A1; - if ((X != FLOOR(X)) || (Y != FLOOR(Y))) { - Anomaly = True; - } - else { - X = Zero; - Z2 = X; - Y = One; - Y2 = Y; - Z1 = Radix - One; - FourD = Four * D; - do { - if (Y2 > Z2) { - Q = Radix; - Y1 = Y; - do { - X1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1); - Q = Y1; - Y1 = X1; - } while ( ! (X1 <= Zero)); - if (Q <= One) { - Z2 = Y2; - Z = Y; - } - } - Y = Y + Two; - X = X + Eight; - Y2 = Y2 + X; - if (Y2 >= FourD) Y2 = Y2 - FourD; - } while ( ! (Y >= D)); - X8 = FourD - Z2; - Q = (X8 + Z * Z) / FourD; - X8 = X8 / Eight; - if (Q != FLOOR(Q)) Anomaly = True; - else { - Break = False; - do { - X = Z1 * Z; - X = X - FLOOR(X / Radix) * Radix; - if (X == One) - Break = True; - else - Z1 = Z1 - One; - } while ( ! (Break || (Z1 <= Zero))); - if ((Z1 <= Zero) && (! Break)) Anomaly = True; - else { - if (Z1 > RadixD2) Z1 = Z1 - Radix; - do { - NewD(); - } while ( ! (U2 * D >= F9)); - if (D * Radix - D != W - D) Anomaly = True; - else { - Z2 = D; - I = 0; - Y = D + (One + Z) * Half; - X = D + Z + Q; - SR3750(); - Y = D + (One - Z) * Half + D; - X = D - Z + D; - X = X + Q + X; - SR3750(); - NewD(); - if (D - Z2 != W - Z2) Anomaly = True; - else { - Y = (D - Z2) + (Z2 + (One - Z) * Half); - X = (D - Z2) + (Z2 - Z + Q); - SR3750(); - Y = (One + Z) * Half; - X = Q; - SR3750(); - if (I == 0) Anomaly = True; - } - } - } - } - } - if ((I == 0) || Anomaly) { - BadCond(Failure, "Anomalous arithmetic with Integer < "); - printf("Radix^Precision = %.7e\n", W); - printf(" fails test whether sqrt rounds or chops.\n"); - SqRWrng = True; - } - } - if (! Anomaly) { - if (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) { - RSqrt = Rounded; - printf("Square root appears to be correctly rounded.\n"); - } - else { - if ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half) - || (MinSqEr + Radix < Half)) SqRWrng = True; - else { - RSqrt = Chopped; - printf("Square root appears to be chopped.\n"); - } - } - } - if (SqRWrng) { - printf("Square root is neither chopped nor correctly rounded.\n"); - printf("Observed errors run from %.7e ", MinSqEr - Half); - printf("to %.7e ulps.\n", Half + MaxSqEr); - TstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix, - "sqrt gets too many last digits wrong"); - } - /*=============================================*/ - Milestone = 90; - /*=============================================*/ - Pause(); - printf("Testing powers Z^i for small Integers Z and i.\n"); - N = 0; - /* ... test powers of zero. */ - I = 0; - Z = -Zero; - M = 3.0; - Break = False; - do { - X = One; - SR3980(); - if (I <= 10) { - I = 1023; - SR3980(); - } - if (Z == MinusOne) Break = True; - else { - Z = MinusOne; - PrintIfNPositive(); - N = 0; - /* .. if(-1)^N is invalid, replace MinusOne by One. */ - I = - 4; - } - } while ( ! Break); - PrintIfNPositive(); - N1 = N; - N = 0; - Z = A1; - M = FLOOR(Two * LOG(W) / LOG(A1)); - Break = False; - do { - X = Z; - I = 1; - SR3980(); - if (Z == AInvrse) Break = True; - else Z = AInvrse; - } while ( ! (Break)); - /*=============================================*/ - Milestone = 100; - /*=============================================*/ - /* Powers of Radix have been tested, */ - /* next try a few primes */ - M = NoTrials; - Z = Three; - do { - X = Z; - I = 1; - SR3980(); - do { - Z = Z + Two; - } while ( Three * FLOOR(Z / Three) == Z ); - } while ( Z < Eight * Three ); - if (N > 0) { - printf("Errors like this may invalidate financial calculations\n"); - printf("\tinvolving interest rates.\n"); - } - PrintIfNPositive(); - N += N1; - if (N == 0) printf("... no discrepancis found.\n"); - if (N > 0) Pause(); - else printf("\n"); - /*=============================================*/ - /*SPLIT - } + Milestone = 80; + /*=============================================*/ + MinSqEr = MinSqEr + Half; + MaxSqEr = MaxSqEr - Half; + Y = (SQRT(One + U2) - One) / U2; + SqEr = (Y - One) + U2 / Eight; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + SqEr = Y + U2 / Eight; + if (SqEr < MinSqEr) MinSqEr = SqEr; + Y = ((SQRT(F9) - U2) - (One - U2)) / U1; + SqEr = Y + U1 / Eight; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + SqEr = (Y + One) + U1 / Eight; + if (SqEr < MinSqEr) MinSqEr = SqEr; + OneUlp = U2; + X = OneUlp; + for( Indx = 1; Indx <= 3; ++Indx) { + Y = SQRT((X + U1 + X) + F9); + Y = ((Y - U2) - ((One - U2) + X)) / OneUlp; + Z = ((U1 - X) + F9) * Half * X * X / OneUlp; + SqEr = (Y + Half) + Z; + if (SqEr < MinSqEr) MinSqEr = SqEr; + SqEr = (Y - Half) + Z; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + if (((Indx == 1) || (Indx == 3))) + X = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp))); + else { + OneUlp = U1; + X = - OneUlp; + } + } + /*=============================================*/ + Milestone = 85; + /*=============================================*/ + SqRWrng = False; + Anomaly = False; + RSqrt = Other; /* ~dgh */ + if (Radix != One) { + printf("Testing whether sqrt is rounded or chopped.\n"); + D = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision))); + /* ... == Radix^(1 + fract) if (Precision == Integer + fract. */ + X = D / Radix; + Y = D / A1; + if ((X != FLOOR(X)) || (Y != FLOOR(Y))) { + Anomaly = True; + } + else { + X = Zero; + Z2 = X; + Y = One; + Y2 = Y; + Z1 = Radix - One; + FourD = Four * D; + do { + if (Y2 > Z2) { + Q = Radix; + Y1 = Y; + do { + X1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1); + Q = Y1; + Y1 = X1; + } while ( ! (X1 <= Zero)); + if (Q <= One) { + Z2 = Y2; + Z = Y; + } + } + Y = Y + Two; + X = X + Eight; + Y2 = Y2 + X; + if (Y2 >= FourD) Y2 = Y2 - FourD; + } while ( ! (Y >= D)); + X8 = FourD - Z2; + Q = (X8 + Z * Z) / FourD; + X8 = X8 / Eight; + if (Q != FLOOR(Q)) Anomaly = True; + else { + Break = False; + do { + X = Z1 * Z; + X = X - FLOOR(X / Radix) * Radix; + if (X == One) + Break = True; + else + Z1 = Z1 - One; + } while ( ! (Break || (Z1 <= Zero))); + if ((Z1 <= Zero) && (! Break)) Anomaly = True; + else { + if (Z1 > RadixD2) Z1 = Z1 - Radix; + do { + NewD(); + } while ( ! (U2 * D >= F9)); + if (D * Radix - D != W - D) Anomaly = True; + else { + Z2 = D; + I = 0; + Y = D + (One + Z) * Half; + X = D + Z + Q; + SR3750(); + Y = D + (One - Z) * Half + D; + X = D - Z + D; + X = X + Q + X; + SR3750(); + NewD(); + if (D - Z2 != W - Z2) Anomaly = True; + else { + Y = (D - Z2) + (Z2 + (One - Z) * Half); + X = (D - Z2) + (Z2 - Z + Q); + SR3750(); + Y = (One + Z) * Half; + X = Q; + SR3750(); + if (I == 0) Anomaly = True; + } + } + } + } + } + if ((I == 0) || Anomaly) { + BadCond(Failure, "Anomalous arithmetic with Integer < "); + printf("Radix^Precision = %.7e\n", W); + printf(" fails test whether sqrt rounds or chops.\n"); + SqRWrng = True; + } + } + if (! Anomaly) { + if (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) { + RSqrt = Rounded; + printf("Square root appears to be correctly rounded.\n"); + } + else { + if ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half) + || (MinSqEr + Radix < Half)) SqRWrng = True; + else { + RSqrt = Chopped; + printf("Square root appears to be chopped.\n"); + } + } + } + if (SqRWrng) { + printf("Square root is neither chopped nor correctly rounded.\n"); + printf("Observed errors run from %.7e ", MinSqEr - Half); + printf("to %.7e ulps.\n", Half + MaxSqEr); + TstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix, + "sqrt gets too many last digits wrong"); + } + /*=============================================*/ + Milestone = 90; + /*=============================================*/ + Pause(); + printf("Testing powers Z^i for small Integers Z and i.\n"); + N = 0; + /* ... test powers of zero. */ + I = 0; + Z = -Zero; + M = 3.0; + Break = False; + do { + X = One; + SR3980(); + if (I <= 10) { + I = 1023; + SR3980(); + } + if (Z == MinusOne) Break = True; + else { + Z = MinusOne; + PrintIfNPositive(); + N = 0; + /* .. if(-1)^N is invalid, replace MinusOne by One. */ + I = - 4; + } + } while ( ! Break); + PrintIfNPositive(); + N1 = N; + N = 0; + Z = A1; + M = FLOOR(Two * LOG(W) / LOG(A1)); + Break = False; + do { + X = Z; + I = 1; + SR3980(); + if (Z == AInvrse) Break = True; + else Z = AInvrse; + } while ( ! (Break)); + /*=============================================*/ + Milestone = 100; + /*=============================================*/ + /* Powers of Radix have been tested, */ + /* next try a few primes */ + M = NoTrials; + Z = Three; + do { + X = Z; + I = 1; + SR3980(); + do { + Z = Z + Two; + } while ( Three * FLOOR(Z / Three) == Z ); + } while ( Z < Eight * Three ); + if (N > 0) { + printf("Errors like this may invalidate financial calculations\n"); + printf("\tinvolving interest rates.\n"); + } + PrintIfNPositive(); + N += N1; + if (N == 0) printf("... no discrepancis found.\n"); + if (N > 0) Pause(); + else printf("\n"); + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part6(){ */ - Milestone = 110; - /*=============================================*/ - printf("Seeking Underflow thresholds UfThold and E0.\n"); - D = U1; - if (Precision != FLOOR(Precision)) { - D = BInvrse; - X = Precision; - do { - D = D * BInvrse; - X = X - One; - } while ( X > Zero); - } - Y = One; - Z = D; - /* ... D is power of 1/Radix < 1. */ - do { - C = Y; - Y = Z; - Z = Y * Y; - } while ((Y > Z) && (Z + Z > Z)); - Y = C; - Z = Y * D; - do { - C = Y; - Y = Z; - Z = Y * D; - } while ((Y > Z) && (Z + Z > Z)); - if (Radix < Two) HInvrse = Two; - else HInvrse = Radix; - H = One / HInvrse; - /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */ - CInvrse = One / C; - E0 = C; - Z = E0 * H; - /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ - do { - Y = E0; - E0 = Z; - Z = E0 * H; - } while ((E0 > Z) && (Z + Z > Z)); - UfThold = E0; - E1 = Zero; - Q = Zero; - E9 = U2; - S = One + E9; - D = C * S; - if (D <= C) { - E9 = Radix * U2; - S = One + E9; - D = C * S; - if (D <= C) { - BadCond(Failure, "multiplication gets too many last digits wrong.\n"); - Underflow = E0; - Y1 = Zero; - PseudoZero = Z; - Pause(); - } - } - else { - Underflow = D; - PseudoZero = Underflow * H; - UfThold = Zero; - do { - Y1 = Underflow; - Underflow = PseudoZero; - if (E1 + E1 <= E1) { - Y2 = Underflow * HInvrse; - E1 = FABS(Y1 - Y2); - Q = Y1; - if ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1; - } - PseudoZero = PseudoZero * H; - } while ((Underflow > PseudoZero) - && (PseudoZero + PseudoZero > PseudoZero)); - } - /* Comment line 4530 .. 4560 */ - if (PseudoZero != Zero) { - printf("\n"); - Z = PseudoZero; - /* ... Test PseudoZero for "phoney- zero" violates */ - /* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero - ... */ - if (PseudoZero <= Zero) { - BadCond(Failure, "Positive expressions can underflow to an\n"); - printf("allegedly negative value\n"); - printf("PseudoZero that prints out as: %g .\n", PseudoZero); - X = - PseudoZero; - if (X <= Zero) { - printf("But -PseudoZero, which should be\n"); - printf("positive, isn't; it prints out as %g .\n", X); - } - } - else { - BadCond(Flaw, "Underflow can stick at an allegedly positive\n"); - printf("value PseudoZero that prints out as %g .\n", PseudoZero); - } - TstPtUf(); - } - /*=============================================*/ - Milestone = 120; - /*=============================================*/ - if (CInvrse * Y > CInvrse * Y1) { - S = H * S; - E0 = Underflow; - } - if (! ((E1 == Zero) || (E1 == E0))) { - BadCond(Defect, ""); - if (E1 < E0) { - printf("Products underflow at a higher"); - printf(" threshold than differences.\n"); - if (PseudoZero == Zero) - E0 = E1; - } - else { - printf("Difference underflows at a higher"); - printf(" threshold than products.\n"); - } - } - printf("Smallest strictly positive number found is E0 = %g .\n", E0); - Z = E0; - TstPtUf(); - Underflow = E0; - if (N == 1) Underflow = Y; - I = 4; - if (E1 == Zero) I = 3; - if (UfThold == Zero) I = I - 2; - UfNGrad = True; - switch (I) { - case 1: - UfThold = Underflow; - if ((CInvrse * Q) != ((CInvrse * Y) * S)) { - UfThold = Y; - BadCond(Failure, "Either accuracy deteriorates as numbers\n"); - printf("approach a threshold = %.17e\n", UfThold);; - printf(" coming down from %.17e\n", C); - printf(" or else multiplication gets too many last digits wrong.\n"); - } - Pause(); - break; + Milestone = 110; + /*=============================================*/ + printf("Seeking Underflow thresholds UfThold and E0.\n"); + D = U1; + if (Precision != FLOOR(Precision)) { + D = BInvrse; + X = Precision; + do { + D = D * BInvrse; + X = X - One; + } while ( X > Zero); + } + Y = One; + Z = D; + /* ... D is power of 1/Radix < 1. */ + do { + C = Y; + Y = Z; + Z = Y * Y; + } while ((Y > Z) && (Z + Z > Z)); + Y = C; + Z = Y * D; + do { + C = Y; + Y = Z; + Z = Y * D; + } while ((Y > Z) && (Z + Z > Z)); + if (Radix < Two) HInvrse = Two; + else HInvrse = Radix; + H = One / HInvrse; + /* ... 1/HInvrse == H == Min(1/Radix, 1/2) */ + CInvrse = One / C; + E0 = C; + Z = E0 * H; + /* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */ + do { + Y = E0; + E0 = Z; + Z = E0 * H; + } while ((E0 > Z) && (Z + Z > Z)); + UfThold = E0; + E1 = Zero; + Q = Zero; + E9 = U2; + S = One + E9; + D = C * S; + if (D <= C) { + E9 = Radix * U2; + S = One + E9; + D = C * S; + if (D <= C) { + BadCond(Failure, "multiplication gets too many last digits wrong.\n"); + Underflow = E0; + Y1 = Zero; + PseudoZero = Z; + Pause(); + } + } + else { + Underflow = D; + PseudoZero = Underflow * H; + UfThold = Zero; + do { + Y1 = Underflow; + Underflow = PseudoZero; + if (E1 + E1 <= E1) { + Y2 = Underflow * HInvrse; + E1 = FABS(Y1 - Y2); + Q = Y1; + if ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1; + } + PseudoZero = PseudoZero * H; + } while ((Underflow > PseudoZero) + && (PseudoZero + PseudoZero > PseudoZero)); + } + /* Comment line 4530 .. 4560 */ + if (PseudoZero != Zero) { + printf("\n"); + Z = PseudoZero; + /* ... Test PseudoZero for "phoney- zero" violates */ + /* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero + ... */ + if (PseudoZero <= Zero) { + BadCond(Failure, "Positive expressions can underflow to an\n"); + printf("allegedly negative value\n"); + printf("PseudoZero that prints out as: %g .\n", PseudoZero); + X = - PseudoZero; + if (X <= Zero) { + printf("But -PseudoZero, which should be\n"); + printf("positive, isn't; it prints out as %g .\n", X); + } + } + else { + BadCond(Flaw, "Underflow can stick at an allegedly positive\n"); + printf("value PseudoZero that prints out as %g .\n", PseudoZero); + } + TstPtUf(); + } + /*=============================================*/ + Milestone = 120; + /*=============================================*/ + if (CInvrse * Y > CInvrse * Y1) { + S = H * S; + E0 = Underflow; + } + if (! ((E1 == Zero) || (E1 == E0))) { + BadCond(Defect, ""); + if (E1 < E0) { + printf("Products underflow at a higher"); + printf(" threshold than differences.\n"); + if (PseudoZero == Zero) + E0 = E1; + } + else { + printf("Difference underflows at a higher"); + printf(" threshold than products.\n"); + } + } + printf("Smallest strictly positive number found is E0 = %g .\n", E0); + Z = E0; + TstPtUf(); + Underflow = E0; + if (N == 1) Underflow = Y; + I = 4; + if (E1 == Zero) I = 3; + if (UfThold == Zero) I = I - 2; + UfNGrad = True; + switch (I) { + case 1: + UfThold = Underflow; + if ((CInvrse * Q) != ((CInvrse * Y) * S)) { + UfThold = Y; + BadCond(Failure, "Either accuracy deteriorates as numbers\n"); + printf("approach a threshold = %.17e\n", UfThold);; + printf(" coming down from %.17e\n", C); + printf(" or else multiplication gets too many last digits wrong.\n"); + } + Pause(); + break; - case 2: - BadCond(Failure, "Underflow confuses Comparison, which alleges that\n"); - printf("Q == Y while denying that |Q - Y| == 0; these values\n"); - printf("print out as Q = %.17e, Y = %.17e .\n", Q, Y2); - printf ("|Q - Y| = %.17e .\n" , FABS(Q - Y2)); - UfThold = Q; - break; + case 2: + BadCond(Failure, "Underflow confuses Comparison, which alleges that\n"); + printf("Q == Y while denying that |Q - Y| == 0; these values\n"); + printf("print out as Q = %.17e, Y = %.17e .\n", Q, Y2); + printf ("|Q - Y| = %.17e .\n" , FABS(Q - Y2)); + UfThold = Q; + break; - case 3: - X = X; - break; + case 3: + X = X; + break; - case 4: - if ((Q == UfThold) && (E1 == E0) - && (FABS( UfThold - E1 / E9) <= E1)) { - UfNGrad = False; - printf("Underflow is gradual; it incurs Absolute Error =\n"); - printf("(roundoff in UfThold) < E0.\n"); - Y = E0 * CInvrse; - Y = Y * (OneAndHalf + U2); - X = CInvrse * (One + U2); - Y = Y / X; - IEEE = (Y == E0); - } - } - if (UfNGrad) { - printf("\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) { - printf("Underflow / UfThold failed!\n"); - R = H + H; - } - else R = SQRT(Underflow / UfThold); - sigsave = 0; - if (R <= H) { - Z = R * UfThold; - X = Z * (One + R * H * (One + H)); - } - else { - Z = UfThold; - X = Z * (One + H * H * (One + H)); - } - if (! ((X == Z) || (X - Z != Zero))) { - BadCond(Flaw, ""); - printf("X = %.17e\n\tis not equal to Z = %.17e .\n", X, Z); - Z9 = X - Z; - printf("yet X - Z yields %.17e .\n", Z9); - printf(" Should this NOT signal Underflow, "); - printf("this is a SERIOUS DEFECT\nthat causes "); - printf("confusion when innocent statements like\n");; - printf(" if (X == Z) ... else"); - printf(" ... (f(X) - f(Z)) / (X - Z) ...\n"); - printf("encounter Division by Zero although actually\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) printf("X / Z fails!\n"); - else printf("X / Z = 1 + %g .\n", (X / Z - Half) - Half); - sigsave = 0; - } - } - printf("The Underflow threshold is %.17e, %s\n", UfThold, - " below which"); - printf("calculation may suffer larger Relative error than "); - printf("merely roundoff.\n"); - Y2 = U1 * U1; - Y = Y2 * Y2; - Y2 = Y * U1; - if (Y2 <= UfThold) { - if (Y > E0) { - BadCond(Defect, ""); - I = 5; - } - else { - BadCond(Serious, ""); - I = 4; - } - printf("Range is too narrow; U1^%d Underflows.\n", I); - } - /*=============================================*/ - /*SPLIT - } + case 4: + if ((Q == UfThold) && (E1 == E0) + && (FABS( UfThold - E1 / E9) <= E1)) { + UfNGrad = False; + printf("Underflow is gradual; it incurs Absolute Error =\n"); + printf("(roundoff in UfThold) < E0.\n"); + Y = E0 * CInvrse; + Y = Y * (OneAndHalf + U2); + X = CInvrse * (One + U2); + Y = Y / X; + IEEE = (Y == E0); + } + } + if (UfNGrad) { + printf("\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) { + printf("Underflow / UfThold failed!\n"); + R = H + H; + } + else R = SQRT(Underflow / UfThold); + sigsave = 0; + if (R <= H) { + Z = R * UfThold; + X = Z * (One + R * H * (One + H)); + } + else { + Z = UfThold; + X = Z * (One + H * H * (One + H)); + } + if (! ((X == Z) || (X - Z != Zero))) { + BadCond(Flaw, ""); + printf("X = %.17e\n\tis not equal to Z = %.17e .\n", X, Z); + Z9 = X - Z; + printf("yet X - Z yields %.17e .\n", Z9); + printf(" Should this NOT signal Underflow, "); + printf("this is a SERIOUS DEFECT\nthat causes "); + printf("confusion when innocent statements like\n");; + printf(" if (X == Z) ... else"); + printf(" ... (f(X) - f(Z)) / (X - Z) ...\n"); + printf("encounter Division by Zero although actually\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) printf("X / Z fails!\n"); + else printf("X / Z = 1 + %g .\n", (X / Z - Half) - Half); + sigsave = 0; + } + } + printf("The Underflow threshold is %.17e, %s\n", UfThold, + " below which"); + printf("calculation may suffer larger Relative error than "); + printf("merely roundoff.\n"); + Y2 = U1 * U1; + Y = Y2 * Y2; + Y2 = Y * U1; + if (Y2 <= UfThold) { + if (Y > E0) { + BadCond(Defect, ""); + I = 5; + } + else { + BadCond(Serious, ""); + I = 4; + } + printf("Range is too narrow; U1^%d Underflows.\n", I); + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part7(){ */ - Milestone = 130; - /*=============================================*/ - Y = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty; - Y2 = Y + Y; - printf("Since underflow occurs below the threshold\n"); - printf("UfThold = (%.17e) ^ (%.17e)\nonly underflow ", HInvrse, Y); - printf("should afflict the expression\n\t(%.17e) ^ (%.17e);\n", HInvrse, Y); - V9 = POW(HInvrse, Y2); - printf("actually calculating yields: %.17e .\n", V9); - if (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) { - BadCond(Serious, "this is not between 0 and underflow\n"); - printf(" threshold = %.17e .\n", UfThold); - } - else if (! (V9 > UfThold * (One + E9))) - printf("This computed value is O.K.\n"); - else { - BadCond(Defect, "this is not between 0 and underflow\n"); - printf(" threshold = %.17e .\n", UfThold); - } - /*=============================================*/ - Milestone = 140; - /*=============================================*/ - printf("\n"); - /* ...calculate Exp2 == exp(2) == 7.389056099... */ - X = Zero; - I = 2; - Y = Two * Three; - Q = Zero; - N = 0; - do { - Z = X; - I = I + 1; - Y = Y / (I + I); - R = Y + Q; - X = Z + R; - Q = (Z - X) + R; - } while(X > Z); - Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo); - X = Z * Z; - Exp2 = X * X; - X = F9; - Y = X - U1; - printf("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n", - Exp2); - for(I = 1;;) { - Z = X - BInvrse; - Z = (X + One) / (Z - (One - BInvrse)); - Q = POW(X, Z) - Exp2; - if (FABS(Q) > TwoForty * U2) { - N = 1; - V9 = (X - BInvrse) - (One - BInvrse); - BadCond(Defect, "Calculated"); - printf(" %.17e for\n", POW(X,Z)); - printf("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z); - printf("\tdiffers from correct value by %.17e .\n", Q); - printf("\tThis much error may spoil financial\n"); - printf("\tcalculations involving tiny interest rates.\n"); - break; - } - else { - Z = (Y - X) * Two + Y; - X = Y; - Y = Z; - Z = One + (X - F9)*(X - F9); - if (Z > One && I < NoTrials) I++; - else { - if (X > One) { - if (N == 0) - printf("Accuracy seems adequate.\n"); - break; - } - else { - X = One + U2; - Y = U2 + U2; - Y += X; - I = 1; - } - } - } - } - /*=============================================*/ - Milestone = 150; - /*=============================================*/ - printf("Testing powers Z^Q at four nearly extreme values.\n"); - N = 0; - Z = A1; - Q = FLOOR(Half - LOG(C) / LOG(A1)); - Break = False; - do { - X = CInvrse; - Y = POW(Z, Q); - IsYeqX(); - Q = - Q; - X = C; - Y = POW(Z, Q); - IsYeqX(); - if (Z < One) Break = True; - else Z = AInvrse; - } while ( ! (Break)); - PrintIfNPositive(); - if (N == 0) printf(" ... no discrepancies found.\n"); - printf("\n"); + Milestone = 130; + /*=============================================*/ + Y = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty; + Y2 = Y + Y; + printf("Since underflow occurs below the threshold\n"); + printf("UfThold = (%.17e) ^ (%.17e)\nonly underflow ", HInvrse, Y); + printf("should afflict the expression\n\t(%.17e) ^ (%.17e);\n", HInvrse, Y); + V9 = POW(HInvrse, Y2); + printf("actually calculating yields: %.17e .\n", V9); + if (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) { + BadCond(Serious, "this is not between 0 and underflow\n"); + printf(" threshold = %.17e .\n", UfThold); + } + else if (! (V9 > UfThold * (One + E9))) + printf("This computed value is O.K.\n"); + else { + BadCond(Defect, "this is not between 0 and underflow\n"); + printf(" threshold = %.17e .\n", UfThold); + } + /*=============================================*/ + Milestone = 140; + /*=============================================*/ + printf("\n"); + /* ...calculate Exp2 == exp(2) == 7.389056099... */ + X = Zero; + I = 2; + Y = Two * Three; + Q = Zero; + N = 0; + do { + Z = X; + I = I + 1; + Y = Y / (I + I); + R = Y + Q; + X = Z + R; + Q = (Z - X) + R; + } while(X > Z); + Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo); + X = Z * Z; + Exp2 = X * X; + X = F9; + Y = X - U1; + printf("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n", + Exp2); + for(I = 1;;) { + Z = X - BInvrse; + Z = (X + One) / (Z - (One - BInvrse)); + Q = POW(X, Z) - Exp2; + if (FABS(Q) > TwoForty * U2) { + N = 1; + V9 = (X - BInvrse) - (One - BInvrse); + BadCond(Defect, "Calculated"); + printf(" %.17e for\n", POW(X,Z)); + printf("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z); + printf("\tdiffers from correct value by %.17e .\n", Q); + printf("\tThis much error may spoil financial\n"); + printf("\tcalculations involving tiny interest rates.\n"); + break; + } + else { + Z = (Y - X) * Two + Y; + X = Y; + Y = Z; + Z = One + (X - F9)*(X - F9); + if (Z > One && I < NoTrials) I++; + else { + if (X > One) { + if (N == 0) + printf("Accuracy seems adequate.\n"); + break; + } + else { + X = One + U2; + Y = U2 + U2; + Y += X; + I = 1; + } + } + } + } + /*=============================================*/ + Milestone = 150; + /*=============================================*/ + printf("Testing powers Z^Q at four nearly extreme values.\n"); + N = 0; + Z = A1; + Q = FLOOR(Half - LOG(C) / LOG(A1)); + Break = False; + do { + X = CInvrse; + Y = POW(Z, Q); + IsYeqX(); + Q = - Q; + X = C; + Y = POW(Z, Q); + IsYeqX(); + if (Z < One) Break = True; + else Z = AInvrse; + } while ( ! (Break)); + PrintIfNPositive(); + if (N == 0) printf(" ... no discrepancies found.\n"); + printf("\n"); - /*=============================================*/ - Milestone = 160; - /*=============================================*/ - Pause(); - printf("Searching for Overflow threshold:\n"); - printf("This may generate an error.\n"); - Y = - CInvrse; - V9 = HInvrse * Y; - sigsave = sigfpe; - if (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; } - do { - V = Y; - Y = V9; - V9 = HInvrse * Y; - } while(V9 < Y); - I = 1; + /*=============================================*/ + Milestone = 160; + /*=============================================*/ + Pause(); + printf("Searching for Overflow threshold:\n"); + printf("This may generate an error.\n"); + Y = - CInvrse; + V9 = HInvrse * Y; + sigsave = sigfpe; + if (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; } + do { + V = Y; + Y = V9; + V9 = HInvrse * Y; + } while(V9 < Y); + I = 1; overflow: - sigsave = 0; - Z = V9; - printf("Can `Z = -Y' overflow?\n"); - printf("Trying it on Y = %.17e .\n", Y); - V9 = - Y; - V0 = V9; - if (V - Y == V + V0) printf("Seems O.K.\n"); - else { - printf("finds a "); - BadCond(Flaw, "-(-Y) differs from Y.\n"); - } - if (Z != Y) { - BadCond(Serious, ""); - printf("overflow past %.17e\n\tshrinks to %.17e .\n", Y, Z); - } - if (I) { - Y = V * (HInvrse * U2 - HInvrse); - Z = Y + ((One - HInvrse) * U2) * V; - if (Z < V0) Y = Z; - if (Y < V0) V = Y; - if (V0 - V < V0) V = V0; - } - else { - V = Y * (HInvrse * U2 - HInvrse); - V = V + ((One - HInvrse) * U2) * Y; - } - printf("Overflow threshold is V = %.17e .\n", V); - if (I) printf("Overflow saturates at V0 = %.17e .\n", V0); - else printf("There is no saturation value because the system traps on overflow.\n"); - V9 = V * One; - printf("No Overflow should be signaled for V * 1 = %.17e\n", V9); - V9 = V / One; - printf(" nor for V / 1 = %.17e .\n", V9); - printf("Any overflow signal separating this * from the one\n"); - printf("above is a DEFECT.\n"); - /*=============================================*/ - Milestone = 170; - /*=============================================*/ - if (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) { - BadCond(Failure, "Comparisons involving "); - printf("+-%g, +-%g\nand +-%g are confused by Overflow.", - V, V0, UfThold); - } - /*=============================================*/ - Milestone = 175; - /*=============================================*/ - printf("\n"); - for(Indx = 1; Indx <= 3; ++Indx) { - switch (Indx) { - case 1: Z = UfThold; break; - case 2: Z = E0; break; - case 3: Z = PseudoZero; break; - } - if (Z != Zero) { - V9 = SQRT(Z); - Y = V9 * V9; - if (Y / (One - Radix * E9) < Z - || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */ - if (V9 > U1) BadCond(Serious, ""); - else BadCond(Defect, ""); - printf("Comparison alleges that what prints as Z = %.17e\n", Z); - printf(" is too far from sqrt(Z) ^ 2 = %.17e .\n", Y); - } - } - } - /*=============================================*/ - Milestone = 180; - /*=============================================*/ - for(Indx = 1; Indx <= 2; ++Indx) { - if (Indx == 1) Z = V; - else Z = V0; - V9 = SQRT(Z); - X = (One - Radix * E9) * V9; - V9 = V9 * X; - if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { - Y = V9; - if (X < W) BadCond(Serious, ""); - else BadCond(Defect, ""); - printf("Comparison alleges that Z = %17e\n", Z); - printf(" is too far from sqrt(Z) ^ 2 (%.17e) .\n", Y); - } - } - /*=============================================*/ - /*SPLIT - } + sigsave = 0; + Z = V9; + printf("Can 'Z = -Y' overflow?\n"); + printf("Trying it on Y = %.17e .\n", Y); + V9 = - Y; + V0 = V9; + if (V - Y == V + V0) printf("Seems O.K.\n"); + else { + printf("finds a "); + BadCond(Flaw, "-(-Y) differs from Y.\n"); + } + if (Z != Y) { + BadCond(Serious, ""); + printf("overflow past %.17e\n\tshrinks to %.17e .\n", Y, Z); + } + if (I) { + Y = V * (HInvrse * U2 - HInvrse); + Z = Y + ((One - HInvrse) * U2) * V; + if (Z < V0) Y = Z; + if (Y < V0) V = Y; + if (V0 - V < V0) V = V0; + } + else { + V = Y * (HInvrse * U2 - HInvrse); + V = V + ((One - HInvrse) * U2) * Y; + } + printf("Overflow threshold is V = %.17e .\n", V); + if (I) printf("Overflow saturates at V0 = %.17e .\n", V0); + else printf("There is no saturation value because the system traps on overflow.\n"); + V9 = V * One; + printf("No Overflow should be signaled for V * 1 = %.17e\n", V9); + V9 = V / One; + printf(" nor for V / 1 = %.17e .\n", V9); + printf("Any overflow signal separating this * from the one\n"); + printf("above is a DEFECT.\n"); + /*=============================================*/ + Milestone = 170; + /*=============================================*/ + if (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) { + BadCond(Failure, "Comparisons involving "); + printf("+-%g, +-%g\nand +-%g are confused by Overflow.", + V, V0, UfThold); + } + /*=============================================*/ + Milestone = 175; + /*=============================================*/ + printf("\n"); + for(Indx = 1; Indx <= 3; ++Indx) { + switch (Indx) { + case 1: Z = UfThold; break; + case 2: Z = E0; break; + case 3: Z = PseudoZero; break; + } + if (Z != Zero) { + V9 = SQRT(Z); + Y = V9 * V9; + if (Y / (One - Radix * E9) < Z + || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */ + if (V9 > U1) BadCond(Serious, ""); + else BadCond(Defect, ""); + printf("Comparison alleges that what prints as Z = %.17e\n", Z); + printf(" is too far from sqrt(Z) ^ 2 = %.17e .\n", Y); + } + } + } + /*=============================================*/ + Milestone = 180; + /*=============================================*/ + for(Indx = 1; Indx <= 2; ++Indx) { + if (Indx == 1) Z = V; + else Z = V0; + V9 = SQRT(Z); + X = (One - Radix * E9) * V9; + V9 = V9 * X; + if (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) { + Y = V9; + if (X < W) BadCond(Serious, ""); + else BadCond(Defect, ""); + printf("Comparison alleges that Z = %17e\n", Z); + printf(" is too far from sqrt(Z) ^ 2 (%.17e) .\n", Y); + } + } + /*=============================================*/ + /*SPLIT + } #include "paranoia.h" part8(){ */ - Milestone = 190; - /*=============================================*/ - Pause(); - X = UfThold * V; - Y = Radix * Radix; - if (X*Y < One || X > Y) { - if (X * Y < U1 || X > Y/U1) BadCond(Defect, "Badly"); - else BadCond(Flaw, ""); + Milestone = 190; + /*=============================================*/ + Pause(); + X = UfThold * V; + Y = Radix * Radix; + if (X*Y < One || X > Y) { + if (X * Y < U1 || X > Y/U1) BadCond(Defect, "Badly"); + else BadCond(Flaw, ""); - printf(" unbalanced range; UfThold * V = %.17e\n\t%s\n", - X, "is too far from 1.\n"); - } - /*=============================================*/ - Milestone = 200; - /*=============================================*/ - for (Indx = 1; Indx <= 5; ++Indx) { - X = F9; - switch (Indx) { - case 2: X = One + U2; break; - case 3: X = V; break; - case 4: X = UfThold; break; - case 5: X = Radix; - } - Y = X; - sigsave = sigfpe; - if (setjmp(ovfl_buf)) - printf(" X / X traps when X = %g\n", X); - else { - V9 = (Y / X - Half) - Half; - if (V9 == Zero) continue; - if (V9 == - U1 && Indx < 5) BadCond(Flaw, ""); - else BadCond(Serious, ""); - printf(" X / X differs from 1 when X = %.17e\n", X); - printf(" instead, X / X - 1/2 - 1/2 = %.17e .\n", V9); - } - sigsave = 0; - } - /*=============================================*/ - Milestone = 210; - /*=============================================*/ - MyZero = Zero; - printf("\n"); - printf("What message and/or values does Division by Zero produce?\n") ; + printf(" unbalanced range; UfThold * V = %.17e\n\t%s\n", + X, "is too far from 1.\n"); + } + /*=============================================*/ + Milestone = 200; + /*=============================================*/ + for (Indx = 1; Indx <= 5; ++Indx) { + X = F9; + switch (Indx) { + case 2: X = One + U2; break; + case 3: X = V; break; + case 4: X = UfThold; break; + case 5: X = Radix; + } + Y = X; + sigsave = sigfpe; + if (setjmp(ovfl_buf)) + printf(" X / X traps when X = %g\n", X); + else { + V9 = (Y / X - Half) - Half; + if (V9 == Zero) continue; + if (V9 == - U1 && Indx < 5) BadCond(Flaw, ""); + else BadCond(Serious, ""); + printf(" X / X differs from 1 when X = %.17e\n", X); + printf(" instead, X / X - 1/2 - 1/2 = %.17e .\n", V9); + } + sigsave = 0; + } + /*=============================================*/ + Milestone = 210; + /*=============================================*/ + MyZero = Zero; + printf("\n"); + printf("What message and/or values does Division by Zero produce?\n") ; #ifndef NOPAUSE - printf("This can interupt your program. You can "); - printf("skip this part if you wish.\n"); - printf("Do you wish to compute 1 / 0? "); - fflush(stdout); - read (KEYBOARD, ch, 8); - if ((ch[0] == 'Y') || (ch[0] == 'y')) { + printf("This can interupt your program. You can "); + printf("skip this part if you wish.\n"); + printf("Do you wish to compute 1 / 0? "); + fflush(stdout); + read (KEYBOARD, ch, 8); + if ((ch[0] == 'Y') || (ch[0] == 'y')) { #endif - sigsave = sigfpe; - printf(" Trying to compute 1 / 0 produces ..."); - if (!setjmp(ovfl_buf)) printf(" %.7e .\n", One / MyZero); - sigsave = 0; + sigsave = sigfpe; + printf(" Trying to compute 1 / 0 produces ..."); + if (!setjmp(ovfl_buf)) printf(" %.7e .\n", One / MyZero); + sigsave = 0; #ifndef NOPAUSE - } - else printf("O.K.\n"); - printf("\nDo you wish to compute 0 / 0? "); - fflush(stdout); - read (KEYBOARD, ch, 80); - if ((ch[0] == 'Y') || (ch[0] == 'y')) { + } + else printf("O.K.\n"); + printf("\nDo you wish to compute 0 / 0? "); + fflush(stdout); + read (KEYBOARD, ch, 80); + if ((ch[0] == 'Y') || (ch[0] == 'y')) { #endif - sigsave = sigfpe; - printf("\n Trying to compute 0 / 0 produces ..."); - if (!setjmp(ovfl_buf)) printf(" %.7e .\n", Zero / MyZero); - sigsave = 0; + sigsave = sigfpe; + printf("\n Trying to compute 0 / 0 produces ..."); + if (!setjmp(ovfl_buf)) printf(" %.7e .\n", Zero / MyZero); + sigsave = 0; #ifndef NOPAUSE - } - else printf("O.K.\n"); + } + else printf("O.K.\n"); #endif - /*=============================================*/ - Milestone = 220; - /*=============================================*/ - Pause(); - printf("\n"); - { - static char *msg[] = { - "FAILUREs encountered =", - "SERIOUS DEFECTs discovered =", - "DEFECTs discovered =", - "FLAWs discovered =" }; - int i; - for(i = 0; i < 4; i++) if (ErrCnt[i]) - printf("The number of %-29s %d.\n", - msg[i], ErrCnt[i]); - } - printf("\n"); - if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect] - + ErrCnt[Flaw]) > 0) { - if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[ - Defect] == 0) && (ErrCnt[Flaw] > 0)) { - printf("The arithmetic diagnosed seems "); - printf("Satisfactory though flawed.\n"); - } - if ((ErrCnt[Failure] + ErrCnt[Serious] == 0) - && ( ErrCnt[Defect] > 0)) { - printf("The arithmetic diagnosed may be Acceptable\n"); - printf("despite inconvenient Defects.\n"); - } - if ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) { - printf("The arithmetic diagnosed has "); - printf("unacceptable Serious Defects.\n"); - } - if (ErrCnt[Failure] > 0) { - printf("Potentially fatal FAILURE may have spoiled this"); - printf(" program's subsequent diagnoses.\n"); - } - } - else { - printf("No failures, defects nor flaws have been discovered.\n"); - if (! ((RMult == Rounded) && (RDiv == Rounded) - && (RAddSub == Rounded) && (RSqrt == Rounded))) - printf("The arithmetic diagnosed seems Satisfactory.\n"); - else { - if (StickyBit >= One && - (Radix - Two) * (Radix - Nine - One) == Zero) { - printf("Rounding appears to conform to "); - printf("the proposed IEEE standard P"); - if ((Radix == Two) && - ((Precision - Four * Three * Two) * - ( Precision - TwentySeven - - TwentySeven + One) == Zero)) - printf("754"); - else printf("854"); - if (IEEE) printf(".\n"); - else { - printf(",\nexcept for possibly Double Rounding"); - printf(" during Gradual Underflow.\n"); - } - } - printf("The arithmetic diagnosed appears to be Excellent!\n"); - } - } - if (fpecount) - printf("\nA total of %d floating point exceptions were registered.\n", - fpecount); - printf("END OF TEST.\n"); - return 0; - } + /*=============================================*/ + Milestone = 220; + /*=============================================*/ + Pause(); + printf("\n"); + { + static char *msg[] = { + "FAILUREs encountered =", + "SERIOUS DEFECTs discovered =", + "DEFECTs discovered =", + "FLAWs discovered =" }; + int i; + for(i = 0; i < 4; i++) if (ErrCnt[i]) + printf("The number of %-29s %d.\n", + msg[i], ErrCnt[i]); + } + printf("\n"); + if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect] + + ErrCnt[Flaw]) > 0) { + if ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[ + Defect] == 0) && (ErrCnt[Flaw] > 0)) { + printf("The arithmetic diagnosed seems "); + printf("Satisfactory though flawed.\n"); + } + if ((ErrCnt[Failure] + ErrCnt[Serious] == 0) + && ( ErrCnt[Defect] > 0)) { + printf("The arithmetic diagnosed may be Acceptable\n"); + printf("despite inconvenient Defects.\n"); + } + if ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) { + printf("The arithmetic diagnosed has "); + printf("unacceptable Serious Defects.\n"); + } + if (ErrCnt[Failure] > 0) { + printf("Potentially fatal FAILURE may have spoiled this"); + printf(" program's subsequent diagnoses.\n"); + } + } + else { + printf("No failures, defects nor flaws have been discovered.\n"); + if (! ((RMult == Rounded) && (RDiv == Rounded) + && (RAddSub == Rounded) && (RSqrt == Rounded))) + printf("The arithmetic diagnosed seems Satisfactory.\n"); + else { + if (StickyBit >= One && + (Radix - Two) * (Radix - Nine - One) == Zero) { + printf("Rounding appears to conform to "); + printf("the proposed IEEE standard P"); + if ((Radix == Two) && + ((Precision - Four * Three * Two) * + ( Precision - TwentySeven - + TwentySeven + One) == Zero)) + printf("754"); + else printf("854"); + if (IEEE) printf(".\n"); + else { + printf(",\nexcept for possibly Double Rounding"); + printf(" during Gradual Underflow.\n"); + } + } + printf("The arithmetic diagnosed appears to be Excellent!\n"); + } + } + if (fpecount) + printf("\nA total of %d floating point exceptions were registered.\n", + fpecount); + printf("END OF TEST.\n"); + return 0; + } /*SPLIT subs.c #include "paranoia.h" @@ -1868,17 +1868,17 @@ FLOAT X; Pause() { #ifndef NOPAUSE - char ch[8]; + char ch[8]; - printf("\nTo continue, press RETURN"); - fflush(stdout); - read(KEYBOARD, ch, 8); + printf("\nTo continue, press RETURN"); + fflush(stdout); + read(KEYBOARD, ch, 8); #endif - printf("\nDiagnosis resumes after milestone Number %d", Milestone); - printf(" Page: %d\n\n", PageNo); - ++Milestone; - ++PageNo; - } + printf("\nDiagnosis resumes after milestone Number %d", Milestone); + printf(" Page: %d\n\n", PageNo); + ++Milestone; + ++PageNo; + } /* TstCond */ @@ -1891,11 +1891,11 @@ BadCond(K, T) int K; char *T; { - static char *msg[] = { "FAILURE", "SERIOUS DEFECT", "DEFECT", "FLAW" }; + static char *msg[] = { "FAILURE", "SERIOUS DEFECT", "DEFECT", "FLAW" }; - ErrCnt [K] = ErrCnt [K] + 1; - printf("%s: %s", msg[K], T); - } + ErrCnt [K] = ErrCnt [K] + 1; + printf("%s: %s", msg[K], T); + } /* Random */ /* Random computes @@ -1906,174 +1906,174 @@ char *T; FLOAT Random() { - FLOAT X, Y; + FLOAT X, Y; - X = Random1 + Random9; - Y = X * X; - Y = Y * Y; - X = X * Y; - Y = X - FLOOR(X); - Random1 = Y + X * 0.000005; - return(Random1); - } + X = Random1 + Random9; + Y = X * X; + Y = Y * Y; + X = X * Y; + Y = X - FLOOR(X); + Random1 = Y + X * 0.000005; + return(Random1); + } /* SqXMinX */ SqXMinX (ErrKind) int ErrKind; { - FLOAT XA, XB; + FLOAT XA, XB; - XB = X * BInvrse; - XA = X - XB; - SqEr = ((SQRT(X * X) - XB) - XA) / OneUlp; - if (SqEr != Zero) { - if (SqEr < MinSqEr) MinSqEr = SqEr; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - J = J + 1.0; - BadCond(ErrKind, "\n"); - printf("sqrt( %.17e) - %.17e = %.17e\n", X * X, X, OneUlp * SqEr); - printf("\tinstead of correct value 0 .\n"); - } - } + XB = X * BInvrse; + XA = X - XB; + SqEr = ((SQRT(X * X) - XB) - XA) / OneUlp; + if (SqEr != Zero) { + if (SqEr < MinSqEr) MinSqEr = SqEr; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + J = J + 1.0; + BadCond(ErrKind, "\n"); + printf("sqrt( %.17e) - %.17e = %.17e\n", X * X, X, OneUlp * SqEr); + printf("\tinstead of correct value 0 .\n"); + } + } /* NewD */ NewD() { - X = Z1 * Q; - X = FLOOR(Half - X / Radix) * Radix + X; - Q = (Q - X * Z) / Radix + X * X * (D / Radix); - Z = Z - Two * X * D; - if (Z <= Zero) { - Z = - Z; - Z1 = - Z1; - } - D = Radix * D; - } + X = Z1 * Q; + X = FLOOR(Half - X / Radix) * Radix + X; + Q = (Q - X * Z) / Radix + X * X * (D / Radix); + Z = Z - Two * X * D; + if (Z <= Zero) { + Z = - Z; + Z1 = - Z1; + } + D = Radix * D; + } /* SR3750 */ SR3750() { - if (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) { - I = I + 1; - X2 = SQRT(X * D); - Y2 = (X2 - Z2) - (Y - Z2); - X2 = X8 / (Y - Half); - X2 = X2 - Half * X2 * X2; - SqEr = (Y2 + Half) + (Half - X2); - if (SqEr < MinSqEr) MinSqEr = SqEr; - SqEr = Y2 - X2; - if (SqEr > MaxSqEr) MaxSqEr = SqEr; - } - } + if (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) { + I = I + 1; + X2 = SQRT(X * D); + Y2 = (X2 - Z2) - (Y - Z2); + X2 = X8 / (Y - Half); + X2 = X2 - Half * X2 * X2; + SqEr = (Y2 + Half) + (Half - X2); + if (SqEr < MinSqEr) MinSqEr = SqEr; + SqEr = Y2 - X2; + if (SqEr > MaxSqEr) MaxSqEr = SqEr; + } + } /* IsYeqX */ IsYeqX() { - if (Y != X) { - if (N <= 0) { - if (Z == Zero && Q <= Zero) - printf("WARNING: computing\n"); - else BadCond(Defect, "computing\n"); - printf("\t(%.17e) ^ (%.17e)\n", Z, Q); - printf("\tyielded %.17e;\n", Y); - printf("\twhich compared unequal to correct %.17e ;\n", - X); - printf("\t\tthey differ by %.17e .\n", Y - X); - } - N = N + 1; /* ... count discrepancies. */ - } - } + if (Y != X) { + if (N <= 0) { + if (Z == Zero && Q <= Zero) + printf("WARNING: computing\n"); + else BadCond(Defect, "computing\n"); + printf("\t(%.17e) ^ (%.17e)\n", Z, Q); + printf("\tyielded %.17e;\n", Y); + printf("\twhich compared unequal to correct %.17e ;\n", + X); + printf("\t\tthey differ by %.17e .\n", Y - X); + } + N = N + 1; /* ... count discrepancies. */ + } + } /* SR3980 */ SR3980() { - do { - Q = (FLOAT) I; - Y = POW(Z, Q); - IsYeqX(); - if (++I > M) break; - X = Z * X; - } while ( X < W ); - } + do { + Q = (FLOAT) I; + Y = POW(Z, Q); + IsYeqX(); + if (++I > M) break; + X = Z * X; + } while ( X < W ); + } /* PrintIfNPositive */ PrintIfNPositive() { - if (N > 0) printf("Similar discrepancies have occurred %d times.\n", N); - } + if (N > 0) printf("Similar discrepancies have occurred %d times.\n", N); + } /* TstPtUf */ TstPtUf() { - N = 0; - if (Z != Zero) { - printf("Since comparison denies Z = 0, evaluating "); - printf("(Z + Z) / Z should be safe.\n"); - sigsave = sigfpe; - if (setjmp(ovfl_buf)) goto very_serious; - Q9 = (Z + Z) / Z; - printf("What the machine gets for (Z + Z) / Z is %.17e .\n", - Q9); - if (FABS(Q9 - Two) < Radix * U2) { - printf("This is O.K., provided Over/Underflow"); - printf(" has NOT just been signaled.\n"); - } - else { - if ((Q9 < One) || (Q9 > Two)) { + N = 0; + if (Z != Zero) { + printf("Since comparison denies Z = 0, evaluating "); + printf("(Z + Z) / Z should be safe.\n"); + sigsave = sigfpe; + if (setjmp(ovfl_buf)) goto very_serious; + Q9 = (Z + Z) / Z; + printf("What the machine gets for (Z + Z) / Z is %.17e .\n", + Q9); + if (FABS(Q9 - Two) < Radix * U2) { + printf("This is O.K., provided Over/Underflow"); + printf(" has NOT just been signaled.\n"); + } + else { + if ((Q9 < One) || (Q9 > Two)) { very_serious: - N = 1; - ErrCnt [Serious] = ErrCnt [Serious] + 1; - printf("This is a VERY SERIOUS DEFECT!\n"); - } - else { - N = 1; - ErrCnt [Defect] = ErrCnt [Defect] + 1; - printf("This is a DEFECT!\n"); - } - } - sigsave = 0; - V9 = Z * One; - Random1 = V9; - V9 = One * Z; - Random2 = V9; - V9 = Z / One; - if ((Z == Random1) && (Z == Random2) && (Z == V9)) { - if (N > 0) Pause(); - } - else { - N = 1; - BadCond(Defect, "What prints as Z = "); - printf("%.17e\n\tcompares different from ", Z); - if (Z != Random1) printf("Z * 1 = %.17e ", Random1); - if (! ((Z == Random2) - || (Random2 == Random1))) - printf("1 * Z == %g\n", Random2); - if (! (Z == V9)) printf("Z / 1 = %.17e\n", V9); - if (Random2 != Random1) { - ErrCnt [Defect] = ErrCnt [Defect] + 1; - BadCond(Defect, "Multiplication does not commute!\n"); - printf("\tComparison alleges that 1 * Z = %.17e\n", - Random2); - printf("\tdiffers from Z * 1 = %.17e\n", Random1); - } - Pause(); - } - } - } + N = 1; + ErrCnt [Serious] = ErrCnt [Serious] + 1; + printf("This is a VERY SERIOUS DEFECT!\n"); + } + else { + N = 1; + ErrCnt [Defect] = ErrCnt [Defect] + 1; + printf("This is a DEFECT!\n"); + } + } + sigsave = 0; + V9 = Z * One; + Random1 = V9; + V9 = One * Z; + Random2 = V9; + V9 = Z / One; + if ((Z == Random1) && (Z == Random2) && (Z == V9)) { + if (N > 0) Pause(); + } + else { + N = 1; + BadCond(Defect, "What prints as Z = "); + printf("%.17e\n\tcompares different from ", Z); + if (Z != Random1) printf("Z * 1 = %.17e ", Random1); + if (! ((Z == Random2) + || (Random2 == Random1))) + printf("1 * Z == %g\n", Random2); + if (! (Z == V9)) printf("Z / 1 = %.17e\n", V9); + if (Random2 != Random1) { + ErrCnt [Defect] = ErrCnt [Defect] + 1; + BadCond(Defect, "Multiplication does not commute!\n"); + printf("\tComparison alleges that 1 * Z = %.17e\n", + Random2); + printf("\tdiffers from Z * 1 = %.17e\n", Random1); + } + Pause(); + } + } + } notify(s) char *s; { - printf("%s test appears to be inconsistent...\n", s); - printf(" PLEASE NOTIFY KARPINKSI!\n"); - } + printf("%s test appears to be inconsistent...\n", s); + printf(" PLEASE NOTIFY KARPINKSI!\n"); + } /*SPLIT msgs.c */ @@ -2086,134 +2086,134 @@ char **s; Instructions() { static char *instr[] = { - "Lest this program stop prematurely, i.e. before displaying\n", - " `END OF TEST',\n", - "try to persuade the computer NOT to terminate execution when an", - "error like Over/Underflow or Division by Zero occurs, but rather", - "to persevere with a surrogate value after, perhaps, displaying some", - "warning. If persuasion avails naught, don't despair but run this", - "program anyway to see how many milestones it passes, and then", - "amend it to make further progress.\n", - "Answer questions with Y, y, N or n (unless otherwise indicated).\n", - 0}; + "Lest this program stop prematurely, i.e. before displaying\n", + " 'END OF TEST',\n", + "try to persuade the computer NOT to terminate execution when an", + "error like Over/Underflow or Division by Zero occurs, but rather", + "to persevere with a surrogate value after, perhaps, displaying some", + "warning. If persuasion avails naught, don't despair but run this", + "program anyway to see how many milestones it passes, and then", + "amend it to make further progress.\n", + "Answer questions with Y, y, N or n (unless otherwise indicated).\n", + 0}; - msglist(instr); - } + msglist(instr); + } /* Heading */ Heading() { static char *head[] = { - "Users are invited to help debug and augment this program so it will", - "cope with unanticipated and newly uncovered arithmetic pathologies.\n", - "Please send suggestions and interesting results to", - "\tRichard Karpinski", - "\tComputer Center U-76", - "\tUniversity of California", - "\tSan Francisco, CA 94143-0704, USA\n", - "In doing so, please include the following information:", + "Users are invited to help debug and augment this program so it will", + "cope with unanticipated and newly uncovered arithmetic pathologies.\n", + "Please send suggestions and interesting results to", + "\tRichard Karpinski", + "\tComputer Center U-76", + "\tUniversity of California", + "\tSan Francisco, CA 94143-0704, USA\n", + "In doing so, please include the following information:", #ifdef Single - "\tPrecision:\tsingle;", + "\tPrecision:\tsingle;", #else - "\tPrecision:\tdouble;", + "\tPrecision:\tdouble;", #endif - "\tVersion:\t10 February 1989;", - "\tComputer:\n", - "\tCompiler:\n", - "\tOptimization level:\n", - "\tOther relevant compiler options:", - 0}; + "\tVersion:\t10 February 1989;", + "\tComputer:\n", + "\tCompiler:\n", + "\tOptimization level:\n", + "\tOther relevant compiler options:", + 0}; - msglist(head); - } + msglist(head); + } /* Characteristics */ Characteristics() { - static char *chars[] = { - "Running this program should reveal these characteristics:", - " Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...", - " Precision = number of significant digits carried.", - " U2 = Radix/Radix^Precision = One Ulp", - "\t(OneUlpnit in the Last Place) of 1.000xxx .", - " U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .", - " Adequacy of guard digits for Mult., Div. and Subt.", - " Whether arithmetic is chopped, correctly rounded, or something else", - "\tfor Mult., Div., Add/Subt. and Sqrt.", - " Whether a Sticky Bit used correctly for rounding.", - " UnderflowThreshold = an underflow threshold.", - " E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.", - " V = an overflow threshold, roughly.", - " V0 tells, roughly, whether Infinity is represented.", - " Comparisions are checked for consistency with subtraction", - "\tand for contamination with pseudo-zeros.", - " Sqrt is tested. Y^X is not tested.", - " Extra-precise subexpressions are revealed but NOT YET tested.", - " Decimal-Binary conversion is NOT YET tested for accuracy.", - 0}; + static char *chars[] = { + "Running this program should reveal these characteristics:", + " Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...", + " Precision = number of significant digits carried.", + " U2 = Radix/Radix^Precision = One Ulp", + "\t(OneUlpnit in the Last Place) of 1.000xxx .", + " U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .", + " Adequacy of guard digits for Mult., Div. and Subt.", + " Whether arithmetic is chopped, correctly rounded, or something else", + "\tfor Mult., Div., Add/Subt. and Sqrt.", + " Whether a Sticky Bit used correctly for rounding.", + " UnderflowThreshold = an underflow threshold.", + " E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.", + " V = an overflow threshold, roughly.", + " V0 tells, roughly, whether Infinity is represented.", + " Comparisions are checked for consistency with subtraction", + "\tand for contamination with pseudo-zeros.", + " Sqrt is tested. Y^X is not tested.", + " Extra-precise subexpressions are revealed but NOT YET tested.", + " Decimal-Binary conversion is NOT YET tested for accuracy.", + 0}; - msglist(chars); - } + msglist(chars); + } History() { /* History */ /* Converted from Brian Wichmann's Pascal version to C by Thos Sumner, - with further massaging by David M. Gay. */ + with further massaging by David M. Gay. */ static char *hist[] = { - "The program attempts to discriminate among", - " FLAWs, like lack of a sticky bit,", - " Serious DEFECTs, like lack of a guard digit, and", - " FAILUREs, like 2+2 == 5 .", - "Failures may confound subsequent diagnoses.\n", - "The diagnostic capabilities of this program go beyond an earlier", - "program called `MACHAR', which can be found at the end of the", - "book `Software Manual for the Elementary Functions' (1980) by", - "W. J. Cody and W. Waite. Although both programs try to discover", - "the Radix, Precision and range (over/underflow thresholds)", - "of the arithmetic, this program tries to cope with a wider variety", - "of pathologies, and to say how well the arithmetic is implemented.", - "\nThe program is based upon a conventional radix representation for", - "floating-point numbers, but also allows logarithmic encoding", - "as used by certain early WANG machines.\n", - "BASIC version of this program (C) 1983 by Prof. W. M. Kahan;", - "see source comments for more history.", - 0}; + "The program attempts to discriminate among", + " FLAWs, like lack of a sticky bit,", + " Serious DEFECTs, like lack of a guard digit, and", + " FAILUREs, like 2+2 == 5 .", + "Failures may confound subsequent diagnoses.\n", + "The diagnostic capabilities of this program go beyond an earlier", + "program called 'MACHAR', which can be found at the end of the", + "book 'Software Manual for the Elementary Functions' (1980) by", + "W. J. Cody and W. Waite. Although both programs try to discover", + "the Radix, Precision and range (over/underflow thresholds)", + "of the arithmetic, this program tries to cope with a wider variety", + "of pathologies, and to say how well the arithmetic is implemented.", + "\nThe program is based upon a conventional radix representation for", + "floating-point numbers, but also allows logarithmic encoding", + "as used by certain early WANG machines.\n", + "BASIC version of this program (C) 1983 by Prof. W. M. Kahan;", + "see source comments for more history.", + 0}; - msglist(hist); - } + msglist(hist); + } double pow(x, y) /* return x ^ y (exponentiation) */ double x, y; { - extern double exp(), frexp(), ldexp(), log(), modf(); - double xy, ye; - long i; - int ex, ey = 0, flip = 0; + extern double exp(), frexp(), ldexp(), log(), modf(); + double xy, ye; + long i; + int ex, ey = 0, flip = 0; - if (!y) return 1.0; + if (!y) return 1.0; - if ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x)); + if ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x)); - if (y < 0.) { y = -y; flip = 1; } - y = modf(y, &ye); - if (y) xy = exp(y * log(x)); - else xy = 1.0; - /* next several lines assume >= 32 bit integers */ - x = frexp(x, &ex); - if (i = ye) for(;;) { - if (i & 1) { xy *= x; ey += ex; } - if (!(i >>= 1)) break; - x *= x; - ex *= 2; - if (x < .5) { x *= 2.; ex -= 1; } - } - if (flip) { xy = 1. / xy; ey = -ey; } - return ldexp(xy, ey); + if (y < 0.) { y = -y; flip = 1; } + y = modf(y, &ye); + if (y) xy = exp(y * log(x)); + else xy = 1.0; + /* next several lines assume >= 32 bit integers */ + x = frexp(x, &ex); + if (i = ye) for(;;) { + if (i & 1) { xy *= x; ey += ex; } + if (!(i >>= 1)) break; + x *= x; + ex *= 2; + if (x < .5) { x *= 2.; ex -= 1; } + } + if (flip) { xy = 1. / xy; ey = -ey; } + return ldexp(xy, ey); } #endif /* NO_FLOATS */ diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c index 29f9e3de4..cfa384268 100644 --- a/test/ref/pointer2.c +++ b/test/ref/pointer2.c @@ -16,15 +16,15 @@ char i1[]; void test1(void) { int a; - a=sizeof(i1[0]); - printf("%04x - ",a); - if(sizeof(i1[0])==sizeof(char)) { - /* gcc gives size of element */ - printf("sizeof(i1[0]) gives size of element\n"); - } - if(sizeof(i1[0])==sizeof(char*)) { - printf("sizeof(i1[0]) gives size of pointer to element\n"); - } + a=sizeof(i1[0]); + printf("%04x - ",a); + if(sizeof(i1[0])==sizeof(char)) { + /* gcc gives size of element */ + printf("sizeof(i1[0]) gives size of element\n"); + } + if(sizeof(i1[0])==sizeof(char*)) { + printf("sizeof(i1[0]) gives size of pointer to element\n"); + } } /* @@ -40,14 +40,14 @@ char *t4={"abcde"}; void test2(void) { char c1,c2,c3,c4; int i,e=0; - for(i=0;i<5;i++){ - c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; -/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ - printf("%c %c %c %c\n",c1,c2,c3,c4); - if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; - } - if(e) printf("test2 failed.\n"); - else printf("test2 ok.\n"); + for(i=0;i<5;i++){ + c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; +/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ + printf("%c %c %c %c\n",c1,c2,c3,c4); + if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; + } + if(e) printf("test2 failed.\n"); + else printf("test2 ok.\n"); } /* @@ -74,7 +74,7 @@ A3 a3[] = { #endif void test3a(A3 *list, int number){ - printf("%s %d\n",list->name,number); + printf("%s %d\n",list->name,number); } static void test31(void) @@ -103,10 +103,10 @@ static void test30(void) */ int main(void) { - test1(); - test2(); - test30(); - test31(); -/* test32(); */ - return 0; + test1(); + test2(); + test30(); + test31(); +/* test32(); */ + return 0; } diff --git a/test/ref/sort.c b/test/ref/sort.c index 5db5cf01b..b4dee8734 100644 --- a/test/ref/sort.c +++ b/test/ref/sort.c @@ -14,62 +14,62 @@ int *xx; exchange(int *x,int *y) { int t; - printf("exchange(%d,%d)\n", x - xx, y - xx); - t = *x; *x = *y; *y = t; + printf("exchange(%d,%d)\n", x - xx, y - xx); + t = *x; *x = *y; *y = t; } /* partition - partition a[i..j] */ int partition(int a[], int i, int j) { int v, k; - j++; - k = i; - v = a[k]; - while (i < j) { - i++; while (a[i] < v) i++; - j--; while (a[j] > v) j--; - if (i < j) exchange(&a[i], &a[j]); - } - exchange(&a[k], &a[j]); - return j; + j++; + k = i; + v = a[k]; + while (i < j) { + i++; while (a[i] < v) i++; + j--; while (a[j] > v) j--; + if (i < j) exchange(&a[i], &a[j]); + } + exchange(&a[k], &a[j]); + return j; } /* quick - quicksort a[lb..ub] */ void quick(int a[], int lb, int ub) { int k; - if (lb >= ub) - return; - k = partition(a, lb, ub); - quick(a, lb, k - 1); - quick(a, k + 1, ub); + if (lb >= ub) + return; + k = partition(a, lb, ub); + quick(a, lb, k - 1); + quick(a, k + 1, ub); } /* sort - sort a[0..n-1] into increasing order */ sort(int a[], int n) { - quick(xx = a, 0, --n); + quick(xx = a, 0, --n); } /* putd - output decimal number */ void putd(int n) { - if (n < 0) { - putchar('-'); - n = -n; - } - if (n/10) - putd(n/10); - putchar(n%10 + '0'); + if (n < 0) { + putchar('-'); + n = -n; + } + if (n/10) + putd(n/10); + putchar(n%10 + '0'); } int main(void) { - int i; + int i; - sort(in, (sizeof in)/(sizeof in[0])); - for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) { - putd(in[i]); - putchar('\n'); - } + sort(in, (sizeof in)/(sizeof in[0])); + for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) { + putd(in[i]); + putchar('\n'); + } - return 0; + return 0; } diff --git a/test/ref/spill.c b/test/ref/spill.c index 56b03d6a7..316928ab3 100644 --- a/test/ref/spill.c +++ b/test/ref/spill.c @@ -51,6 +51,6 @@ int j, k, m, n; #endif f5(){ - x=A[k*m]*A[j*m]+B[k*n]*B[j*n]; - x=A[k*m]*B[j*n]-B[k*n]*A[j*m]; + x=A[k*m]*A[j*m]+B[k*n]*B[j*n]; + x=A[k*m]*B[j*n]-B[k*n]*A[j*m]; } diff --git a/test/ref/stdarg.c b/test/ref/stdarg.c index 295a2ccad..b88fcaafe 100644 --- a/test/ref/stdarg.c +++ b/test/ref/stdarg.c @@ -10,15 +10,15 @@ #ifndef NO_FUNCS_TAKE_STRUCTS struct node { - int a[4]; + int a[4]; } x = { #ifdef NO_SLOPPY_STRUCT_INIT - { + { #endif - 1,2,3,4 + 1,2,3,4 #ifdef NO_SLOPPY_STRUCT_INIT - } + } #endif }; #endif @@ -27,68 +27,68 @@ print(char *fmt, ...); main() { - print("test 1\n"); - print("test %s\n", "2"); - print("test %d%c", 3, '\n'); - print("%s%s %w%c", "te", "st", 4, '\n'); + print("test 1\n"); + print("test %s\n", "2"); + print("test %d%c", 3, '\n'); + print("%s%s %w%c", "te", "st", 4, '\n'); #ifdef NO_FLOATS - print("%s%s %f%c", "te", "st", (signed long) 5, '\n'); - #else - print("%s%s %f%c", "te", "st", 5.0, '\n'); + print("%s%s %f%c", "te", "st", (signed long) 5, '\n'); + #else + print("%s%s %f%c", "te", "st", 5.0, '\n'); #endif - #ifndef NO_FUNCS_TAKE_STRUCTS + #ifndef NO_FUNCS_TAKE_STRUCTS print("%b %b %b %b %b %b\n", x, x, x, x, x, x); - #endif - return 0; + #endif + return 0; } print(char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - for (; *fmt; fmt++) - { - if (*fmt == '%') - switch (*++fmt) { + va_list ap; + va_start(ap, fmt); + for (; *fmt; fmt++) + { + if (*fmt == '%') + switch (*++fmt) { case 'b': { - #ifdef NO_FUNCS_TAKE_STRUCTS - printf("(1 2 3 4)"); - #else - struct node x = - va_arg( - ap, - struct node - ); - printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]); - #endif + #ifdef NO_FUNCS_TAKE_STRUCTS + printf("(1 2 3 4)"); + #else + struct node x = + va_arg( + ap, + struct node + ); + printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]); + #endif break; } - case 'c': - /* printf("%c", va_arg(ap, char)); */ - printf("%c", va_arg(ap, int)); - break; - case 'd': - printf("%d", va_arg(ap, int)); - break; - case 'w': - /* printf("%x", va_arg(ap, short)); */ - printf("%x", va_arg(ap, int)); - break; - case 's': - printf("%s", va_arg(ap, char *)); - break; - case 'f': - #ifdef NO_FLOATS - printf("%ld.000000", va_arg(ap, signed long)); - #else - printf("%f", va_arg(ap, double)); - #endif - break; - default: - printf("%c", *fmt); - break; - } - else - printf("%c", *fmt); - } - va_end(ap); + case 'c': + /* printf("%c", va_arg(ap, char)); */ + printf("%c", va_arg(ap, int)); + break; + case 'd': + printf("%d", va_arg(ap, int)); + break; + case 'w': + /* printf("%x", va_arg(ap, short)); */ + printf("%x", va_arg(ap, int)); + break; + case 's': + printf("%s", va_arg(ap, char *)); + break; + case 'f': + #ifdef NO_FLOATS + printf("%ld.000000", va_arg(ap, signed long)); + #else + printf("%f", va_arg(ap, double)); + #endif + break; + default: + printf("%c", *fmt); + break; + } + else + printf("%c", *fmt); + } + va_end(ap); } diff --git a/test/ref/strptr.c b/test/ref/strptr.c index 8bfa983a8..152c1bb48 100644 --- a/test/ref/strptr.c +++ b/test/ref/strptr.c @@ -24,7 +24,7 @@ FILE *outfile=NULL; #else #endif - + #include #include #include @@ -34,18 +34,18 @@ FILE *outfile=NULL; struct Xdirent { - char d_name[XNAME_MAX+1]; - unsigned short d_off; - unsigned short d_reclen; - unsigned char d_type; - unsigned char d_namlen; + char d_name[XNAME_MAX+1]; + unsigned short d_off; + unsigned short d_reclen; + unsigned char d_type; + unsigned char d_namlen; }; typedef struct { - unsigned char fd; - unsigned short off; - char name[XNAME_MAX+1]; + unsigned char fd; + unsigned short off; + char name[XNAME_MAX+1]; } XDIR; unsigned char b1[4]; @@ -61,51 +61,51 @@ static struct Xdirent entry; unsigned char fd; static unsigned char ch; - entry.d_off=dir->off; + entry.d_off=dir->off; - /* basic line-link / file-length */ - memcpy(buffer,b1,4); - - dir->off=dir->off+4; - entry.d_reclen=254*(buffer[2]+(buffer[3]<<8)); + /* basic line-link / file-length */ + memcpy(buffer,b1,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; + /* read file entry */ + memcpy(buffer,b2,0x10); + + 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){ - temp=buffer[ii];ii++; - if(ii>16){ - /* something went wrong...this shouldnt happen! */ - return(NULL); - } - else if(temp=='\"') i++; - else if(temp=='b') { - /* "blocks free" */ - return(NULL); - } - } - printf("Xreaddir: '%s'\n",buffer); + printf("Xreaddir: '%s'\n",buffer); + + /* skip until either quote (file) or b (blocks free => end) */ + i=0;ii=0; + while(i==0){ + temp=buffer[ii];ii++; + if(ii>16){ + /* something went wrong...this shouldnt happen! */ + return(NULL); + } + else if(temp=='\"') i++; + else if(temp=='b') { + /* "blocks free" */ + return(NULL); + } + } + printf("Xreaddir: '%s'\n",buffer); - /* process file entry */ + /* process file entry */ - i=0; temp=buffer[ii];ii++; - while(temp!='\"'){ - entry.d_name[i]=temp; - i++; - temp=buffer[ii];ii++; - } - entry.d_name[i]=0; - entry.d_namlen=i; + i=0; temp=buffer[ii];ii++; + while(temp!='\"'){ + entry.d_name[i]=temp; + i++; + temp=buffer[ii];ii++; + } + entry.d_name[i]=0; + entry.d_namlen=i; - /* set type flag */ + /* set type flag */ - return(&entry); + return(&entry); } int main(void) @@ -113,16 +113,16 @@ int main(void) char mydirname[XNAME_MAX+1]="."; XDIR mydir; struct Xdirent *mydirent; - + printf("start\n"); if((mydirent=Xreaddir(&mydir))==NULL) { - printf("NULL\n"); + printf("NULL\n"); } else { - printf("=%s\n",mydirent->d_name); + printf("=%s\n",mydirent->d_name); } printf("done\n"); diff --git a/test/ref/struct.c b/test/ref/struct.c index a0f181e96..15fae62fc 100644 --- a/test/ref/struct.c +++ b/test/ref/struct.c @@ -74,8 +74,8 @@ void makepoint(point *p,int x, int y) { /* make a rectangle from two points */ void makerect(rect *d,point p1, point p2) { rect r; - r.pt1 = p1; - r.pt2 = p2; + r.pt1 = p1; + r.pt2 = p2; canonrect(d,r); } @@ -97,53 +97,53 @@ odd(struct odd y) { /* add two points */ point addpoint(point p1, point p2) { - p1.x += p2.x; - p1.y += p2.y; - return p1; + p1.x += p2.x; + p1.y += p2.y; + return p1; } /* canonicalize rectangle coordinates */ rect canonrect(rect r) { - rect temp; + rect temp; - temp.pt1.x = min(r.pt1.x, r.pt2.x); - temp.pt1.y = min(r.pt1.y, r.pt2.y); - temp.pt2.x = max(r.pt1.x, r.pt2.x); - temp.pt2.y = max(r.pt1.y, r.pt2.y); - return temp; + temp.pt1.x = min(r.pt1.x, r.pt2.x); + temp.pt1.y = min(r.pt1.y, r.pt2.y); + temp.pt2.x = max(r.pt1.x, r.pt2.x); + temp.pt2.y = max(r.pt1.y, r.pt2.y); + return temp; } /* make a point from x and y components */ point makepoint(int x, int y) { - point p; + point p; - p.x = x; - p.y = y; - return p; + p.x = x; + p.y = y; + return p; } /* make a rectangle from two points */ rect makerect(point p1, point p2) { - rect r; + rect r; - r.pt1 = p1; - r.pt2 = p2; - return canonrect(r); + r.pt1 = p1; + r.pt2 = p2; + return canonrect(r); } struct odd {char a[3]; } y = { #ifdef NO_SLOPPY_STRUCT_INIT - { + { #endif - 'a', 'b', 0 + 'a', 'b', 0 #ifdef NO_SLOPPY_STRUCT_INIT - } + } #endif }; odd(struct odd y) { - struct odd x - = y; + struct odd x + = y; printf("%s\n\r", x.a); } @@ -157,8 +157,8 @@ int ptinrect(point *p, rect *r) { } #else int ptinrect(point p, rect r) { - return p.x >= r.pt1.x && p.x < r.pt2.x - && p.y >= r.pt1.y && p.y < r.pt2.y; + return p.x >= r.pt1.x && p.x < r.pt2.x + && p.y >= r.pt1.y && p.y < r.pt2.y; } #endif @@ -212,9 +212,9 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 }; #else if (ptinrect(x, screen) == 0) #endif - { + { printf("not "); - } + } printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y, screen.pt2.x, screen.pt2.y); } @@ -240,24 +240,24 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 }; #endif rect screen = - makerect( - addpoint(maxpt, makepoint(-10, -10)), - addpoint(origin, makepoint(10, 10)) - ); + makerect( + addpoint(maxpt, makepoint(-10, -10)), + addpoint(origin, makepoint(10, 10)) + ); - 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); - if (ptinrect(x, screen) == 0) - printf("not "); + 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); + if (ptinrect(x, screen) == 0) + printf("not "); printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y, - screen.pt2.x, screen.pt2.y); - } - odd(y); + screen.pt2.x, screen.pt2.y); + } + odd(y); - return 0; + return 0; } #endif /* FUNCS_RETURN_STRUCTS */ diff --git a/test/ref/switch.c b/test/ref/switch.c index 0821d29ee..dc7fdc8ce 100644 --- a/test/ref/switch.c +++ b/test/ref/switch.c @@ -18,9 +18,9 @@ limit(); big( # ifdef ASSUME_32BIT_UNSIGNED - unsigned + unsigned # else - unsigned long + unsigned long # endif x); @@ -28,28 +28,28 @@ x); main() { - testbackslash(); - f(); - g(); - h(); - testbig(); /* ! broken long int compare (?) */ - limit(); /* ! broken long int compare (?) */ + testbackslash(); + f(); + g(); + h(); + testbig(); /* ! broken long int compare (?) */ + limit(); /* ! broken long int compare (?) */ - return 0; + return 0; } testbig() { - #ifdef ASSUME_32BIT_INT - int i; - #else - signed long i; - #endif - /* 2341234 2341234 2341234 */ - for (i = 0x1000000; i&0x7000000; i += 0x1000000) { -/* printf("i = 0x%lx\n", i); */ - big(i); - } + #ifdef ASSUME_32BIT_INT + int i; + #else + signed long i; + #endif + /* 2341234 2341234 2341234 */ + for (i = 0x1000000; i&0x7000000; i += 0x1000000) { +/* printf("i = 0x%lx\n", i); */ + big(i); + } } #ifdef NO_LOCAL_STRING_INIT @@ -69,93 +69,93 @@ testbackslash() #else for (s = "bfnrtvx"; *s; s++) { #endif - printf("%c = %c\n", *s, backslash(*s)); + printf("%c = %c\n", *s, backslash(*s)); } } backslash(c) { - switch (c) + switch (c) { - case 'b': - return 'b'; - case 'f': - return 'f'; - case 'n': - return 'n'; - case 'r': - return 'r'; - case 't': - return 't'; - case 'v': + case 'b': + return 'b'; + case 'f': + return 'f'; + case 'n': + return 'n'; + case 'r': + return 'r'; + case 't': + return 't'; + case 'v': return 'v'; - } + } - return 'x'; + return 'x'; } f() { - int i, x = 0, y; + int i, x = 0, y; - printf("f:\n"); - for (i = 0; i <= 20; i++) { - y = i; - switch (i) { - case 1: x = i; break; - case 2: x = i; break; - case 7: x = i; break; - case 8: x = i; break; - case 9: x = i; break; - case 16: x = i; break; - case 17: x = i; break; - case 18: x = i; break; - case 19: x = i; break; - case 20: x = i; break; - } - printf("x = %d\n", x); - } + printf("f:\n"); + for (i = 0; i <= 20; i++) { + y = i; + switch (i) { + case 1: x = i; break; + case 2: x = i; break; + case 7: x = i; break; + case 8: x = i; break; + case 9: x = i; break; + case 16: x = i; break; + case 17: x = i; break; + case 18: x = i; break; + case 19: x = i; break; + case 20: x = i; break; + } + printf("x = %d\n", x); + } } g() { - int i; + int i; - printf("g:\n"); - for (i = 1; i <= 10; i++) - switch (i) { - case 1: case 2: printf("1 %d\n", i); break; - case 3: case 4: case 5: printf("2 %d\n", i); break; - case 6: case 7: case 8: printf("3 %d\n", i); - default: - printf("d %d\n", i); break; - case 1001: case 1002: case 1003: case 1004: - printf("5 %d\n", i); break; - case 3001: case 3002: case 3003: case 3004: - printf("6 %d\n", i); break; - } + printf("g:\n"); + for (i = 1; i <= 10; i++) + switch (i) { + case 1: case 2: printf("1 %d\n", i); break; + case 3: case 4: case 5: printf("2 %d\n", i); break; + case 6: case 7: case 8: printf("3 %d\n", i); + default: + printf("d %d\n", i); break; + case 1001: case 1002: case 1003: case 1004: + printf("5 %d\n", i); break; + case 3001: case 3002: case 3003: case 3004: + printf("6 %d\n", i); break; + } } h() { - int i, n=0; + int i, n=0; - printf("h:\n"); - for (i = 1; i <= 500; i++) - switch (i) { - default: n++; continue; - case 128: printf("i = %d\n", i); break; - case 16: printf("i = %d\n", i); break; - case 8: printf("i = %d\n", i); break; - case 120: printf("i = %d\n", i); break; - case 280: printf("i = %d\n", i); break; - case 264: printf("i = %d\n", i); break; - case 248: printf("i = %d\n", i); break; - case 272: printf("i = %d\n", i); break; - case 304: printf("i = %d\n", i); break; - case 296: printf("i = %d\n", i); break; - case 288: printf("i = %d\n", i); break; - case 312: printf("i = %d\n", i); break; - } - printf("%d defaults\n", n); + printf("h:\n"); + for (i = 1; i <= 500; i++) + switch (i) { + default: n++; continue; + case 128: printf("i = %d\n", i); break; + case 16: printf("i = %d\n", i); break; + case 8: printf("i = %d\n", i); break; + case 120: printf("i = %d\n", i); break; + case 280: printf("i = %d\n", i); break; + case 264: printf("i = %d\n", i); break; + case 248: printf("i = %d\n", i); break; + case 272: printf("i = %d\n", i); break; + case 304: printf("i = %d\n", i); break; + case 296: printf("i = %d\n", i); break; + case 288: printf("i = %d\n", i); break; + case 312: printf("i = %d\n", i); break; + } + printf("%d defaults\n", n); } #ifdef NO_OLD_FUNC_DECL @@ -165,9 +165,9 @@ h() #endif # ifdef ASSUME_32BIT_UNSIGNED - unsigned + unsigned # else - unsigned long + unsigned long # endif #ifdef NO_OLD_FUNC_DECL @@ -176,42 +176,42 @@ h() x; { #endif -/* printf("x = 0x%x\n", x); */ +/* printf("x = 0x%x\n", x); */ - switch(x&0x6000000){ - case -1: - case -2: - case 0x0000000: - printf("x = 0x%lx\n", x); break; - case 0x2000000: - printf("x = 0x%lx\n", x); break; - case 0x4000000: - printf("x = 0x%lx\n", x); break; - default: - printf("x = 0x%lx (default)\n", x); break; - } + switch(x&0x6000000){ + case -1: + case -2: + case 0x0000000: + printf("x = 0x%lx\n", x); break; + case 0x2000000: + printf("x = 0x%lx\n", x); break; + case 0x4000000: + printf("x = 0x%lx\n", x); break; + default: + printf("x = 0x%lx (default)\n", x); break; + } } limit() { - int i; + int i; - for (i = INT_MIN; i <= INT_MIN+5; i++) -/* for (i = INT_MIN; i < INT_MIN+6; i++) */ - switch (i) { - case INT_MIN: printf("0\n"); break; - case INT_MIN+1: printf("1\n"); break; - case INT_MIN+2: printf("2\n"); break; - case INT_MIN+3: printf("3\n"); break; - case INT_MIN+4: printf("4\n"); break; - default: printf("5\n"); break; - } - for (i = INT_MAX; i >= INT_MAX-5; i--) - switch (i) { - case INT_MAX: printf("0\n"); break; - case INT_MAX-1: printf("1\n"); break; - case INT_MAX-2: printf("2\n"); break; - case INT_MAX-3: printf("3\n"); break; - case INT_MAX-4: printf("4\n"); break; - default: printf("5\n"); break; - } + for (i = INT_MIN; i <= INT_MIN+5; i++) +/* for (i = INT_MIN; i < INT_MIN+6; i++) */ + switch (i) { + case INT_MIN: printf("0\n"); break; + case INT_MIN+1: printf("1\n"); break; + case INT_MIN+2: printf("2\n"); break; + case INT_MIN+3: printf("3\n"); break; + case INT_MIN+4: printf("4\n"); break; + default: printf("5\n"); break; + } + for (i = INT_MAX; i >= INT_MAX-5; i--) + switch (i) { + case INT_MAX: printf("0\n"); break; + case INT_MAX-1: printf("1\n"); break; + case INT_MAX-2: printf("2\n"); break; + case INT_MAX-3: printf("3\n"); break; + case INT_MAX-4: printf("4\n"); break; + default: printf("5\n"); break; + } } diff --git a/test/ref/switch2.c b/test/ref/switch2.c index 7a9bcecd7..7884f3722 100644 --- a/test/ref/switch2.c +++ b/test/ref/switch2.c @@ -9,31 +9,31 @@ #include void testlimits(int i) { - printf("%d:",i); + printf("%d:",i); - switch(i) { - case -1: /* works */ - /* case 0xffff: */ /* 'range error' (-1) */ + switch(i) { + case -1: /* works */ + /* case 0xffff: */ /* 'range error' (-1) */ - printf("-1\n"); - break; - /* max int */ + printf("-1\n"); + break; + /* max int */ -/* case 0x7fff: */ /* works */ - case 32767: /* works */ - /* case 32768: */ /* 'range error' (correct for that one!) */ +/* case 0x7fff: */ /* works */ + case 32767: /* works */ + /* case 32768: */ /* 'range error' (correct for that one!) */ - printf("max\n"); - break; - /* min int */ + printf("max\n"); + break; + /* min int */ - case -32768: /* 'warning. constant is long' */ - /* case 0x8000: */ /* 'range error' */ - /* case -32769: */ /* 'range error' (correct for that one!) */ - printf("min\n"); - break; - } - printf("\n"); + case -32768: /* 'warning. constant is long' */ + /* case 0x8000: */ /* 'range error' */ + /* case -32769: */ /* 'range error' (correct for that one!) */ + printf("min\n"); + break; + } + printf("\n"); } void testdefault1(unsigned char i) { @@ -45,9 +45,9 @@ signed char k; #else char k; #endif - + #else - + #ifdef UNSIGNED_CHARS signed char k; #else @@ -56,89 +56,89 @@ char k; #endif - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - /* gcc warning: case label value exceeds maximum value for type */ - /* cc65 error: range error */ + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + /* gcc warning: case label value exceeds maximum value for type */ + /* cc65 error: range error */ - /* - case 170: - break; - */ - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + /* + case 170: + break; + */ + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } void testdefault2(unsigned char i) { @@ -150,9 +150,9 @@ char k; #else unsigned char k; #endif - + #else - + #ifdef UNSIGNED_CHARS char k; #else @@ -161,102 +161,102 @@ unsigned char k; #endif - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ - case 170: - break; - - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + case 170: + break; + + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } int main(void) { - testlimits(32767); - testlimits(-32768); - testlimits(-1); - - testdefault1(1); - testdefault1(2); - testdefault1(3); - testdefault1(4); - - testdefault2(1); - testdefault2(2); - testdefault2(3); - testdefault2(4); + testlimits(32767); + testlimits(-32768); + testlimits(-1); + + testdefault1(1); + testdefault1(2); + testdefault1(3); + testdefault1(4); + + testdefault2(1); + testdefault2(2); + testdefault2(3); + testdefault2(4); - return 0; + return 0; } diff --git a/test/ref/varargs.c b/test/ref/varargs.c index 3d61fdbd0..c3e89aaa5 100644 --- a/test/ref/varargs.c +++ b/test/ref/varargs.c @@ -86,7 +86,7 @@ static char string[0x100]; va_start(ap,format); vsprintf(string,format,ap); - printf("fd:%d,format:%s,string:%s\n",fd,format,string); + printf("fd:%d,format:%s,string:%s\n",fd,format,string); va_end(ap); } diff --git a/test/ref/wf1.c b/test/ref/wf1.c index 0539d8398..1c3bfbd37 100644 --- a/test/ref/wf1.c +++ b/test/ref/wf1.c @@ -16,12 +16,12 @@ FILE *in; struct node { - int count; /* frequency count */ - struct node *left; /* left subtree */ - struct node *right; /* right subtree */ - char *word; /* word itself */ + int count; /* frequency count */ + struct node *left; /* left subtree */ + struct node *right; /* right subtree */ + char *word; /* word itself */ } words[MAXWORDS]; -int next; /* index of next free entry in words */ +int next; /* index of next free entry in words */ /*struct node *lookup();*/ @@ -38,14 +38,14 @@ struct node *lookup(char *word, struct node **p); int isletter(char c); -/* err - print error message s and die */ +/* err - print error message s and die */ #ifndef NO_OLD_FUNC_DECL err(s) char *s; { #else int err(char *s) { #endif - printf("? %s\n", s); - exit(1); + printf("? %s\n", s); + exit(1); } /* getword - get next input word into buf, return 0 on EOF */ @@ -55,25 +55,25 @@ int getword(buf) char *buf; int getword(char *buf) #endif { - char *s; - int c; + char *s; + int c; while (((c = getchar()) != -1) && (isletter(c) == 0)) - ; + ; for (s = buf; (c = isletter(c)); c = getchar()) - *s++ = c; - *s = 0; - if (s > buf) - return 1; - return 0; + *s++ = c; + *s = 0; + if (s > buf) + return 1; + return 0; } /* isletter - return folded version of c if it is a letter, 0 otherwise */ int isletter(char c) { - if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A'; - if ((c >= 'a') && (c <= 'z')) return c; - return 0; + if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A'; + if ((c >= 'a') && (c <= 'z')) return c; + return 0; } /* lookup - lookup word in tree; install if necessary */ @@ -84,27 +84,27 @@ char *word; struct node **p; struct node *lookup(char *word, struct node **p) #endif { - int cond; -/* char *malloc(); */ + int cond; +/* char *malloc(); */ - if (*p) { - cond = strcmp(word, (*p)->word); - if (cond < 0) - return lookup(word, &(*p)->left); - else if (cond > 0) - return lookup(word, &(*p)->right); - else - return *p; - } - if (next >= MAXWORDS) - err("out of node storage"); - words[next].count = 0; - words[next].left = words[next].right = 0; - words[next].word = malloc(strlen(word) + 1); - if (words[next].word == 0) - err("out of word storage"); - strcpy(words[next].word, word); - return *p = &words[next++]; + if (*p) { + cond = strcmp(word, (*p)->word); + if (cond < 0) + return lookup(word, &(*p)->left); + else if (cond > 0) + return lookup(word, &(*p)->right); + else + return *p; + } + if (next >= MAXWORDS) + err("out of node storage"); + words[next].count = 0; + words[next].left = words[next].right = 0; + words[next].word = malloc(strlen(word) + 1); + if (words[next].word == 0) + err("out of word storage"); + strcpy(words[next].word, word); + return *p = &words[next++]; } /* tprint - print tree */ @@ -113,28 +113,28 @@ void tprint(tree) struct node *tree; { #else void tprint(struct node *tree) { #endif - if (tree) { - tprint(tree->left); - printf("%d:%s\n", tree->count, tree->word); - tprint(tree->right); - } + if (tree) { + tprint(tree->left); + printf("%d:%s\n", tree->count, tree->word); + tprint(tree->right); + } } int main(void) { - struct node *root; - char word[20]; + struct node *root; + char word[20]; in = fopen("wf1.in","rb"); if (in == NULL) { return EXIT_FAILURE; } - root = 0; - next = 0; - while (getword(word)) - lookup(word, &root)->count++; - tprint(root); + root = 0; + next = 0; + while (getword(word)) + lookup(word, &root)->count++; + tprint(root); fclose(in); return 0; diff --git a/test/ref/yacc.c b/test/ref/yacc.c index ab72e24c0..f2c3e2a58 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -72,9 +72,9 @@ int yytchar; extern int yylineno; struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; struct yysvf *yyestate; extern struct yysvf yysvec[], *yybgin; @@ -96,18 +96,18 @@ yyback(int *p,int m); #ifdef YYDEBUG void printchar(char *name,int ch) { - if((ch==YYNEWLINE)) - { - fprintf(yyout," %s=YYNEWLINE\n",name); - } - else if((ch<0)||(ch>0xf0)||(!isprint(ch))) - { - fprintf(yyout," %s=%04x\n",name,ch &0xffff); - } - else - { - fprintf(yyout," %s='%c'\n",name,ch); - } + if((ch==YYNEWLINE)) + { + fprintf(yyout," %s=YYNEWLINE\n",name); + } + else if((ch<0)||(ch>0xf0)||(!isprint(ch))) + { + fprintf(yyout," %s=%04x\n",name,ch &0xffff); + } + else + { + fprintf(yyout," %s='%c'\n",name,ch); + } } #endif @@ -117,148 +117,148 @@ int nstr; extern int yyprevious; #ifdef YYDEBUG - fprintf(yyout,"yylex()\n"); + fprintf(yyout,"yylex()\n"); #endif - while((nstr = yylook()) >= 0) - { + while((nstr = yylook()) >= 0) + { #ifdef YYDEBUG - fprintf(yyout,"yylex: nstr=%d\n",nstr); + fprintf(yyout,"yylex: nstr=%d\n",nstr); #endif yyfussy: - switch(nstr) - { - case 0: - if(yywrap()) return(0); - break; - case 1: - return ID; - break; - case 2: - return CON; - break; - case 3: - ; - break; - case 4: - return yytext[0]; - break; - case -1: - break; - default: - fprintf(yyout,"yylex: bad switch yylook %d\n",nstr); - } + switch(nstr) + { + case 0: + if(yywrap()) return(0); + break; + case 1: + return ID; + break; + case 2: + return CON; + break; + case 3: + ; + break; + case 4: + return yytext[0]; + break; + case -1: + break; + default: + fprintf(yyout,"yylex: bad switch yylook %d\n",nstr); + } - } - + } + #ifdef YYDEBUG - fprintf(yyout,"yylex: return 0\n"); + fprintf(yyout,"yylex: return 0\n"); #endif - return(0); + return(0); } /* end of yylex */ int yyvstop[] = { - 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 + 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 }; # define YYTYPE char struct yywork { - YYTYPE verify, advance; + YYTYPE verify, advance; } yycrank[] = { - {0,0}, {0,0}, {1,3}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {1,4}, {1,3}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,3}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,4}, {1,3}, + {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}, {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}, {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}, - {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}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0x40 */ - {0,0}, {0,0}, {1,6}, {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}, {0,0}, {1,6}, {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}, {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}, + {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}, + {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}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {6,8}, {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}, /* 0x80 */ - {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}, + {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}, #ifdef CHARSETHACK - {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}, {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}, {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}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0xc0 */ - {0,0}, {0,0}, {1,6}, {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}, {0,0}, {1,6}, {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}, #endif - {0,0} + {0,0} }; /* struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; */ struct yysvf yysvec[] = { - {0, 0, 0}, - {yycrank+-1, 0, 0}, - {yycrank+0, yysvec+1, 0}, - {yycrank+0, 0, yyvstop+1}, - {yycrank+0, 0, yyvstop+3}, - {yycrank+2, 0, yyvstop+6}, - {yycrank+19, 0, yyvstop+9}, - {yycrank+0, yysvec+5, yyvstop+12}, - {yycrank+0, yysvec+6, yyvstop+14}, - {0, 0, 0} + {0, 0, 0}, + {yycrank+-1, 0, 0}, + {yycrank+0, yysvec+1, 0}, + {yycrank+0, 0, yyvstop+1}, + {yycrank+0, 0, yyvstop+3}, + {yycrank+2, 0, yyvstop+6}, + {yycrank+19, 0, yyvstop+9}, + {yycrank+0, yysvec+5, yyvstop+12}, + {yycrank+0, yysvec+6, yyvstop+14}, + {0, 0, 0} }; /* 0x8d */ /* struct yywork *yytop = yycrank+141; */ @@ -268,66 +268,66 @@ struct yywork *yytop = yycrank+255; struct yysvf *yybgin = yysvec+1; /* - WARNING: this table contains one entry per character - in the execution character set and must match it. + WARNING: this table contains one entry per character + in the execution character set and must match it. */ char yymatch[] = { - 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , #ifdef CHARSETHACK - 01 ,011 ,012 ,01 ,01 ,012 ,01 ,01 , + 01 ,011 ,012 ,01 ,01 ,012 ,01 ,01 , #else - 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , + 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , #endif - 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , - 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , + 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 , + 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 , + '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' , + 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' , + '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' , + 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 , + '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, - 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,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, /* 0xc0 (petcii) @A... */ - 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , - 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'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 , + '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, + 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, #endif - 0 + 0 }; char yyextra[] = { - 0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0 }; -/* ncform 4.1 83/08/11 */ +/* ncform 4.1 83/08/11 */ int yylineno =1; # define YYU(x) x @@ -344,26 +344,26 @@ unsigned char testbreak=0; yylook() { - register struct yysvf *yystate, **lsp; - register struct yywork *yyt; - struct yysvf *yyz; - int yych; - struct yywork *yyr; + register struct yysvf *yystate, **lsp; + register struct yywork *yyt; + struct yysvf *yyz; + int yych; + struct yywork *yyr; /* # ifdef LEXDEBUG - int debug; + int debug; # endif */ - - char *yylastch; - - /* start off machines */ + + char *yylastch; + + /* start off machines */ /* # ifdef LEXDEBUG - debug = 1; + debug = 1; # else - debug = 0; + debug = 0; # endif */ @@ -372,298 +372,298 @@ yylook() # else #define debug 0 #endif - + #ifdef YYDEBUG - fprintf(yyout,"yylook()\n"); + fprintf(yyout,"yylook()\n"); # endif - - if (!yymorfg) - yylastch = yytext; - else - { - yymorfg=0; - yylastch = yytext+yyleng; - } + + if (!yymorfg) + yylastch = yytext; + else + { + yymorfg=0; + yylastch = yytext+yyleng; + } #ifdef YYDEBUG - fprintf(yyout,"yylook: yymorfg=%d\n",yymorfg); + fprintf(yyout,"yylook: yymorfg=%d\n",yymorfg); # endif - - for(;;) - { + + for(;;) + { #ifdef YYDEBUG - fprintf(yyout,"yylook: (outer loop)"); - printchar("yyprevious",yyprevious); + fprintf(yyout,"yylook: (outer loop)"); + printchar("yyprevious",yyprevious); # endif - lsp = yylstate; - yyestate = yystate = yybgin; - if (yyprevious==YYNEWLINE) yystate++; + lsp = yylstate; + yyestate = yystate = yybgin; + if (yyprevious==YYNEWLINE) yystate++; - testbreak=0; - - for (;;) - { + testbreak=0; + + for (;;) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: (inner loop) state %d\n",yystate-yysvec-1); + fprintf(yyout,"yylook: (inner loop) state %d\n",yystate-yysvec-1); # endif - if(testbreak==5) - { - fprintf(yyout,"yylook: error, aborted after 5 loops\n"); - exit(0); - } - testbreak++; - - yyt = yystate->yystoff; + if(testbreak==5) + { + fprintf(yyout,"yylook: error, aborted after 5 loops\n"); + exit(0); + } + testbreak++; + + yyt = yystate->yystoff; -/* fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); */ +/* fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); */ - - if(yyt == yycrank) - { /* may not be any transitions */ - yyz = yystate->yyother; - if(yyz == 0)break; - if(yyz->yystoff == yycrank)break; - } - *yylastch++ = yych = input(); + + if(yyt == yycrank) + { /* may not be any transitions */ + yyz = yystate->yyother; + if(yyz == 0)break; + if(yyz->yystoff == yycrank)break; + } + *yylastch++ = yych = input(); # ifdef LEXDEBUG - fprintf(yyout,"yylook: input "); - printchar("yych",yych); + fprintf(yyout,"yylook: input "); + printchar("yych",yych); # endif - - tryagain: + + tryagain: # ifdef LEXDEBUG -/* fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); */ - fprintf(yyout,"yylook: tryagain\n"); +/* fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); */ + fprintf(yyout,"yylook: tryagain\n"); # endif - yyr = yyt; + yyr = yyt; -/* fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ - - if ( yyt > yycrank) - { - yyt = yyr + yych; - if (yyt <= yytop && yyt->verify+yysvec == yystate) - { - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - { +/* fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ + + if ( yyt > yycrank) + { + yyt = yyr + yych; + if (yyt <= yytop && yyt->verify+yysvec == yystate) + { + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (1) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (1) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG - fprintf(yyout,"yylook: continue (1)\n"); + fprintf(yyout,"yylook: continue (1)\n"); # endif - goto contin; - } + goto contin; + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: ( yyt > yycrank)\n"); + fprintf(yyout,"yylook: ( yyt > yycrank)\n"); # endif - } + } # ifdef YYOPTIM - else if(yyt < yycrank) /* r < yycrank */ - { - yyt = yyr = yycrank+(yycrank-yyt); + else if(yyt < yycrank) /* r < yycrank */ + { + yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG - fprintf(yyout,"yylook: compressed state\n"); + fprintf(yyout,"yylook: compressed state\n"); # endif - yyt = yyt + yych; - if(yyt <= yytop && yyt->verify+yysvec == yystate) - { + yyt = yyt + yych; + if(yyt <= yytop && yyt->verify+yysvec == yystate) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: (1)\n"); + fprintf(yyout,"yylook: (1)\n"); # endif - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - { + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (2) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (2) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG - fprintf(yyout,"yylook: continue (2)\n"); + fprintf(yyout,"yylook: continue (2)\n"); # endif - goto contin; - - } + goto contin; + + } # ifdef LEXDEBUG /* - fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); - fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); - fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); + fprintf(yyout,"yylook: yych=%02x yymatch[yych]=%02x\n",yych,yymatch[yych]); + fprintf(yyout,"yylook: yyt offs: %02x\n",yyt-yycrank); + fprintf(yyout,"yylook: yyr offs: %02x\n",yyr-yycrank); */ # endif - yyt = yyr + YYU(yymatch[yych]); + yyt = yyr + YYU(yymatch[yych]); # ifdef LEXDEBUG /* - fprintf(yyout,"yylook: yyt offs: %02x <= yytop offs: %02x\n",yyt-yycrank,yytop-yycrank); - fprintf(yyout,"yylook: yyt->verify=%04x yysvec=%04x (yyt->verify+yysvec)=%04x == yystate=%04x\n",yyt->verify,yysvec,(yyt->verify+yysvec),yystate); + fprintf(yyout,"yylook: yyt offs: %02x <= yytop offs: %02x\n",yyt-yycrank,yytop-yycrank); + fprintf(yyout,"yylook: yyt->verify=%04x yysvec=%04x (yyt->verify+yysvec)=%04x == yystate=%04x\n",yyt->verify,yysvec,(yyt->verify+yysvec),yystate); */ - fprintf(yyout,"yylook: try fall back character\n"); + 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"); + fprintf(yyout,"yylook: (2a)\n"); # endif - - if(yyt->advance+yysvec == YYLERR) /* error transition */ - { + + if(yyt->advance+yysvec == YYLERR) /* error transition */ + { # ifdef LEXDEBUG -/* cc65 compiles this ?! fprintf(yyout,"yylook: unput (3) ",); */ - fprintf(yyout,"yylook: unput (3) "); - printchar("*yylastch",*yylastch); +/* cc65 compiles this ?! fprintf(yyout,"yylook: unput (3) ",); */ + fprintf(yyout,"yylook: unput (3) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - *lsp++ = yystate = yyt->advance+yysvec; + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance+yysvec; # ifdef LEXDEBUG -/* fprintf(yyout,"yylook: yyt offs: %02x yyt->advance=%d\n",yyt-yycrank,yyt->advance); */ - fprintf(yyout,"yylook: continue (3)\n"); +/* fprintf(yyout,"yylook: yyt offs: %02x yyt->advance=%d\n",yyt-yycrank,yyt->advance); */ + fprintf(yyout,"yylook: continue (3)\n"); # endif - goto contin; - - } + goto contin; + + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: (2)\n"); + fprintf(yyout,"yylook: (2)\n"); # endif - } - if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank) - { + } + if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank) + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: fall back to state %d\n",yystate-yysvec-1); + fprintf(yyout,"yylook: fall back to state %d\n",yystate-yysvec-1); # endif - goto tryagain; - } + goto tryagain; + } # endif - else - { + else + { # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (4) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (4) "); + printchar("*yylastch",*yylastch); # endif - unput(*--yylastch); - break; - } - contin: + unput(*--yylastch); + break; + } + contin: # ifdef LEXDEBUG - fprintf(yyout,"yylook: contin state=%d\n",yystate-yysvec-1); + fprintf(yyout,"yylook: contin state=%d\n",yystate-yysvec-1); # endif - ; - } + ; + } # ifdef LEXDEBUG - if (lsp == yylstate) - { - fprintf(yyout,"yylook: stopped (end)\n"); - } - else - { - fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); - } + if (lsp == yylstate) + { + fprintf(yyout,"yylook: stopped (end)\n"); + } + else + { + fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); + } # endif - while (lsp-- > yylstate) - { - *yylastch-- = 0; - if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0) - { - yyolsp = lsp; - if(yyextra[*yyfnd]) /* must backup */ - { - while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate) - { - lsp--; + while (lsp-- > yylstate) + { + *yylastch-- = 0; + if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0) + { + yyolsp = lsp; + if(yyextra[*yyfnd]) /* must backup */ + { + while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate) + { + lsp--; # ifdef LEXDEBUG - fprintf(yyout,"yylook: unput (5) "); - printchar("*yylastch",*yylastch); + fprintf(yyout,"yylook: unput (5) "); + printchar("*yylastch",*yylastch); # endif - unput(*yylastch--); - } - } - yyprevious = YYU(*yylastch); - yylsp = lsp; - yyleng = yylastch-yytext+1; - yytext[yyleng] = 0; + unput(*yylastch--); + } + } + yyprevious = YYU(*yylastch); + yylsp = lsp; + yyleng = yylastch-yytext+1; + yytext[yyleng] = 0; # ifdef LEXDEBUG - fprintf(yyout,"yylook: match action %d\n",*yyfnd); - fprintf(yyout,"yylook: done loops: %d\n",testbreak); + fprintf(yyout,"yylook: match action %d\n",*yyfnd); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); # endif - return(*yyfnd++); - } - unput(*yylastch); - } - if (yytext[0] == 0 /* && feof(yyin) */) - { - yysptr=yysbuf; + return(*yyfnd++); + } + unput(*yylastch); + } + if (yytext[0] == 0 /* && feof(yyin) */) + { + yysptr=yysbuf; # ifdef LEXDEBUG - fprintf(yyout,"yylook: done loops: %d\n",testbreak); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); # endif - return(0); - } - yyprevious = yytext[0] = input(); + return(0); + } + yyprevious = yytext[0] = input(); # ifdef LEXDEBUG - fprintf(yyout,"yylook: input "); - printchar("yyprevious",yyprevious); + fprintf(yyout,"yylook: input "); + printchar("yyprevious",yyprevious); # endif - if (yyprevious>0) - output(yyprevious); - yylastch=yytext; + if (yyprevious>0) + output(yyprevious); + yylastch=yytext; # ifdef LEXDEBUG -/* if(debug)putchar('\n'); */ +/* if(debug)putchar('\n'); */ # endif - } + } # ifdef LEXDEBUG - fprintf(yyout,"yylook: done loops: %d\n",testbreak); - fprintf(yyout,"yylook: return \n"); + fprintf(yyout,"yylook: done loops: %d\n",testbreak); + fprintf(yyout,"yylook: return \n"); # endif } - + yyback(p, m) - int *p; + int *p; { - if (p==0) return(0); - while (*p) - { - if (*p++ == m) - { - return(1); - } - } - return(0); + if (p==0) return(0); + while (*p) + { + if (*p++ == m) + { + return(1); + } + } + return(0); } - /* the following are only used in the lex library */ + /* the following are only used in the lex library */ yyinput() { - int out=input(); - + int out=input(); + #ifdef YYDEBUG - fprintf(yyout,"yylook: input "); - printchar("out",out); -#endif - return(out); + fprintf(yyout,"yylook: input "); + printchar("out",out); +#endif + return(out); } yyoutput(c) int c; { - output(c); + output(c); } yyunput(c) int c; { - unput(c); + unput(c); } main() @@ -689,8 +689,8 @@ char *s; short yyexca[] = { -1, 1, - 0, -1, - -2, 0, + 0, -1, + -2, 0, }; # define YYNPROD 15 @@ -762,7 +762,7 @@ short yydef[]= # define YYACCEPT return(0) # define YYABORT return(1) -/* parser for yacc output */ +/* parser for yacc output */ #ifdef YYDEBUG int yydebug = 1; /* 1 for debugging */ @@ -776,231 +776,231 @@ short yyerrflag = 0; /* error recovery flag */ yyparse() { - short yys[YYMAXDEPTH]; - short yyj, yym; - register YYSTYPE *yypvt; - register short yystate, *yyps, yyn; - register YYSTYPE *yypv; - register short *yyxi; + short yys[YYMAXDEPTH]; + short yyj, yym; + register YYSTYPE *yypvt; + register short yystate, *yyps, yyn; + register YYSTYPE *yypv; + register short *yyxi; - yystate = 0; - yychar = -1; - yynerrs = 0; - yyerrflag = 0; - yyps= &yys[-1]; - yypv= &yyv[-1]; + yystate = 0; + yychar = -1; + yynerrs = 0; + yyerrflag = 0; + yyps= &yys[-1]; + yypv= &yyv[-1]; yystack: /* put a state and value onto the stack */ #ifdef YYDEBUG - printf("yyparse: yystack\n"); + printf("yyparse: yystack\n"); #endif #ifdef YYDEBUG - printf("yyparse: yystate=%d, ", yystate); - printchar("yychar",yychar); + printf("yyparse: yystate=%d, ", yystate); + printchar("yychar",yychar); #endif - if( ++yyps> &yys[YYMAXDEPTH] ) - { - yyerror( "yyparse: yacc stack overflow" ); - return(1); - } - *yyps = yystate; - ++yypv; - *yypv = yyval; + if( ++yyps> &yys[YYMAXDEPTH] ) + { + yyerror( "yyparse: yacc stack overflow" ); + return(1); + } + *yyps = yystate; + ++yypv; + *yypv = yyval; yynewstate: #ifdef YYDEBUG - printf("yyparse: yynewstate\n"); + printf("yyparse: yynewstate\n"); #endif - yyn = yypact[yystate]; + yyn = yypact[yystate]; - if( yyn<= YYFLAG ) goto yydefault; /* simple state */ + if( yyn<= YYFLAG ) goto yydefault; /* simple state */ #ifdef YYDEBUG - printf("yyparse: yynewstate (1)\n"); + printf("yyparse: yynewstate (1)\n"); #endif - - if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; + + if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; #ifdef YYDEBUG - - printf("yyparse: yynewstate yyn=%d ",yyn); - printchar("yychar",yychar); + + printf("yyparse: yynewstate yyn=%d ",yyn); + printchar("yychar",yychar); #endif - - if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; + + if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; #ifdef YYDEBUG - printf("yyparse: yynewstate (2)\n"); + printf("yyparse: yynewstate (2)\n"); #endif - - if( yychk[ yyn=yyact[ yyn ] ] == yychar ) /* valid shift */ - { - yychar = -1; - yyval = yylval; - yystate = yyn; + + if( yychk[ yyn=yyact[ yyn ] ] == yychar ) /* valid shift */ + { + yychar = -1; + yyval = yylval; + yystate = yyn; #ifdef YYDEBUG - printf("yyparse: yynewstate (3)\n"); + printf("yyparse: yynewstate (3)\n"); #endif - if( yyerrflag > 0 ) --yyerrflag; - goto yystack; - } + if( yyerrflag > 0 ) --yyerrflag; + goto yystack; + } yydefault: #ifdef YYDEBUG - printf("yyparse: yydefault yystate=%d\n",yystate); + printf("yyparse: yydefault yystate=%d\n",yystate); #endif - /* default state action */ + /* default state action */ - if( (yyn=yydef[yystate]) == -2 ) - { - if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; - /* look through exception table */ + if( (yyn=yydef[yystate]) == -2 ) + { + if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; + /* look through exception table */ - for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ + for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ - while( *(yyxi+=2) >= 0 ) - { - if( *yyxi == yychar ) break; - } - if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ - } + while( *(yyxi+=2) >= 0 ) + { + if( *yyxi == yychar ) break; + } + if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ + } #ifdef YYDEBUG - printf("yyparse: yyn=%d yyerrflag=%d\n",yyn,yyerrflag); + printf("yyparse: yyn=%d yyerrflag=%d\n",yyn,yyerrflag); #endif - - if( yyn == 0 ) /* error */ - { - /* error ... attempt to resume parsing */ + + if( yyn == 0 ) /* error */ + { + /* error ... attempt to resume parsing */ - switch( yyerrflag ){ - case 0: /* brand new error */ + switch( yyerrflag ){ + case 0: /* brand new error */ - yyerror( "yyparse: syntax error" ); - yyerrlab: - ++yynerrs; + yyerror( "yyparse: syntax error" ); + yyerrlab: + ++yynerrs; - case 1: - case 2: /* incompletely recovered error ... try again */ + case 1: + case 2: /* incompletely recovered error ... try again */ - yyerrflag = 3; + yyerrflag = 3; - /* find a state where "error" is a legal shift action */ + /* find a state where "error" is a legal shift action */ - while ( yyps >= yys ) { - yyn = yypact[*yyps] + YYERRCODE; - if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ - yystate = yyact[yyn]; /* simulate a shift of "error" */ - goto yystack; - } - yyn = yypact[*yyps]; + while ( yyps >= yys ) { + yyn = yypact[*yyps] + YYERRCODE; + if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ + yystate = yyact[yyn]; /* simulate a shift of "error" */ + goto yystack; + } + yyn = yypact[*yyps]; - /* the current yyps has no shift onn "error", pop stack */ + /* the current yyps has no shift onn "error", pop stack */ #ifdef YYDEBUG - printf("yyparse: error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); + printf("yyparse: error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); #endif - --yyps; - --yypv; - } + --yyps; + --yypv; + } - /* there is no state on the stack with an error shift ... abort */ + /* there is no state on the stack with an error shift ... abort */ - yyabort: - return(1); + yyabort: + return(1); - case 3: /* no shift yet; clobber input char */ + case 3: /* no shift yet; clobber input char */ #ifdef YYDEBUG - printf("yyparse: error recovery discards char "); - printchar("yychar",yychar); + printf("yyparse: error recovery discards char "); + printchar("yychar",yychar); #endif - if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ - yychar = -1; - goto yynewstate; /* try again in the same state */ + if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ + yychar = -1; + goto yynewstate; /* try again in the same state */ - } + } - } + } - /* reduction by production yyn */ + /* reduction by production yyn */ #ifdef YYDEBUG - printf("yyparse: reduce %d\n",yyn); + printf("yyparse: reduce %d\n",yyn); #endif - yyps -= yyr2[yyn]; - yypvt = yypv; - yypv -= yyr2[yyn]; - yyval = yypv[1]; - yym=yyn; - /* consult goto table to find next state */ - 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; - } - 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"); - } - break; - case 12: - { - 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 */ + yyps -= yyr2[yyn]; + yypvt = yypv; + yypv -= yyr2[yyn]; + yyval = yypv[1]; + yym=yyn; + /* consult goto table to find next state */ + 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; + } + 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"); + } + break; + case 12: + { + 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; + return 1; } diff --git a/test/ref/yacc2.c b/test/ref/yacc2.c index 78d654ded..3b4819c55 100644 --- a/test/ref/yacc2.c +++ b/test/ref/yacc2.c @@ -10,105 +10,105 @@ # define YYTYPE char struct yywork { - YYTYPE verify, advance; + YYTYPE verify, advance; } yycrank[] = { - {0,0}, {0,0}, {1,3}, {0,0}, - {0,0}, {0,0}, {0,0}, {0,0}, - {0,0}, {0,0}, {1,4}, {1,3}, - {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,3}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {1,4}, {1,3}, + {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}, {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}, {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}, - {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}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0x40 */ - {0,0}, {0,0}, {1,6}, {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}, {0,0}, {1,6}, {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}, {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}, + {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}, + {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}, - {6,8}, {6,8}, {6,8}, {6,8}, + {0,0}, {0,0}, {6,8}, {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}, /* 0x80 */ - {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}, + {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}, #ifdef CHARSETHACK - {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}, {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}, {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}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, + {0,0}, {0,0}, {0,0}, {0,0}, /* 0xc0 */ - {0,0}, {0,0}, {1,6}, {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}, {0,0}, {1,6}, {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}, #endif - {0,0} + {0,0} }; struct yywork *yytop = yycrank+255; int yyvstop[] = { - 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 + 0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0 }; struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops; + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; }; struct yysvf yysvec[] = { - {0, 0, 0}, - {yycrank+-1, 0, 0}, - {yycrank+0, yysvec+1, 0}, - {yycrank+0, 0, yyvstop+1}, - {yycrank+0, 0, yyvstop+3}, - {yycrank+2, 0, yyvstop+6}, - {yycrank+19, 0, yyvstop+9}, - {yycrank+0, yysvec+5, yyvstop+12}, - {yycrank+0, yysvec+6, yyvstop+14}, - {0, 0, 0} + {0, 0, 0}, + {yycrank+-1, 0, 0}, + {yycrank+0, yysvec+1, 0}, + {yycrank+0, 0, yyvstop+1}, + {yycrank+0, 0, yyvstop+3}, + {yycrank+2, 0, yyvstop+6}, + {yycrank+19, 0, yyvstop+9}, + {yycrank+0, yysvec+5, yyvstop+12}, + {yycrank+0, yysvec+6, yyvstop+14}, + {0, 0, 0} }; #if 0 @@ -116,7 +116,7 @@ struct yysvf yysvec[] = // *yylastch++ = yych = input(); void subtest1(void) { - *yylastch++ = yych = input(); + *yylastch++ = yych = input(); } #endif @@ -125,26 +125,26 @@ static int bog=1234; #if 0 void bogus(void) { - bog*=0x1234; + bog*=0x1234; } #else -#define bogus() bog+=0x1234 +#define bogus() bog+=0x1234 #endif #if 1 // yyt = yyt + yych; void subtest2(void) { - register struct yywork *yyt; - int yych; + register struct yywork *yyt; + int yych; - yyt=yycrank; - yych=10; + yyt=yycrank; + yych=10; - bogus(); - yyt = yyt + yych; + bogus(); + yyt = yyt + yych; - printf("yyt: %d %d\n",yyt->verify,yyt->advance); + printf("yyt: %d %d\n",yyt->verify,yyt->advance); } #endif @@ -152,21 +152,21 @@ void subtest2(void) // if(yyt <= yytop && yyt->verify+yysvec == yystate) void subtest3(void) { - register struct yywork *yyt; - register struct yysvf *yystate; + register struct yywork *yyt; + register struct yysvf *yystate; - yyt=yycrank; - yystate=yysvec; - - bogus(); - if(yyt <= yytop && yyt->verify+yysvec == yystate) - { - printf("if ok %d %d\n",yyt->verify,yyt->advance); - } - else - { - printf("if not ok %d %d\n",yyt->verify,yyt->advance); - } + yyt=yycrank; + yystate=yysvec; + + bogus(); + if(yyt <= yytop && yyt->verify+yysvec == yystate) + { + printf("if ok %d %d\n",yyt->verify,yyt->advance); + } + else + { + printf("if not ok %d %d\n",yyt->verify,yyt->advance); + } } #endif @@ -179,19 +179,19 @@ short yyr2[]= // yyps -= yyr2[yyn]; void subtest4(void) { - register short *yyps, yyn; + register short *yyps, yyn; - yyps=0x8004; - yyn=0; + yyps=0x8004; + yyn=0; - while(yyn<14) - { - bogus(); - yyps -= yyr2[yyn]; + while(yyn<14) + { + bogus(); + yyps -= yyr2[yyn]; - yyn++; - } - printf("yyps: %04x\n",yyps); + yyn++; + } + printf("yyps: %04x\n",yyps); } #if 1 @@ -199,21 +199,21 @@ void subtest4(void) int yylookret=10; yylook() { - yylookret--; - return yylookret; + yylookret--; + return yylookret; } // while((nstr = yylook()) >= 0) void subtest5(void) { - int nstr; + int nstr; - bogus(); - while((nstr = yylook()) >= 0) - { - printf("nstr: %04x\n",nstr); - bogus(); - } + bogus(); + while((nstr = yylook()) >= 0) + { + printf("nstr: %04x\n",nstr); + bogus(); + } } #endif diff --git a/test/val/compare1.c b/test/val/compare1.c index 0127e3b1b..e9d2f7d4a 100644 --- a/test/val/compare1.c +++ b/test/val/compare1.c @@ -52,7 +52,7 @@ compare_char_to_lits1 (void) failures++; } -/* achar0 should be `5' */ +/* achar0 should be '5' */ void compare_char_to_lits2 (void) { @@ -106,7 +106,7 @@ compare_int_to_lits1 (void) failures++; } -/* aint0 should be `5' */ +/* aint0 should be '5' */ void compare_int_to_lits2 (void) { @@ -123,7 +123,7 @@ compare_int_to_lits2 (void) failures++; } -/* aint0 should be `0x1234' */ +/* aint0 should be '0x1234' */ void compare_int_to_lits3 (void) { diff --git a/test/val/compare5.c b/test/val/compare5.c index 9e0c97a63..f1d94d537 100644 --- a/test/val/compare5.c +++ b/test/val/compare5.c @@ -288,17 +288,17 @@ void c_minus1(void) printf("(long0 != -1)\n"); if(long0 != -1) { - failures++; + failures++; } printf("(long0 > 0)\n"); if(long0 > 0) { - failures++; + failures++; } printf("(long1 < 0)\n"); if(long1 < 0) { - failures++; + failures++; } /* if(long1 < 2) diff --git a/test/val/cq22.c b/test/val/cq22.c index bcd1570c8..015b7bf77 100644 --- a/test/val/cq22.c +++ b/test/val/cq22.c @@ -101,9 +101,9 @@ int s22(struct defs *pd0) #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s22(pd0); @@ -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 76f437e0c..1f66a378c 100644 --- a/test/val/cq241.c +++ b/test/val/cq241.c @@ -243,9 +243,9 @@ int s241(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s241(pd0); @@ -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 676c73182..aaec9a8ea 100644 --- a/test/val/cq243.c +++ b/test/val/cq243.c @@ -176,21 +176,21 @@ int s243(struct defs *pd0) { by a more failproof version if( - '\0' != 0 || - '\01' != 1 || - '\02' != 2 || - '\03' != 3 || - '\04' != 4 || - '\05' != 5 || - '\06' != 6 || - '\07' != 7 || - '\10' != 8 || - '\17' != 15 || - '\20' != 16 || - '\77' != 63 || - '\100' != 64 || - '\177' != 127 - ) + '\0' != 0 || + '\01' != 1 || + '\02' != 2 || + '\03' != 3 || + '\04' != 4 || + '\05' != 5 || + '\06' != 6 || + '\07' != 7 || + '\10' != 8 || + '\17' != 15 || + '\20' != 16 || + '\77' != 63 || + '\100' != 64 || + '\177' != 127 + ) */ if( ('0' != '\60') || @@ -201,7 +201,7 @@ int s243(struct defs *pd0) { ('z' != '\172') ) - { + { rc = rc+8; if(pd0->flgd != 0) { @@ -221,9 +221,9 @@ int s243(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s243(pd0); @@ -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 bedf51e95..9f4704f36 100644 --- a/test/val/cq244.c +++ b/test/val/cq244.c @@ -116,9 +116,9 @@ s244(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s244(pd0); @@ -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 9cb2f61c8..bfdade957 100644 --- a/test/val/cq25.c +++ b/test/val/cq25.c @@ -128,9 +128,9 @@ int s25(struct defs *pd0) { #define cq_sections 1 #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s25(pd0); @@ -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 399f0a45e..239411f1c 100644 --- a/test/val/cq26.c +++ b/test/val/cq26.c @@ -171,9 +171,9 @@ s26(struct defs *pd0) { *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -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 8a8125c52..a8b6b1d52 100644 --- a/test/val/cq4.c +++ b/test/val/cq4.c @@ -317,9 +317,9 @@ setev(){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -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 3dcca6454..fc4d1d95f 100644 --- a/test/val/cq61.c +++ b/test/val/cq61.c @@ -140,9 +140,9 @@ simply discarded. */ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -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 166d3a95b..a8b05c8f2 100644 --- a/test/val/cq626.c +++ b/test/val/cq626.c @@ -291,9 +291,9 @@ int s626(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -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 7bf0d9e1e..f7167c728 100644 --- a/test/val/cq71.c +++ b/test/val/cq71.c @@ -194,9 +194,9 @@ int *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -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 f4c58801f..d7a878033 100644 --- a/test/val/cq714.c +++ b/test/val/cq714.c @@ -1507,175 +1507,175 @@ initial (5,2) | (5,2) | (12,10) } #ifdef NO_FLOATS - fl = 5; cr = 2; - fl /= cr; - if(fl != 2){ - lrc = 232; - if(prlc) printf(f,lrc); - } - fl = 5; sr = 2; - fl /= sr; - if(fl != 2){ - lrc = 233; - if(prlc) printf(f,lrc); - } - fl = 5; ir = 2; - fl /= ir; - if(fl != 2){ - lrc = 234; - if(prlc) printf(f,lrc); - } - fl = 5; lr = 2; - fl /= lr; - if(fl != 2){ - lrc = 235; - if(prlc) printf(f,lrc); - } - fl = 5; ur = 2; - fl /= ur; - if(fl != 2){ - lrc = 236; - if(prlc) printf(f,lrc); - } - fl = 5; fr = 2; - fl /= fr; - if(fl != 2){ - lrc = 237; - if(prlc) printf(f,lrc); - } - fl = 5; dr = 2; - fl /= dr; - if(fl != 2){ - lrc = 238; - if(prlc) printf(f,lrc); - } - dl = 5; cr = 2; - dl /= cr; - if(dl != 2){ - lrc = 239; - if(prlc) printf(f,lrc); - } - dl = 5; sr = 2; - dl /= sr; - if(dl != 2){ - lrc = 240; - if(prlc) printf(f,lrc); - } - dl = 5; ir = 2; - dl /= ir; - if(dl != 2){ - lrc = 241; - if(prlc) printf(f,lrc); - } - dl = 5; lr = 2; - dl /= lr; - if(dl != 2){ - lrc = 242; - if(prlc) printf(f,lrc); - } - dl = 5; ur = 2; - dl /= ur; - if(dl != 2){ - lrc = 243; - if(prlc) printf(f,lrc); - } - dl = 5; fr = 2; - dl /= fr; - if(dl != 2){ - lrc = 244; - if(prlc) printf(f,lrc); - } - dl = 5; dr = 2; - dl /= dr; - if(dl != 2){ - lrc = 245; - if(prlc) printf(f,lrc); - } + fl = 5; cr = 2; + fl /= cr; + if(fl != 2){ + lrc = 232; + if(prlc) printf(f,lrc); + } + fl = 5; sr = 2; + fl /= sr; + if(fl != 2){ + lrc = 233; + if(prlc) printf(f,lrc); + } + fl = 5; ir = 2; + fl /= ir; + if(fl != 2){ + lrc = 234; + if(prlc) printf(f,lrc); + } + fl = 5; lr = 2; + fl /= lr; + if(fl != 2){ + lrc = 235; + if(prlc) printf(f,lrc); + } + fl = 5; ur = 2; + fl /= ur; + if(fl != 2){ + lrc = 236; + if(prlc) printf(f,lrc); + } + fl = 5; fr = 2; + fl /= fr; + if(fl != 2){ + lrc = 237; + if(prlc) printf(f,lrc); + } + fl = 5; dr = 2; + fl /= dr; + if(fl != 2){ + lrc = 238; + if(prlc) printf(f,lrc); + } + dl = 5; cr = 2; + dl /= cr; + if(dl != 2){ + lrc = 239; + if(prlc) printf(f,lrc); + } + dl = 5; sr = 2; + dl /= sr; + if(dl != 2){ + lrc = 240; + if(prlc) printf(f,lrc); + } + dl = 5; ir = 2; + dl /= ir; + if(dl != 2){ + lrc = 241; + if(prlc) printf(f,lrc); + } + dl = 5; lr = 2; + dl /= lr; + if(dl != 2){ + lrc = 242; + if(prlc) printf(f,lrc); + } + dl = 5; ur = 2; + dl /= ur; + if(dl != 2){ + lrc = 243; + if(prlc) printf(f,lrc); + } + dl = 5; fr = 2; + dl /= fr; + if(dl != 2){ + lrc = 244; + if(prlc) printf(f,lrc); + } + dl = 5; dr = 2; + dl /= dr; + if(dl != 2){ + lrc = 245; + if(prlc) printf(f,lrc); + } #else - fl = 5; cr = 2; - fl /= cr; - if(fl != 2.5){ - lrc = 232; - if(prlc) printf(f,lrc); - } - fl = 5; sr = 2; - fl /= sr; - if(fl != 2.5){ - lrc = 233; - if(prlc) printf(f,lrc); - } - fl = 5; ir = 2; - fl /= ir; - if(fl != 2.5){ - lrc = 234; - if(prlc) printf(f,lrc); - } - fl = 5; lr = 2; - fl /= lr; - if(fl != 2.5){ - lrc = 235; - if(prlc) printf(f,lrc); - } - fl = 5; ur = 2; - fl /= ur; - if(fl != 2.5){ - lrc = 236; - if(prlc) printf(f,lrc); - } - fl = 5; fr = 2; - fl /= fr; - if(fl != 2.5){ - lrc = 237; - if(prlc) printf(f,lrc); - } - fl = 5; dr = 2; - fl /= dr; - if(fl != 2.5){ - lrc = 238; - if(prlc) printf(f,lrc); - } - dl = 5; cr = 2; - dl /= cr; - if(dl != 2.5){ - lrc = 239; - if(prlc) printf(f,lrc); - } - dl = 5; sr = 2; - dl /= sr; - if(dl != 2.5){ - lrc = 240; - if(prlc) printf(f,lrc); - } - dl = 5; ir = 2; - dl /= ir; - if(dl != 2.5){ - lrc = 241; - if(prlc) printf(f,lrc); - } - dl = 5; lr = 2; - dl /= lr; - if(dl != 2.5){ - lrc = 242; - if(prlc) printf(f,lrc); - } - dl = 5; ur = 2; - dl /= ur; - if(dl != 2.5){ - lrc = 243; - if(prlc) printf(f,lrc); - } - dl = 5; fr = 2; - dl /= fr; - if(dl != 2.5){ - lrc = 244; - if(prlc) printf(f,lrc); - } - dl = 5; dr = 2; - dl /= dr; - if(dl != 2.5){ - lrc = 245; - if(prlc) printf(f,lrc); - } + fl = 5; cr = 2; + fl /= cr; + if(fl != 2.5){ + lrc = 232; + if(prlc) printf(f,lrc); + } + fl = 5; sr = 2; + fl /= sr; + if(fl != 2.5){ + lrc = 233; + if(prlc) printf(f,lrc); + } + fl = 5; ir = 2; + fl /= ir; + if(fl != 2.5){ + lrc = 234; + if(prlc) printf(f,lrc); + } + fl = 5; lr = 2; + fl /= lr; + if(fl != 2.5){ + lrc = 235; + if(prlc) printf(f,lrc); + } + fl = 5; ur = 2; + fl /= ur; + if(fl != 2.5){ + lrc = 236; + if(prlc) printf(f,lrc); + } + fl = 5; fr = 2; + fl /= fr; + if(fl != 2.5){ + lrc = 237; + if(prlc) printf(f,lrc); + } + fl = 5; dr = 2; + fl /= dr; + if(fl != 2.5){ + lrc = 238; + if(prlc) printf(f,lrc); + } + dl = 5; cr = 2; + dl /= cr; + if(dl != 2.5){ + lrc = 239; + if(prlc) printf(f,lrc); + } + dl = 5; sr = 2; + dl /= sr; + if(dl != 2.5){ + lrc = 240; + if(prlc) printf(f,lrc); + } + dl = 5; ir = 2; + dl /= ir; + if(dl != 2.5){ + lrc = 241; + if(prlc) printf(f,lrc); + } + dl = 5; lr = 2; + dl /= lr; + if(dl != 2.5){ + lrc = 242; + if(prlc) printf(f,lrc); + } + dl = 5; ur = 2; + dl /= ur; + if(dl != 2.5){ + lrc = 243; + if(prlc) printf(f,lrc); + } + dl = 5; fr = 2; + dl /= fr; + if(dl != 2.5){ + lrc = 244; + if(prlc) printf(f,lrc); + } + dl = 5; dr = 2; + dl /= dr; + if(dl != 2.5){ + lrc = 245; + if(prlc) printf(f,lrc); + } #endif cl = 5; cr = 2; cl %= cr; @@ -1750,9 +1750,9 @@ initial (5,2) | (5,2) | (12,10) *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s714(pd0); @@ -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 b4908f4cb..9538281b8 100644 --- a/test/val/cq714b.c +++ b/test/val/cq714b.c @@ -971,9 +971,9 @@ initial (5,2) | (5,2) | (12,10) *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s714(pd0); @@ -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 fec9c6170..0fe864159 100644 --- a/test/val/cq715.c +++ b/test/val/cq715.c @@ -105,9 +105,9 @@ int x, y, z; *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ /*case 0: return s26(pd0);*/ @@ -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 2f956e59d..421177a0b 100644 --- a/test/val/cq72.c +++ b/test/val/cq72.c @@ -299,9 +299,9 @@ int s72(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); @@ -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/cq757.c b/test/val/cq757.c index 60b588555..cf28f79e3 100644 --- a/test/val/cq757.c +++ b/test/val/cq757.c @@ -289,9 +289,9 @@ int s757(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s26(pd0); diff --git a/test/val/cq7813.c b/test/val/cq7813.c index 0e743abcd..9d4308a3e 100644 --- a/test/val/cq7813.c +++ b/test/val/cq7813.c @@ -336,9 +336,9 @@ int s7813(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s7813(pd0); @@ -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 0271cae5d..85e1ac1d6 100644 --- a/test/val/cq81.c +++ b/test/val/cq81.c @@ -682,9 +682,9 @@ test is unreliable. */ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s81(pd0); @@ -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 d37c82f29..64429e300 100644 --- a/test/val/cq84.c +++ b/test/val/cq84.c @@ -101,13 +101,13 @@ int s84(struct defs *pd0){ if(pd0->flgd != 0) printf(s84er,2); rc = rc+2; } - #else + #else pfi = glork; if((*pfi)(4) != 4){ if(pd0->flgd != 0) printf(s84er,2); rc = rc+2; } - #endif + #endif /* Float fa[17] declares an array of floating point numbers, and *afp[17] declares an array of pointers @@ -223,9 +223,9 @@ return x;} *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s84(pd0); @@ -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 15b055b20..49423e7de 100644 --- a/test/val/cq85.c +++ b/test/val/cq85.c @@ -118,10 +118,10 @@ int s85(struct defs *pd0){ #ifdef NO_FLOATS "signed", "signed", - #else + #else "float", "double" - #endif + #endif }; static char aln[] = " alignment: "; @@ -205,12 +205,12 @@ int s85(struct defs *pd0){ if(pd0->flgm != 0) printf("Sign extension in fields\n"); } else{ - #ifdef NO_BITFIELDS - if(pd0->flgd != 0) printf("NO_BITFIELDS\n"); - #else - if(pd0->flgd != 0) printf(s85er,2); - rc = rc+2; - #endif + #ifdef NO_BITFIELDS + if(pd0->flgd != 0) printf("NO_BITFIELDS\n"); + #else + if(pd0->flgd != 0) printf(s85er,2); + rc = rc+2; + #endif } } @@ -268,9 +268,9 @@ int one(); *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s85(pd0); @@ -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 9f2409e7a..9c850662a 100644 --- a/test/val/cq86.c +++ b/test/val/cq86.c @@ -183,9 +183,9 @@ int *metricp; *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s86(pd0); @@ -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 a15f75110..ef742824e 100644 --- a/test/val/cq88.c +++ b/test/val/cq88.c @@ -139,9 +139,9 @@ int s88(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s88(pd0); @@ -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/cq9.c b/test/val/cq9.c index 228ac9e77..c0f1f45ff 100644 --- a/test/val/cq9.c +++ b/test/val/cq9.c @@ -109,9 +109,9 @@ int s9(struct defs *pd0){ *********************************************************************************************/ #ifndef NO_TYPELESS_STRUCT_PTR - int section(int j,struct* pd0){ + int section(int j,struct* pd0){ #else - int section(int j,void* pd0){ + int section(int j,void* pd0){ #endif switch(j){ case 0: return s9(pd0); diff --git a/test/val/lz4.c b/test/val/lz4.c index dceefbfcc..6fe72e72d 100644 --- a/test/val/lz4.c +++ b/test/val/lz4.c @@ -660,10 +660,10 @@ static unsigned char buf[18830]; int main() { - unsigned long cksum = adler32(0, NULL, 0); + unsigned long cksum = adler32(0, NULL, 0); - decompress_lz4(compressed, buf, 18830); - cksum = adler32(cksum, buf, 18830); + decompress_lz4(compressed, buf, 18830); + cksum = adler32(cksum, buf, 18830); - return cksum == 0xf748269d ? 0 : 1; + return cksum == 0xf748269d ? 0 : 1; } diff --git a/test/val/nestfor.c b/test/val/nestfor.c index 735da21de..09f9d093d 100644 --- a/test/val/nestfor.c +++ b/test/val/nestfor.c @@ -21,10 +21,10 @@ unsigned char uchar1 = 0; void dput(unsigned char val) { - /*PORTB = val; - PORTA = 0x01; - PORTA = 0x00; - */ + /*PORTB = val; + PORTA = 0x01; + PORTA = 0x00; + */ } void done() @@ -35,104 +35,104 @@ void done() /* both loops use the loop variable inside the inner loop */ void for1(void) { - unsigned char i, j; + unsigned char i, j; - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(i); - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(i); + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* only the outer loop's variable is used inside, inner can be optimized into a repeat-loop */ void for2(void) { - unsigned char i, j; + unsigned char i, j; - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(i); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(i); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* only the inner loop's variable is used inside */ void for3(void) { - unsigned char i, j; + unsigned char i, j; - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* neither loop variable used inside the loops */ void for4(void) { - unsigned char i, j; + unsigned char i, j; - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 0; j < 4; j++) { - uchar1++; - dput(uchar0); - dput(uchar1); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 12) - failures++; + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 0; j < 4; j++) { + uchar1++; + dput(uchar0); + dput(uchar1); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 12) + failures++; } /* like for1 but different condition in inner loop */ void for5(void) { - unsigned char i, j; + unsigned char i, j; - uchar0 = 0; - uchar1 = 0; - for(i = 0; i < 3; i++) { - uchar0++; - for(j = 10; j >= 5; j--) { - uchar1++; - dput(i); - dput(j); - } - } - if(uchar0 != 3) - failures++; - if(uchar1 != 18) - failures++; + uchar0 = 0; + uchar1 = 0; + for(i = 0; i < 3; i++) { + uchar0++; + for(j = 10; j >= 5; j--) { + uchar1++; + dput(i); + dput(j); + } + } + if(uchar0 != 3) + failures++; + if(uchar1 != 18) + failures++; } int main(void) diff --git a/test/val/postincdec.c b/test/val/postincdec.c index 6d3e9593c..9a4f06183 100644 --- a/test/val/postincdec.c +++ b/test/val/postincdec.c @@ -10,14 +10,14 @@ static unsigned char val, array[2]; int main() { - val = 0; - array[0] = array[1] = 10; + val = 0; + array[0] = array[1] = 10; - array[val++] = 2; - array[val++] = 2; - --val; - array[val--] = 0; - array[val--] = 0; + array[val++] = 2; + array[val++] = 2; + --val; + array[val--] = 0; + array[val--] = 0; - return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; + return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; } diff --git a/test/val/ptrfunc.c b/test/val/ptrfunc.c index 55503e176..4aa23b77b 100644 --- a/test/val/ptrfunc.c +++ b/test/val/ptrfunc.c @@ -50,33 +50,33 @@ void done() void call0(void) { - uchar0++; + uchar0++; } void call1(void) { - uchar1++; + uchar1++; } unsigned char call2(void) { - return uchar0 + 9; + return uchar0 + 9; } void docall0(void) { - pfunc = call0; - (pfunc)(); - if(uchar0 != 1) - failures++; + pfunc = call0; + (pfunc)(); + if(uchar0 != 1) + failures++; } void docall1() { - unsigned char i; - for(i = 0; i < 3; i++) { - (*p1func)(); - } + unsigned char i; + for(i = 0; i < 3; i++) { + (*p1func)(); + } } #ifdef NO_IMPLICIT_FUNCPTR_CONV @@ -85,53 +85,53 @@ void docall2( void(*pf)(void) ) void docall2( void(*pf)() ) #endif { - unsigned char i; - for(i = 0; i < 2; i++) { - pf(); - } + unsigned char i; + for(i = 0; i < 2; i++) { + pf(); + } } int main(void) { docall0(); - p1func = call1; - docall1(); - if(uchar1 != 3) - failures++; - if(uchar0 != 1) - failures++; + p1func = call1; + docall1(); + if(uchar1 != 3) + failures++; + if(uchar0 != 1) + failures++; - p1func = call0; - docall1(); - if(uchar1 != 3) - failures++; - if(uchar0 != 4) - failures++; + p1func = call0; + docall1(); + if(uchar1 != 3) + failures++; + if(uchar0 != 4) + failures++; - docall2(call0); - if(uchar1 != 3) - failures++; - if(uchar0 != 6) - failures++; + docall2(call0); + if(uchar1 != 3) + failures++; + if(uchar0 != 6) + failures++; - docall2(call1); - if(uchar1 != 5) - failures++; - if(uchar0 != 6) - failures++; + docall2(call1); + if(uchar1 != 5) + failures++; + if(uchar0 != 6) + failures++; - pcfunc = call2; - uchar2 = (*pcfunc)(); - if(uchar2 != 15) - failures++; + pcfunc = call2; + uchar2 = (*pcfunc)(); + if(uchar2 != 15) + failures++; - uchar2 += (pcfunc)(); - uchar2 += pcfunc(); + uchar2 += (pcfunc)(); + uchar2 += pcfunc(); - success = failures; - done(); - printf("failures: %d\n",failures); + success = failures; + done(); + printf("failures: %d\n",failures); - return failures; + return failures; } diff --git a/test/val/trampoline-params.c b/test/val/trampoline-params.c index 890e43e5f..c05d8c06d 100644 --- a/test/val/trampoline-params.c +++ b/test/val/trampoline-params.c @@ -10,9 +10,9 @@ static unsigned char flag; static void trampoline_set() { - asm("ldy tmp4"); - asm("sty %v", flag); - asm("jsr callptr4"); + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); } #pragma wrapped-call(push, trampoline_set, 4) @@ -21,12 +21,12 @@ long adder(long in); long adder(long in) { - return in + 7; + return in + 7; } int main() { - flag = 0; + flag = 0; - return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; + return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; } diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c index d154a3da0..e2db839c8 100644 --- a/test/val/trampoline-varargs.c +++ b/test/val/trampoline-varargs.c @@ -10,14 +10,14 @@ static unsigned char flag; static void trampoline_set() { - // The Y register is used for variadics - save and restore - asm("sty tmp3"); + // The Y register is used for variadics - save and restore + asm("sty tmp3"); - asm("ldy tmp4"); - asm("sty %v", flag); + asm("ldy tmp4"); + asm("sty %v", flag); - asm("ldy tmp3"); - asm("jsr callptr4"); + asm("ldy tmp3"); + asm("jsr callptr4"); } #pragma wrapped-call(push, trampoline_set, 4) @@ -26,23 +26,23 @@ unsigned adder(unsigned char num, ...); unsigned adder(unsigned char num, ...) { - unsigned char i; - unsigned sum = 0; - va_list ap; - va_start(ap, num); + unsigned char i; + unsigned sum = 0; + va_list ap; + va_start(ap, num); - for (i = 0; i < num; i++) { - sum += va_arg(ap, unsigned); - } + for (i = 0; i < num; i++) { + sum += va_arg(ap, unsigned); + } - va_end(ap); + va_end(ap); - return sum; + return sum; } int main() { - flag = 0; + flag = 0; - return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; + return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; } diff --git a/test/val/trampoline.c b/test/val/trampoline.c index 63741b590..b2010f6f3 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -8,14 +8,14 @@ static unsigned char flag; static void trampoline_set() { - asm("ldy tmp4"); - asm("sty %v", flag); - asm("jsr callptr4"); + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); } void trampoline_inc() { - asm("inc %v", flag); - asm("jsr callptr4"); + asm("inc %v", flag); + asm("jsr callptr4"); } void func3() { @@ -25,7 +25,7 @@ void func3() { #pragma wrapped-call(push, trampoline_inc, 0) void func2() { - func3(); + func3(); } #pragma wrapped-call(push, trampoline_set, 4) @@ -36,14 +36,14 @@ void func1(void); #pragma wrapped-call(pop) void func1() { - func2(); + func2(); } int main(void) { - flag = 0; + flag = 0; - func1(); + func1(); - return flag == 5 ? 0 : 1; + return flag == 5 ? 0 : 1; } diff --git a/testcode/lib/atari/asm-xex.s b/testcode/lib/atari/asm-xex.s new file mode 100644 index 000000000..d2a8d0335 --- /dev/null +++ b/testcode/lib/atari/asm-xex.s @@ -0,0 +1,51 @@ +; Sample using ATARI file format, by "atari-xex.cfg" linker configuration. +; +; This is a very simple example, shows a message to the screen, waits and +; returns to DOS. +; +; Compile with: +; cl65 -tatari -Catari-xex.cfg asm-xex.s -o prog.xex + + .include "atari.inc" + +; Default RUNAD is "start", export that: + .export start + + +; Write string to screen +.proc puts + sta ICBAL + stx ICBAH + lda #PUTREC + sta ICCOM + ldx #$FF + stx ICBLL + inx + stx ICBLH + jsr CIOV + rts +.endproc + + +; Write a message and exit + +.proc start + lda #msg + jsr puts + + + ; Delay before returning to DOS + lda #0 + tax +loop: + inx + cpx #$FF + adc #0 + bcc loop + + rts +.endproc + +msg: .byte "Hello world", ATEOL + diff --git a/testcode/lib/atari/multi-xex.cfg b/testcode/lib/atari/multi-xex.cfg new file mode 100644 index 000000000..7558aa895 --- /dev/null +++ b/testcode/lib/atari/multi-xex.cfg @@ -0,0 +1,35 @@ +FEATURES { + STARTADDRESS: default = $2E00; +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; + # First memory segment in file, show message + LOADER: file = %O, start = $680, size = 128; + # First memory segment in file, load over COLOR registers: + COLOR: file = %O, start = $2C4, size = 5; + # Second memory segment, load at page 6: + PAGE6: file = %O, start = $600, size = 128; + # Third memory segment in file, load over SDLST register: + SDLST: file = %O, start = $230, size = 2; + # Main segment, load at "STARTADDRESS" + MAIN: file = %O, start = %S, size = $BC20 - %S; +} +FILES { + %O: format = atari; +} +FORMATS { + atari: runad = start, + initad = LOADER: show_load; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, optional = yes; + # Place segments in memory areas: + LOADER: load = LOADER, type = rw; + COLOR: load = COLOR, type = rw; + PAGE6: load = PAGE6, type = rw; + SDLST: load = SDLST, type = rw; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = ro optional = yes; + DATA: load = MAIN, type = rw optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; +} diff --git a/testcode/lib/atari/multi-xex.s b/testcode/lib/atari/multi-xex.s new file mode 100644 index 000000000..cdf43469d --- /dev/null +++ b/testcode/lib/atari/multi-xex.s @@ -0,0 +1,80 @@ +; Multiple segment ATARI file format sample, using custom linker script. +; +; This sample defines a custom display-list screen with no code, writing all +; memory areas directly. +; +; See the linker script (multi-xex.cfg) for the definition of memory areas and +; segments. +; +; Compile with: +; cl65 -tatari -Cmulti-xex.cfg multi-xex.s -o prog.xex + + .include "atari.inc" + + .macpack atari + +; Default RUNAD is "start", export that: + .export start, show_load + +; Loader + .segment "LOADER" +show_load: + ldx #0 ; channel 0 + lda #msg_load + sta ICBAH,x + lda #$FF + sta ICBLL,x ; length + sta ICBLH,x + lda #PUTREC + sta ICCOM,x + jmp CIOV + +msg_load: + .byte "Loading....", ATEOL + +; We load color values directly into registers + .segment "COLOR" + + .byte $16 ; COLOR0 + .byte $46 ; COLOR1 + .byte $00 ; COLOR2 + .byte $6A ; COLOR3 + .byte $82 ; COLOR4 + +; We load our display list over page 6 + .segment "PAGE6" + +display_list: + .byte DL_BLK8 + .byte DL_BLK8 + .byte DL_BLK8 + .byte DL_BLK8 + .byte DL_BLK8 + .byte DL_BLK8 + .byte DL_CHR20x8x2 | DL_LMS + .word screen_memory + .byte DL_CHR40x8x1 + .byte DL_JVB + .word display_list + +screen_memory: + ; first text line: 20 bytes + scrcode " HeLlO wOrLd! " + ; second text line, 40 bytes + .byte 0, 0, 0, 0, 0, 0, 0, 0,70,71,70,71,70,71,70,71,70,71,70,71 + .byte 70,71,70,71,70,71,70,71,70,71,70,71, 0, 0, 0, 0, 0, 0, 0, 0 + +; We write directly to the display list pointer + .segment "SDLST" + .word display_list + +; And we load our main program + .code + +.proc start + ; Jump forever + jmp start +.endproc + diff --git a/testcode/lib/atari/multi.xex b/testcode/lib/atari/multi.xex new file mode 100644 index 000000000..7da39ad47 Binary files /dev/null and b/testcode/lib/atari/multi.xex differ diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 3a8d72226..56ed82a79 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -13,7 +13,7 @@ psa: .word 0 .bss temp_x: .byte 0 temp_y: .byte 0 -temp_a: .byte 0 +temp_a: .byte 0 irq_count: .byte 0 nmi_count: .byte 0 psx: .byte 0 @@ -419,4 +419,3 @@ printsign1: ldy temp_y rts .endproc - diff --git a/testcode/lib/mouse-test.c b/testcode/lib/mouse-test.c index 2e316c4c6..ea8311d19 100644 --- a/testcode/lib/mouse-test.c +++ b/testcode/lib/mouse-test.c @@ -7,7 +7,7 @@ ** ** Compile with "-DSTATIC_MOUSE" to statically link all available drivers. ** Compile with "-DMOUSE_DRIVER=" to statically link the given driver. -** E.g., -DMOUSE_DRIVER=atrsts_mou to just link with the Atari ST mouse driver. +** E.g., -DMOUSE_DRIVER=atrst_mou to just link with the Atari ST mouse driver. */