diff -Nru avra-1.3.0/AUTHORS avra-1.4.2+dfsg/AUTHORS --- avra-1.3.0/AUTHORS 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/AUTHORS 2020-07-18 23:19:00.000000000 +0000 @@ -1 +1,43 @@ -See README.txt in the doc folder for a list of authors of AVRA +We would like to thank the following people for giving contributions, +patches and bug reports, as well as suggestions and new ideas. + +Jon Anders Haugum (project founder) +Burkhard Arenfeld (release 1.2.0) +Tobias Weber (old maintainer, enhanced macro support) +Jerry Jacobs (release 1.3.0) +Bernt Hembre +Nils Strøm +Roberto Biancardi +Qwerty Jones +Ben Hitchcock (Maker of the mac port) +Daniel Drotos +Laurence Boyd II +Varuzhan Danielyan +Laurence Turner +Eugene R. O'Bryan +Dmitry Dicky +Bob Harris (Maker of coff support) +Lesha Bogdanow +Jim Galbraith +Mark Brinicombe +Igor Nikolayenko +Peter Hettkamp +Herb Poppe +David Burke +Alexey Pavluchenko +Alan Probandt +Mariusz Matuszek +Arne Rossius +Marti Tichacek +Patrick Parity +Johannes Overmann +Roland Riegel +Peter Katzmann +Donald D. Davis +Virgil Dupras (old maintainer, 1.4.{0,1} releases) +Tomek Szczęsny +Robert Russell + +And all the anonymous people who submitted patches! + +Thank you for your work and support. diff -Nru avra-1.3.0/Build avra-1.4.2+dfsg/Build --- avra-1.3.0/Build 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/Build 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# -# AVRA Build and Release helper script -# source this in the root directory of avra and then invoke one of the -# functions to create a release. This is very hackish, but makes life easier. -VERSION="1.3.0" # Change to new version -OS_TYPE="source" # Change to linux, mingw32, apple or source - -# This doesn't normaly have to be changed -ROOT_DIR="${PWD}" -BUILD_DIR="${PWD}/release" -DOC_DIR="${PWD}/doc" -EXAMPLES_DIR="${PWD}/examples" -INCLUDES_DIR="${PWD}/includes" -SOURCE_DIR="${PWD}/src" -ARCHIVE_DIR="${PWD}/archives" -MISC_FILES="ChangeLog,README,README.html,COPYING,NEWS,AUTHORS" -LINUX_BUILD="avra-${VERSION}-linux-i386-static" -SOURCE_BUILD="avra-${VERSION}-src" - - -function avra-build-source { - echo "Creating ${SOURCE_BUILD} release" - mkdir -p ${BUILD_DIR}/${SOURCE_BUILD} - cp -Rvf ${ROOT_DIR} ${BUILD_DIR}/${SOURCE_BUILD} - cd ${BUILD_DIR} - tar -cjvf ${SOURCE_BUILD}.tar.bz2 ${SOURCE_BUILD}/ - cp ${SOURCE_BUILD}.tar.bz2 ${ARCHIVE_DIR} - cd ${ARCHIVE_DIR} - sha1sum * > ${ARCHIVE_DIR}/SHA1SUM - cd ${ROOT_DIR} - rm -R ${BUILD_DIR} - cat ${ARCHIVE_DIR}/SHA1SUM - -} - -function avra-build-linux { - echo "Creating ${LINUX_BUILD} release" - asciidoc README - mkdir -p ${BUILD_DIR}/${LINUX_BUILD} - mkdir -p ${ARCHIVE_DIR} - cd ${SOURCE_DIR} - make -f makefiles/Makefile.linux - cp avra ${BUILD_DIR}/${LINUX_BUILD} - make -f makefiles/Makefile.linux clean - cp -R ${DOC_DIR} ${BUILD_DIR}/${LINUX_BUILD} - cp -R ${EXAMPLES_DIR} ${BUILD_DIR}/${LINUX_BUILD} - cp -R ${INCLUDES_DIR} ${BUILD_DIR}/${LINUX_BUILD} - cd ${BUILD_DIR} - tar -cjvf ${LINUX_BUILD}.tar.bz2 ${LINUX_BUILD}/ - cp ${LINUX_BUILD}.tar.bz2 ${ARCHIVE_DIR} - cd ${ARCHIVE_DIR} - sha1sum * > ${ARCHIVE_DIR}/SHA1SUM - cd ${ROOT_DIR} - rm -R ${BUILD_DIR} - cat ${ARCHIVE_DIR}/SHA1SUM -} - -function avra-build-apple { - echo "Creating avra-${VERSION}-osx release" - mkdir -p release/avra-${VERSION}-osx - cd ./src - make -f makefiles/Makefile.osx - cp avra ../release/avra-${VERSION}-osx - zip -r avra-${VERSION}-osx.zip . -i avra-${VERSION}-osx/ - cd .. -} - -function avra-build-windows-mingw32 { - echo "Creating avra-${VERSION}-win32 release" - mkdir -p release/avra-${VERSION}-win32 - cd ./src - make -f makefiles/Makefile.mingw32 - cp avra.exe ../release/avra-${VERSION}-win32 - make -f makefiles/Makefile.mingw32 clean - cd ../release - zip -r avra-${VERSION}-win32.zip . -i avra-${VERSION}-win32/ - cd .. -} - -if [ $OS_TYPE == "linux" ]; then - avra-build-linux -fi - -if [ $OS_TYPE == "source" ]; then - avra-build-source -fi diff -Nru avra-1.3.0/CHANGELOG.md avra-1.4.2+dfsg/CHANGELOG.md --- avra-1.3.0/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/CHANGELOG.md 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,232 @@ +# ARVA Change log + +## Release 1.4.2 (2020-07-18, by Burkhard Arenfeld, Robert Russell, and others) + +- Remove bug with wrong start of DSEG for processors with SRAM start != 0x60 +- Fix segment check for SRAM. End address wasn't correct calculated +- Fix wrong flash size of ATtiny20 and ATmega2560 +- Fix wrong RAM size and flags of ATtiny10 +- Add support for ATmega164P/PA, ATmega324P/PA, ATmega644P/PA, ATmega1284P/PA, + ATmega8A, ATtiny261A, ATtiny461A, ATtiny861A, ATtiny4, ATtiny5, ATtiny9, + ATmega128A, ATmega48A/P/PA, ATmega88A/P/PA, ATmega168A/P/PA, ATmega328/P/PB +- Changed width of name column for nicer printing in --devices +- Add some device definitions in include directory +- Fix ifdef and ifndef (again) +- Fix DSEG overlap detection with .BYTE directives +- Enhance regression testing system +- Remove long copyright notice from command line title + +## Release 1.4.1 (2019-04-24) + +- Add support for ATtiny48/88 +- Improve build process for MacOs + +## Release 1.4.0 (2019-02-26) + +- Fix broken .ifndef logic. +- Define X, Y, Z 16-bit register pairs. +- Don't clear register alias definitions before pass 2 of the assembly. +- Improve build system. +- Improve listfile output. +- Improve overlapping code processing. +- Add support for Attiny20 with AVR8L core. +- Add support for ATMega1280 and ATMega2560. +- Improve command line processing. +- Don't generate empty COFF files. +- Improve .BYTE directive checks that it's in a proper section. +- Don't erase values of variables when entering second pass. +- Fix long name of -I option, should be --includedir. +- Handle long lines properly. +- Allow forward references to labels within macros. +- Make output filename control command line flags (-o, -e, -d) effective. +- Add automated tests. +- Add default include path defined at compile time. + +## Release 1.3.0 (2010-06-28, by Jerry Jacobs) + +- Added new targets, ATtiny13A, ATtiny24/A, ATtiny44/A, ATtiny84, ATtiny2313A, ATtiny4313, ATmega328P +- Added mingw32 support for building windows binairies from linux host +- Removed obsolete Dev-C++ for windows building +- Updated documentation and rewritten in asciidoc markup language +- FIXED: 1934647: Handle also # directives because include files don’t use . directives. +- FIXED: 1970530: Make whitespace character possible between function name and open bracket. +- FIXED: 1970630: Make line continuation possible with backslash as the last character of a line. +- FIXED: 2929406: Change incorrect argument --includedir to includepath. + +## Release 1.2.3 (2007-11-15, bug fix by Burkhard Arenfeld) + +- Fix bug 1697037 (Error with single character ';') +- Better check for line termination. Now a single CR or a FF generates an warning message. Code with bad CR + termination could appear, if you edit CR-LF terminated files (WIN/DOS) with linux (LF only) editors. +- Fix bug 1462900 (Segfault, if error in -D parameter) +- Fix bug 1742436 (Error in .dseg size check) +- Fix bug 1742437 (Error in EEPROM presence check) +- Add patch 1604128 from Jim Galbraith (New devices ATtiny25/45/85, small fix for ATmega8 (no jmp, call instruction)) +- Fix bug in handling of special tags (%HOUR% ...). A % without a special tag was replaced by previous tag value. +- Use a global timestamp for all functions which needs a time (pi->time). +- Fix bug in handling of unknown args (E.g.: avra --abc -> Segfault). +- Fix segfault if .error directive without parameter is used. +- Add a warning, if characters with code > 127 are used in .db strings and fix listing output. +- Take a look at Testcode_avra-1_2_3.asm, which demonstrate some differences between 1.2.3 and previous releases +- AVR000.zip contains some header files for different devices. +- Included avra binary was created with ubuntu 7.10 linux + +## Release 1.2.2 (2007-05-11, better error checks by Burkhard Arenfeld) +- Check in print_msg() if filename is NULL. Avoid printing a NULL-Pointer. +- Warning, if no .DEVICE was found, because address range check doesn't work without it +- Error, if more than one .DEVICE was found. +- Error, if .DEVICE is after any assembled code or .ORG directive, because .DEVICE resets the address + counters and the assembler builds wrong code. +- Create a list of program segments (see orglist). Every .ORG, .DEVICE, .?SEG is stored, so the + assembler now can check for overlapping segments. Now overlapped segments in Flash, Data or EEPROM memory + are detected. Very usefull, if .ORG is used to build tables or bootloader code at specific addresses. +- Better check for exceeding device space in RAM, Flash or EEPROM memory. Now not the total count of + assembled memory is used, instead every assembled address range is checked. +- .DSEG and .ESEG now generates an error, if device has no RAM / EEPROM. +- Now a warning appears, if a .DEF name is already used as constant or label. Atmel assembler generates this + warning, too. +- Fix a small bug in the example program. + +## Release 1.2.1 (2006-11-17, bug fix by Roland Riegel) + +- Some of the high end AVRs use the SRAM adress range from 0x60 to 0x100 for IO extension. + Avra so far used to start with SRAM Usage at 0x60. This is now set from case by case. + +## Release 1.2.0 (2006-10-15, released by Burkhard Arenfeld) + +- Patch segfault, if .error is given without parameter +- Patch segfault, if .device is given with an invalid parameter +- Check in predef_dev() if symbol is already defined. Can happens, if someone + tries to define the symbol with the -D parameter. E.g.: `avra -D __ATMEGA8__ Test.asm` + now generate error message, because `__ATMEGA8__` is reserved +- Add .elseif directive. It's the same like .elif. (Original Atmel assembler use .elseif + and not .elif) +- In .db lines strings can now contain ',' and ';' characters. +- Allow forward declaration of constants (.equ) except for .ifdef and .ifndef. + Invalid forward declarations are checked now. (In the first pass undefined Symbols in + .ifdef and .ifndef parameters are stored in a 'blacklist' and checked in the second pass) +- Extend the .message directive for better debugging. Now it accept not only a String. + You can use a list of expressions like in a .db directive as parameter. +- The assembler 'pass' variable moved into the pi struct. I deleted the pass variable from + a lot of functions. +- New functions in avra.c. It was easier for me, to understand the code without the + for(label = first; ...)-loops. Replaced a lot of for(label = ...) -loops by one of this + functions. + +## Release 1.1.1 (2006-09-06) + +- right shift operator bug +- LPM is supported on ATtiny26 but avra say it isn't +- bugfix for jmp/call opcode +- crash due to a strcmp with null pointer when parsing the cmd line args + +## Release 1.1.0 (2005-12-27, released by Tobias Weber) + +- .DW defines were missing in the listfile. +- Support for mega8515. +- Fix for generic register names and extended macro syntax. +- Makefile for lcc-win32 Compiler. +- Changed "global" keyword to ".global". +- Added .includepath directive that allows setting include path. +- segfault when not passing any sourcefiles. +- --define FOO=2 does not work as claimed by the documentation. +- Added return value, indicating whether avra failed or succeded. +- Added support for automake utilities. See manual for more info. +- if no code is present, eeprom hex file will be written anyway. +- added -W NoRegDef for suppressing Register assignment warnings. +- .db values were sometimes wrong printed in lst file with 6 leading F. +- Added BYTE1() function equivalent to LOW(). +- The character " (pharentesis) could not be use as single character like '"' + +## Release 1.0.1 (2004-06-10, released by Tobias Weber) + +- Added meta tags for time and date. +- Expression of .elif was cutted off in list file - fixed. +- .equ, .org, .defines added to list file output. +- Values and expressions of .db assignemts are now listed in listfile. +- Added Support for ATmega48, ATmega88 and ATmega168. +- Added .include error file name print out. +- Fixed seg fault that could happen while using .LIST directive with no + listfile switched on. +- Error when using comments within macros that made use of sign @ fixed. +- Listfile lines are now prefixed with the current segment C,D,E for + code, data and eeprom. + +## Release 1.0.0 (2004-02-14, released by Tobias Weber) + +- Added support for ATtiny13 and ATtiny2313 +- List file command line syntax now AVRASM compatible +- Map file command line syntax now AVRASM compatible +- Fixed problem with limited macro label running numbers +- Now multiple labels can be used within macros +- Fixed error output line number for included files +- code cleaned up + +## Release 0.9.1 (2003-06-02, released by Tobias Weber) + +- fixed code for Linux compiler +- fixed nested macro labels +- code cleaned up + +## Release 0.9 (2003-05-23, released by Tobias Weber) + +- Added labels to macros +- Added special codes 'dst' and 'src' +- Added directive .endmacro, only .endm was allowed so far +- Added a return(0); at the end of main() to quiet the Borland C++ 5.5 + compiler (Jim Galbraith) +- Fixed wrong flash size calculation (Jim Galbraith) +- In device.c, added ATtiny26 to struct device device_list[] (Jim Galbraith) + +## Release 0.8 (2003-03-07, released by Tobias Weber) + +- Added new macro assembler coding facilities +- Added error description for .include directives + +## Release 0.7 (2000-02-17) + +- Added supported() function to check in a .if if a instruction is + supported (From Lesha Bogdanow ). +- Added checking of which mnemonic that work on the different AVRs + (From Lesha Bogdanow ). +- Added constants `__DEVICE__`, `__FLASH_SIZE__`, `__RAM_SIZE__` and + `__EEPROM_SIZE__` (From Lesha Bogdanow ). +- Added tiny devices (From Lesha Bogdanow ). +- Changed error on constant out of range into a warning. +- Added support for instructions: (E)LPM Rd,Z(+), SPM, ESPM, BREAK, + MOVW, MULS, MULSU, FMUL, FMULS, FMULSU +- Added support for new devices: ATmega8, ATmega16, ATmega32, + ATmega128, ATmega162, ATmega163, ATmega323, AT94K +- Added --devices switch to list all supported devices. +- Fixed bug in map file name when the name had more than one . (dot) +- Added option --includedirs to add additional include dirs in + search path. +- Added support for creation of intel hex 32 files to be able to + address memory above 64KB. Uses 02 records for addresses up to 1MB + and 04 record for addresses above 1MB. + +## Release 0.6 (2000-01-24) + +- Added COFF support from Bob Harris + +## Release 0.5 (1999-03-31) + +- Bugfix: a inline string copy did not terminate string. +- Fixed bug causing --define symbol=value not to work. +- Added output of memory usage. +- Fixed bug when there was a { in a comment. +- Fixed count for data segment. +- Fix to make a forward referenced label in .db/.dw work. +- Added ATmega161 and ATtiny15 in list. +- rjmp and rcall now wraps around with 4k word devices. +- Fixed bug when branching backwards with BRBS or BRBC + +## Release 0.4 (1999-02-02) + +- Added support for global keyword to use on labels in macros. +- Fixed get_next_token to handle commas inside ' ' +- Fixed bug when searching for correct macro_call, so recursive + and nested macros will work. +- Now handles commas in strings. +- Added fix to handle semi colon in a string. +- Improved mnemonic parsing for ld and st diff -Nru avra-1.3.0/debian/avra.1 avra-1.4.2+dfsg/debian/avra.1 --- avra-1.3.0/debian/avra.1 2013-08-23 19:46:55.000000000 +0000 +++ avra-1.4.2+dfsg/debian/avra.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -.TH avra 1 "May 8, 2010" "Atmel AVR Assembler" "Atmel AVR Assembler" - -.SH NAME -avra - Assembler for the Atmel AVR microcontroller family -.SH SYNOPSIS -.B avra -[\fB\-f\fR] [\fBO\fR|\fBM\fR|\fBI\fR|\fBG\fR\fR] output file type - [\fB\-o\fR \fIoutfile\fR] output file name - [\fB\-l\fR \fIlistfile\fR] generate list file - [\fB\-m\fR \fImapfile\fR] generate map file - [\fB\-\-define\fR \fIsymbol[=value]\fR] [\fB\-\-includepath\fR \fIpath\fR] [\fB\-listmac\fR] - [\fB\-\-max_errors\fR \fInumber\fR] [\fB\-\-devices\fR] [\fB\-\-version\fR] - [\fB\-h\fR] [\fB\-\-help\fR] general help - \fIinfile\fR -.SH DESCRIPTION -\fBAVRA\fR is an assembler for Atmel AVR microcontrollers, and it is almost -compatible with Atmel's own assembler AVRASM32. The differences between the -two are: -.IP "Support for some extra preprocessor directives." -includes: .define, .undef, .ifdef, .ifndef, .if, .else, .endif, .elif, .elseif, .warning -.IP "Not all command line options are supported." -Specifying an eeprom file (\-e) is not supported. All eeprom data is -put out into a file called program.eep.hex and always Intel hex -format. Other hex file formats than Intel are currently not supported. -.IP "Forward references are not supported." -Like in C, you have to define everything before you are using it, -excepting labels. This makes sure, that directives like .ifdef and .undef -are working properly. If you are familiar with the C programming -language, you should get easily into \fBAVRA\fR. See chapter "Programming -techniques" for more information about how to write proper code. -.IP "Enhanced macro support." -\fBAVRA\fR has some new features for writing flexible macros. This should -increase the ability to reuse code e.g. build your own library. -.IP "Debugging support." -\fBAVRA\fR creates a coff file everytime the assembly was sucessful. This -file allows AVR Studio or any coff compatible debugger to simulate -or emulate the program. -.IP "Meta tags for assembly time." -This helps you tracking versions of your software and can also be -used to generate customer specific serial numbers. -.SH OPTIONS -Several option can be given after one '\-', but if an option requires an -argument; the argument must be given after that option. -.TP -.B \-\-listfile, \-l -Create list file -.TP -.B \-\-mapfile, \-m -Create map file -.TP -.B \-\-define, \-D -Define symbol. -.TP -.B \-\-includepath, \-I -Additional include paths. -.TP -.B \-\-listmac -List macro expansion in listfile. -.TP -.B \-\-max_errors -Maximum number of errors before exit (default: 10) -.TP -.B \-\-devices -List out supported devices. -.TP -.B \-\-version -Version information. -.TP -.B \-\-help, \-h -Show summary of options. -.SH "SEE ALSO" -.BR avrp (1) -.SH AUTHOR -The initial version of AVRA was written by John Anders Haugum. He released -all versions until v0.7. Later versions were released by Tobias Weber. Version -1.3.0 was released by Jerry Jacobs. diff -Nru avra-1.3.0/debian/avra.docs avra-1.4.2+dfsg/debian/avra.docs --- avra-1.3.0/debian/avra.docs 2013-08-23 19:40:47.000000000 +0000 +++ avra-1.4.2+dfsg/debian/avra.docs 2023-03-22 04:48:12.000000000 +0000 @@ -1 +1,3 @@ -doc/README.txt +README.md +USAGE.md +AUTHORS diff -Nru avra-1.3.0/debian/avra.install avra-1.4.2+dfsg/debian/avra.install --- avra-1.3.0/debian/avra.install 2013-08-02 04:26:11.000000000 +0000 +++ avra-1.4.2+dfsg/debian/avra.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -includes/* usr/share/avra/ diff -Nru avra-1.3.0/debian/avra.manpages avra-1.4.2+dfsg/debian/avra.manpages --- avra-1.3.0/debian/avra.manpages 2013-08-02 02:26:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/avra.manpages 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian/avra.1 diff -Nru avra-1.3.0/debian/changelog avra-1.4.2+dfsg/debian/changelog --- avra-1.3.0/debian/changelog 2016-05-24 03:54:29.000000000 +0000 +++ avra-1.4.2+dfsg/debian/changelog 2023-03-22 12:56:51.000000000 +0000 @@ -1,3 +1,22 @@ +avra (1.4.2+dfsg-1) unstable; urgency=medium + + * new upstream release (closes: #969580) + * switch to DEP-14 repo packaging layout + * d/watch: new upstream location + * d/copyright: update + * d/control: new upstream location + * remove outdated man page + * remove upstream applied patches + * help output update patch + * update build rules, debhelper compat to 12 + * produce avra manual page + * update standards version to 4.6.2 + * do not suggest obsolete avrprog and avrp packages + * add autopkgtest + * fix usage description typos + + -- Milan Kupcevic Wed, 22 Mar 2023 08:56:51 -0400 + avra (1.3.0-3) unstable; urgency=medium * Use hardening options. diff -Nru avra-1.3.0/debian/compat avra-1.4.2+dfsg/debian/compat --- avra-1.3.0/debian/compat 2013-08-23 19:02:55.000000000 +0000 +++ avra-1.4.2+dfsg/debian/compat 2023-03-22 04:48:12.000000000 +0000 @@ -1 +1 @@ -9 +12 diff -Nru avra-1.3.0/debian/control avra-1.4.2+dfsg/debian/control --- avra-1.3.0/debian/control 2016-05-23 03:38:54.000000000 +0000 +++ avra-1.4.2+dfsg/debian/control 2023-03-22 12:55:53.000000000 +0000 @@ -1,15 +1,20 @@ Source: avra Section: electronics -Priority: extra +Priority: optional Maintainer: Milan Kupcevic -Build-Depends: debhelper (>= 9.0.0), autoconf, automake -Standards-Version: 3.9.8 -Homepage: http://avra.sourceforge.net +Build-Depends: + debhelper (>= 12), + automake, + help2man +Standards-Version: 4.6.2 +Vcs-Git: https://salsa.debian.org/debian/avra.git +Vcs-Browser: https://salsa.debian.org/debian/avra +Homepage: https://github.com/Ro5bert/avra Package: avra Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Suggests: avrdude, avrprog, avrp +Suggests: avrdude Description: assembler for Atmel AVR microcontrollers Avra is an assembler for the Atmel's family of AVR 8-bit RISC microcontrollers. It is mostly compatible with Atmel's own assembler, diff -Nru avra-1.3.0/debian/copyright avra-1.4.2+dfsg/debian/copyright --- avra-1.3.0/debian/copyright 2013-09-10 03:29:28.000000000 +0000 +++ avra-1.4.2+dfsg/debian/copyright 2023-03-22 04:47:00.000000000 +0000 @@ -1,43 +1,36 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: AVRA -Source: http://avra.sf.net -License: GPL-2+ +Upstream-Name: AVRA - Assembler for the Atmel AVR microcontroller family +Source: https://github.com/Ro5bert/avra + The files listed in the Files-Excluded field have subsequently been removed + from the source package for lack of copying permission statements or for + otherwise not conforming to the DFSG. +Files-Excluded: + examples/throttle_multiply.asm + examples/throttle_divide.asm + tests/overlap/overlap07/avra.core Files: * -Copyright: 1998-2003, 2004, 2006, 2010 Jon Anders Haugum, Tobias Weber +Copyright: + 1998-2003,2004,2006,2010,2019,2020 Jon Anders Haugum, Tobias Weber, + Burkhard Arenfeld, Robert Russell, Jerry Jacobs et al. License: GPL-2+ -Files: src/device.c -Copyright: 1998-2010 Jon Anders Haugum, Tobias Weber, Jerry Jacobs +Files: debian/* +Copyright: + 1999,2000,2003 Jefferson E. Noxon + 2005 Torsten Landschoff + 2007,2010 Tobias Klauser + 2013,2014,2016,2023 Milan Kupcevic License: GPL-2+ -Files: src/configure -Copyright: 2003 Free Software Foundation, Inc. -License: unlimited - This configure script is free software; the Free Software Foundation - gives unlimited permission to copy, distribute and modify it. - -Files: src/Makefile.in -Copyright: 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005 Free Software Foundation, Inc. -License: permissive - This Makefile.in is free software; the Free Software Foundation - gives unlimited permission to copy and/or distribute it, - with or without modifications, as long as this notice is preserved. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY, to the extent permitted by law; without - even the implied warranty of MERCHANTABILITY or FITNESS FOR A - PARTICULAR PURPOSE. - -Files: src/stab.h -Copyright: 1990 by Sun Microsystems, Inc -Comment: Contains interface definitions. - Copyright on interface definitions is widely regarded as not enforceable. -License: unknown +Files: examples/* +Copyright: 2003 Philip DeVries +License: GPL-2+ -Files: includes/* -Copyright: 2005 by Atmel +Files: + includes/* + examples/tn15def.inc +Copyright: 1999,2005,2011 by Atmel Comment: Contains interface definitions. Copyright on interface definitions is widely regarded as not enforceable. License: unknown @@ -45,28 +38,18 @@ License: unknown License terms not specified. -Files: examples/* -Copyright: 2003 Philip DeVries -License: GPL-2+ - -Files: debian/* -Copyright: 1999, 2000, 2003 Jefferson E. Noxon - 2005 Torsten Landschoff - 2007, 2010 Tobias Klauser - 2013 Milan Kupcevic -License: GPL-2+ - -Files: debian/patches/* -Copyright: 2013 Milan Kupcevic -License: GPL-2+ +Files: src/stab.h +Copyright: 1990 by Sun Microsystems, Inc +Comment: Contains interface definitions. + Copyright on interface definitions is widely regarded as not enforceable. +License: unknown -Files: debian/avra.1 -Copyright: 2006 Robert Lemmen -Comment: - This file was contributed to this package by its author as a fix to - bug #360577. We can assume the authors intention was to distribute the - file under the same licensing terms as the software package itself. -License: GPL-2+ +Files: COPYING +Copyright: + 1989,1991 Free Software Foundation, Inc. +License: verbatim + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. License: GPL-2+ This program is free software; you can redistribute it and/or modify @@ -78,7 +61,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - . +Comment: On Debian systems, the full text of the GNU General Public License version 2 can be found in the file /usr/share/common-licenses/GPL-2 - diff -Nru avra-1.3.0/debian/gbp.conf avra-1.4.2+dfsg/debian/gbp.conf --- avra-1.3.0/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/gbp.conf 2023-03-22 01:39:58.000000000 +0000 @@ -0,0 +1,5 @@ +[DEFAULT] +debian-branch = debian/latest +upstream-branch = upstream/latest +pristine-tar = True +patch-numbers = False diff -Nru avra-1.3.0/debian/patches/attiny4-5-9-10src.patch avra-1.4.2+dfsg/debian/patches/attiny4-5-9-10src.patch --- avra-1.3.0/debian/patches/attiny4-5-9-10src.patch 2013-09-06 01:42:35.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/attiny4-5-9-10src.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -Description: Add support for ATtiny4, ATtiny5, ATtiny9 and ATtiny10 - Support for ATtiny4, ATtiny5, ATtiny9 and ATtiny10 microcontrollers - based on ATtiny4/5/9/10 Datasheet 8127F-AVR-02/2013. -Author: Milan Kupcevic -Bug: http://sourceforge.net/p/avra/bugs/73/ ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/src/device.c -+++ b/src/device.c -@@ -49,10 +49,10 @@ - /* Name, Flash(words),RAM start, RAM size, EEPROM, flags */ - { NULL, 4194304, 0x60, 8388608, 65536, 0}, // Total instructions: 137 - /* ATtiny Series */ -- // ATtiny4 -- // ATtiny5 -- // ATtiny9 -- { "ATtiny10", 512, 0x00, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, -+ { "ATtiny4", 256, 0x40, 32, 0, DF_AVR8L|DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_LDD|DF_NO_STD}, -+ { "ATtiny5", 256, 0x40, 32, 0, DF_AVR8L|DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_LDD|DF_NO_STD}, -+ { "ATtiny9", 512, 0x40, 32, 0, DF_AVR8L|DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_LDD|DF_NO_STD}, -+ { "ATtiny10", 512, 0x40, 32, 0, DF_AVR8L|DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_LDD|DF_NO_STD}, - { "ATtiny11", 512, 0x00, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny12", 512, 0x00, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny13", 512, 0x60, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, ---- a/src/device.h -+++ b/src/device.h -@@ -17,6 +17,8 @@ - #define DF_NO_EICALL 0x00002000 // No EICALL instruction - #define DF_NO_EIJMP 0x00004000 // No EIJMP instruction - #define DF_AVR8L 0x00008000 /* ATtiny10, 20, 40 set No ADIW, SBIW, one word LDS/STS */ -+#define DF_NO_LDD 0x00010000 // No LDD instruction -+#define DF_NO_STD 0x00020000 // No STD instruction - - struct device - { ---- a/src/mnemonic.c -+++ b/src/mnemonic.c -@@ -305,8 +305,8 @@ - {"sts", 0x9200, DF_TINY1X | DF_AVR8L}, - {"ld", 0, 0}, - {"st", 0, 0}, -- {"ldd", 0, DF_TINY1X}, -- {"std", 0, DF_TINY1X}, -+ {"ldd", 0, DF_TINY1X|DF_NO_LDD}, -+ {"std", 0, DF_TINY1X|DF_NO_STD}, - {"count", 0, 0}, - {"lpm", 0x9004, DF_NO_LPM|DF_NO_LPM_X}, - {"lpm", 0x9005, DF_NO_LPM|DF_NO_LPM_X}, -@@ -330,10 +330,10 @@ - {"st", 0x8200, 0}, - {"st", 0x9201, DF_TINY1X}, - {"st", 0x9202, DF_TINY1X}, -- {"ldd", 0x8008, DF_TINY1X}, -- {"ldd", 0x8000, DF_TINY1X}, -- {"std", 0x8208, DF_TINY1X}, -- {"std", 0x8200, DF_TINY1X}, -+ {"ldd", 0x8008, DF_TINY1X|DF_NO_LDD}, -+ {"ldd", 0x8000, DF_TINY1X|DF_NO_LDD}, -+ {"std", 0x8208, DF_TINY1X|DF_NO_STD}, -+ {"std", 0x8200, DF_TINY1X|DF_NO_STD}, - {"lds", 0xa000, DF_TINY1X}, - {"sts", 0xa800, DF_TINY1X}, - {"end", 0, 0} diff -Nru avra-1.3.0/debian/patches/AVR8L-plus-attiny20-git-b13b7c.patch avra-1.4.2+dfsg/debian/patches/AVR8L-plus-attiny20-git-b13b7c.patch --- avra-1.3.0/debian/patches/AVR8L-plus-attiny20-git-b13b7c.patch 2013-09-06 02:10:22.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/AVR8L-plus-attiny20-git-b13b7c.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -Description: Add support for ATtiny20 with AVR8L instructions -Origin: backport, http://sf.net/p/avra/code/ci/b13b7c ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/src/avra.h -+++ b/src/avra.h -@@ -305,7 +305,7 @@ - - /* mnemonic.c */ - int parse_mnemonic(struct prog_info *pi); --int get_mnemonic_type(char *mnemonic); -+int get_mnemonic_type(struct prog_info *pi); - int get_register(struct prog_info *pi, char *data); - int get_bitnum(struct prog_info *pi, char *data, int *ret); - int get_indirect(struct prog_info *pi, char *operand); ---- a/src/device.c -+++ b/src/device.c -@@ -58,7 +58,7 @@ - { "ATtiny13", 512, 0x60, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny13A", 512, 0x60, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny15", 512, 0x00, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, -- // ATtiny20 -+ { "ATtiny20", 2048, 0x40, 128, 0, DF_AVR8L|DF_NO_JMP|DF_NO_MUL|DF_NO_EIJMP|DF_NO_EICALL|DF_NO_MOVW|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, - { "ATtiny22", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny24", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny24A", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, ---- a/src/device.h -+++ b/src/device.h -@@ -16,6 +16,7 @@ - #define DF_NO_BREAK 0x00001000 // No BREAK instruction - #define DF_NO_EICALL 0x00002000 // No EICALL instruction - #define DF_NO_EIJMP 0x00004000 // No EIJMP instruction -+#define DF_AVR8L 0x00008000 /* ATtiny10, 20, 40 set No ADIW, SBIW, one word LDS/STS */ - - struct device - { ---- a/src/mnemonic.c -+++ b/src/mnemonic.c -@@ -179,6 +179,8 @@ - MNEMONIC_LDD_Z, // Rd, Z+q 10q0 qq0d dddd 0qqq - MNEMONIC_STD_Y, // Y+q, Rr 10q0 qq1r rrrr 1qqq - MNEMONIC_STD_Z, // Z+q, Rr 10q0 qq1r rrrr 0qqq -+ MNEMONIC_LDS_AVR8L,// Rd, k 1010 0kkk dddd kkkk -+ MNEMONIC_STS_AVR8L,// Rd, k 1010 1kkk dddd kkkk - MNEMONIC_END - }; - -@@ -279,8 +281,8 @@ - {"fmul", 0x0308, DF_NO_MUL}, - {"fmuls", 0x0380, DF_NO_MUL}, - {"fmulsu",0x0388, DF_NO_MUL}, -- {"adiw", 0x9600, DF_TINY1X}, -- {"sbiw", 0x9700, DF_TINY1X}, -+ {"adiw", 0x9600, DF_TINY1X | DF_AVR8L}, -+ {"sbiw", 0x9700, DF_TINY1X | DF_AVR8L}, - {"subi", 0x5000, 0}, - {"sbci", 0x4000, 0}, - {"andi", 0x7000, 0}, -@@ -299,8 +301,8 @@ - {"sbis", 0x9b00, 0}, - {"sbi", 0x9a00, 0}, - {"cbi", 0x9800, 0}, -- {"lds", 0x9000, DF_TINY1X}, -- {"sts", 0x9200, DF_TINY1X}, -+ {"lds", 0x9000, DF_TINY1X | DF_AVR8L}, -+ {"sts", 0x9200, DF_TINY1X | DF_AVR8L}, - {"ld", 0, 0}, - {"st", 0, 0}, - {"ldd", 0, DF_TINY1X}, -@@ -332,6 +334,8 @@ - {"ldd", 0x8000, DF_TINY1X}, - {"std", 0x8208, DF_TINY1X}, - {"std", 0x8200, DF_TINY1X}, -+ {"lds", 0xa000, DF_TINY1X}, -+ {"sts", 0xa800, DF_TINY1X}, - {"end", 0, 0} - }; - -@@ -353,7 +357,7 @@ - char temp[MAX_MNEMONIC_LEN + 1]; - - operand1 = get_next_token(pi->fi->scratch, TERM_SPACE); // we get the first word on line -- mnemonic = get_mnemonic_type(my_strlwr(pi->fi->scratch)); -+ mnemonic = get_mnemonic_type(pi); - if(mnemonic == -1) { // if -1 this must be a macro name - macro = get_macro(pi, pi->fi->scratch); // and so, we try to get the corresponding macro struct. - if(macro) { -@@ -539,21 +543,44 @@ - } else if(mnemonic == MNEMONIC_LDS) { - i = get_register(pi, operand1); - opcode = i << 4; -+ /* AVR8L has one word LDS. High nibble of k in funny order */ -+ if (pi->device->flag & DF_AVR8L) { -+ mnemonic = MNEMONIC_LDS_AVR8L; -+ opcode &= 0x00f0; -+ } - if(!get_expr(pi, operand2, &i)) - return(False); -- if((i < 0) || (i > 65535)) -- print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); -- opcode2 = i; -- instruction_long = True; -+ if (pi->device->flag & DF_AVR8L) { -+ if((i < 0x40) || (i > 0xbf)) -+ print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0x40 <= k <= 0xbf)"); -+ opcode |= ((i & 0x40) << 2) | ((i & 0x30) << 5) | (i & 0x0f); -+ } else { -+ if((i < 0) || (i > 65535)) -+ print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); -+ opcode2 = i; -+ instruction_long = True; -+ } - } else if(mnemonic == MNEMONIC_STS) { - if(!get_expr(pi, operand1, &i)) - return(False); -- if((i < 0) || (i > 65535)) -- print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); -- opcode2 = i; -+ /* AVR8L has one word STS. High nibble of k in funny order */ -+ if (pi->device->flag & DF_AVR8L) { -+ mnemonic = MNEMONIC_STS_AVR8L; -+ if((i < 0x40) || (i > 0xbf)) -+ print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0x40 <= k <= 0xbf)"); -+ opcode |= ((i & 0x40) << 2) | ((i & 0x30) << 5) | (i & 0x0f); -+ } else { -+ if((i < 0) || (i > 65535)) -+ print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); -+ opcode2 = i; -+ instruction_long = True; -+ } - i = get_register(pi, operand2); -- opcode = i << 4; -- instruction_long = True; -+ if (pi->device->flag & DF_AVR8L) -+ opcode |= ((i << 4) & 0x00f0); -+ else -+ opcode = i << 4; -+ //print_msg(pi, MSGTYPE_MESSAGE, "operand2 0x%04x opcode 0x%04x", i, opcode); - } else if(mnemonic == MNEMONIC_LD) { - i = get_register(pi, operand1); - opcode = i << 4; -@@ -628,6 +655,8 @@ - else - pi->cseg_addr++; - } else { // Pass 1 -+ if (pi->device->flag & DF_AVR8L) -+ mnemonic = MNEMONIC_LDS_AVR8L; - if((mnemonic == MNEMONIC_JMP) || (mnemonic == MNEMONIC_CALL) - || (mnemonic == MNEMONIC_LDS) || (mnemonic == MNEMONIC_STS)) { - pi->cseg_addr += 2; -@@ -640,10 +669,12 @@ - return(True); - } - -- --int get_mnemonic_type(char *mnemonic) -+int get_mnemonic_type(struct prog_info *pi) - { - int i; -+ char *mnemonic; -+ -+ mnemonic = my_strlwr(pi->fi->scratch); - - for(i = 0; i < MNEMONIC_COUNT; i++) { - if(!strcmp(mnemonic, instruction_list[i].mnemonic)) { -@@ -675,6 +706,8 @@ - reg = atoi(&data[1]); - if(reg > 31) - print_msg(pi, MSGTYPE_ERROR, "R%d is not a valid register", reg); -+ if ((reg < 16) && (pi->device->flag & DF_AVR8L)) -+ print_msg(pi, MSGTYPE_ERROR, "%s can only use a high registers (r16 - r31)", pi->device->name); - } - else - print_msg(pi, MSGTYPE_ERROR, "No register associated with %s", data); -@@ -767,11 +800,10 @@ - /* Return 1 if instruction name is supported by the current device, - 0 if unsupported, -1 if it is invalid */ - int is_supported(struct prog_info *pi, char *name) { -- char temp[MAX_MNEMONIC_LEN+1]; - int mnemonic; - -- strncpy(temp,name,MAX_MNEMONIC_LEN); -- mnemonic = get_mnemonic_type(my_strlwr(temp)); -+ strncpy(pi->fi->scratch,name,MAX_MNEMONIC_LEN); -+ mnemonic = get_mnemonic_type(pi); - if (mnemonic == -1) return -1; - if (pi->device->flag & instruction_list[mnemonic].flag) return 0; - return 1; diff -Nru avra-1.3.0/debian/patches/conflicting-function-declarations.patch avra-1.4.2+dfsg/debian/patches/conflicting-function-declarations.patch --- avra-1.3.0/debian/patches/conflicting-function-declarations.patch 2014-11-20 22:18:05.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/conflicting-function-declarations.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Description: Use proper function return types - Function declaration and definition return types should not differ. -Author: Michael Tautschnig -Bug: http://sourceforge.net/p/avra/patches/15/ ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/src/avra.h -+++ b/src/avra.h -@@ -347,8 +347,8 @@ - char *Space(char *n); - - /* stdextra.c */ --char *nocase_strcmp(char *s, char *t); --char *nocase_strncmp(char *s, char *t, int n); -+int nocase_strcmp(char *s, char *t); -+int nocase_strncmp(char *s, char *t, int n); - char *nocase_strstr(char *s, char *t); - int atox(char *s); - int atoi_n(char *s, int n); diff -Nru avra-1.3.0/debian/patches/help-output-update.patch avra-1.4.2+dfsg/debian/patches/help-output-update.patch --- avra-1.3.0/debian/patches/help-output-update.patch 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/help-output-update.patch 2023-03-22 04:48:12.000000000 +0000 @@ -0,0 +1,59 @@ +Description: help output update + Clean up and update help output usage and options. +Author: Milan Kupcevic +Forwarded: https://github.com/Ro5bert/avra/pull/59 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/src/avra.c ++++ b/src/avra.c +@@ -44,30 +44,26 @@ + const char *title = "AVRA: advanced AVR macro assembler (version %s)\n"; + + const char *usage = +- "usage: avra [-f][O|M|I|G] output file type\n" +- " [-o ] output file name\n" +- " [-d ] debug file name\n" +- " [-e ] file name to output EEPROM contents\n" +- " [-l ] generate list file\n" +- " [-m ] generate map file\n" +- " [--define [=]]\n" +- " [-I ] [--listmac]\n" +- " [--max_errors ] [--devices] [--version]\n" +- " [-O e|w|i]\n" +- " [-h] [--help] general help\n" +- " \n" +- "\n" +- " --listfile -l : Create list file\n" +- " --mapfile -m : Create map file\n" +- " --define -D : Define symbol.\n" +- " --includedir -I : Additional include paths. Default: %s\n" +- " --listmac : List macro expansion in listfile.\n" +- " --max_errors : Maximum number of errors before exit\n" +- " (default: 10)\n" +- " --devices : List out supported devices.\n" +- " --version : Version information.\n" +- " -O e|w|i : Issue error/warning/ignore overlapping code.\n" +- " --help, -h : This help text.\n"; ++ "Usage: avra [OPTION]... FILE\n" ++ "Options:\n" ++ " -d, --debugfile debug file name\n" ++ " -D, --define [=] define symbol\n" ++ " -e, --eepfile create EEPROM contents file\n" ++ " -f, --filetype O|M|I|G output file type\n" ++ " -I, --includepath additional include paths\n" ++ " (default: %s)\n" ++ " -l, --listfile create list file\n" ++ " -m, --mapfile create map file\n" ++ " -o, --outfile output file name\n" ++ " -O, --overlap e|w|i issue error/warning/ignore overlapping code\n" ++ " --devices list out supported devices\n" ++ " --listmac list macro expansion in listfile\n" ++ " --max_errors maximum number of errors before exit\n" ++ " (default: 10)\n" ++ " --version version information\n" ++ " -h, --help general help\n" ++ " FILE file to assemble\n" ++ ; + + const struct dataset overlap_choice[4] = { + { OVERLAP_ERROR, "e"}, diff -Nru avra-1.3.0/debian/patches/produce-avra-manual-page.patch avra-1.4.2+dfsg/debian/patches/produce-avra-manual-page.patch --- avra-1.3.0/debian/patches/produce-avra-manual-page.patch 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/produce-avra-manual-page.patch 2023-03-22 12:50:28.000000000 +0000 @@ -0,0 +1,88 @@ +Description: produce avra manual page +Author: Milan Kupcevic +Forwarded: not-needed +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/Makefile ++++ b/Makefile +@@ -21,10 +21,19 @@ + .PHONY: all + all: + $(MAKE) -C src -f makefiles/Makefile.$(OS) ++ chmod ugo+x avra ++ help2man \ ++ --no-info \ ++ --section 1 \ ++ --name="assembler for the AVR microcontroller family" \ ++ --source="avra $(VERSION)" \ ++ --version-string="$(VERSION)" \ ++ ./avra > avra.1 + + .PHONY: clean + clean: + $(MAKE) -C src -f makefiles/Makefile.$(OS) clean ++ rm -f avra.1 + + avra-$(VERSION).tar.gz: $(DISTFILES) clean + mkdir avra-$(VERSION) +@@ -40,6 +49,8 @@ + install: all + install -d $(DESTDIR)$(PREFIX)/bin + install -m 755 src/avra $(DESTDIR)$(PREFIX)/bin ++ install -d $(DESTDIR)$(PREFIX)/share/man/man1 ++ install -m 644 avra.1 $(DESTDIR)$(PREFIX)/share/man/man1 + install -d $(DESTDIR)$(TARGET_INCLUDE_PATH) + cp includes/* $(DESTDIR)$(TARGET_INCLUDE_PATH) + +--- /dev/null ++++ b/avra +@@ -0,0 +1,49 @@ ++#!/bin/sh ++if [ "$1" = "--help" ] ; then ++ src/avra --help | \ ++ sed - \ ++ -e "s,AVRA: .*,," ++ echo "" ++ cat << eof ++*DESCRIPTION* ++AVRA is an advanced macro assembler for the AVR microcontrollers designed as a ++replacement for AVRASM32. While command line options have been adapted as close ++as possible, AVRA offers a number of advanced features which are not present ++in the AVRASM32. These features should help in creating versatile and more ++modular code. ++eof ++ echo "" ++ sed USAGE.md \ ++ -e "s,#### \(.*\),\1:," \ ++ -e "s,### \(.*\),\1:," \ ++ -e "s,## \(.*\),*\1*," \ ++ -e "s,# \(.*\),*\1*," \ ++ -E \ ++ -e "s,\[([^]]+)\]\(http([^)]+)\),\1: ,g" ++ echo "" ++ cat << eof ++*AUTHOR* ++Originally written by John Anders Haugum; subsequently maintained by Tobias ++Weber (v0.7+), Burkhard Arenfeld (v1.2), Jerry Jacobs (v1.3) and Virgil Dupras ++(v1.4). This manual page has been produced by Milan Kupcevic ++for the Debian project and can be used by others. See AUTHORS for complete list ++of contributors. ++eof ++ echo "" ++ cat << eof ++Copyright (C) 1998-2003, 2004, 2005, 2006, 2007, 2010, 2019, 2020 Jon Anders ++Haugum, Tobias Weber, Burkhard Arenfeld, Robert Russell, Jerry Jacobs et al. ++License GPLv2+: GNU GPL version 2 or later ++. This is free software; you are free to ++change and redistribute it under certain conditions. ++There is NO WARRANTY to the extent permitted by law. ++eof ++ echo "" ++ cat << eof ++*SEE ALSO* ++avrdude(1) ++eof ++fi ++if [ "$1" = "--version" ] ; then ++ src/avra --version ++fi diff -Nru avra-1.3.0/debian/patches/series avra-1.4.2+dfsg/debian/patches/series --- avra-1.3.0/debian/patches/series 2014-11-17 21:46:53.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/series 2023-03-22 12:55:53.000000000 +0000 @@ -1,4 +1,3 @@ -AVR8L-plus-attiny20-git-b13b7c.patch -attiny4-5-9-10src.patch -tn4-5-9-10def.inc.patch -conflicting-function-declarations.patch +help-output-update.patch +produce-avra-manual-page.patch +typo-fixes.patch diff -Nru avra-1.3.0/debian/patches/tn4-5-9-10def.inc.patch avra-1.4.2+dfsg/debian/patches/tn4-5-9-10def.inc.patch --- avra-1.3.0/debian/patches/tn4-5-9-10def.inc.patch 2013-09-06 01:42:35.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/tn4-5-9-10def.inc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,1373 +0,0 @@ -Description: Add header files for ATtiny4, ATtiny5, ATtiny9 and ATtiny10 -Author: Milan Kupcevic -Bug: http://sourceforge.net/p/avra/bugs/73/ ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- /dev/null -+++ b/includes/tn10def.inc -@@ -0,0 +1,358 @@ -+; -+; Copyright (C) 2013 Milan Kupcevic -+; -+; You can redistribute and/or modify this file under the -+; terms of the GNU General Public License version 2, or -+; (at your option) any later version, as published by -+; the Free Software Foundation. -+; -+; This file is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program. If not, see . -+; -+; -+; Based on ATtiny4/5/9/10 Datasheet 8127F-AVR-02/2013. -+; -+ -+.device ATtiny10 -+ -+.equ SIGNATURE_000 = 0x1e -+.equ SIGNATURE_001 = 0x90 -+.equ SIGNATURE_002 = 0x03 -+ -+; Port B Input Pins -+.equ PINB = 0x00 -+.equ PINB0 = 0 -+.equ PINB1 = 1 -+.equ PINB2 = 2 -+.equ PINB3 = 3 -+ -+; Port B Data Direction Register -+.equ DDRB = 0x01 -+.equ DDRB0 = 0 -+.equ DDB0 = 0 -+.equ DDRB1 = 1 -+.equ DDB1 = 1 -+.equ DDRB2 = 2 -+.equ DDB2 = 2 -+.equ DDRB3 = 3 -+.equ DDB3 = 3 -+ -+; Port B Data Register -+.equ PORTB = 0x02 -+.equ PORTB0 = 0 -+.equ PB0 = 0 -+.equ PORTB1 = 1 -+.equ PB1 = 1 -+.equ PORTB2 = 2 -+.equ PB2 = 2 -+.equ PORTB3 = 3 -+.equ PB3 = 3 -+ -+; Port B Pull-up Enable Control Register -+.equ PUEB = 0x03 -+.equ PUEB0 = 0 -+.equ PUEB1 = 1 -+.equ PUEB2 = 2 -+.equ PUEB3 = 3 -+ -+; Port Control Register -+.equ PORTCR = 0x0c -+.equ BBMB = 1 -+ -+; Pin Change Mask Register -+.equ PCMSK = 0x10 -+.equ PCINT0 = 0 -+.equ PCINT1 = 1 -+.equ PCINT2 = 2 -+.equ PCINT3 = 3 -+ -+; Pin Change Interrupt Flag Register -+.equ PCIFR = 0x11 -+.equ PCIF0 = 0 -+ -+; Pin Change Interrupt Control Register -+.equ PCICR = 0x12 -+.equ PCIE0 = 0 -+ -+; External Interrupt Mask Register -+.equ EIMSK = 0x13 -+.equ INT0 = 0 -+ -+; External Interrupt Flag Register -+.equ EIFR = 0x14 -+.equ INTF0 = 0 -+ -+; External Interrupt Control Register A -+.equ EICRA = 0x15 -+.equ ISC00 = 0 -+.equ ISC01 = 1 -+ -+; Digital Input Disable Register 0 -+.equ DIDR0 = 0x17 -+.equ ADC0D = 0 -+.equ AIN0D = 0 -+.equ ADC1D = 1 -+.equ AIN1D = 1 -+.equ ADC2D = 2 -+.equ ADC3D = 3 -+ -+; ADC Data Register -+.equ ADCL = 0x19 -+.equ ADC0 = 0 -+.equ ADC1 = 1 -+.equ ADC2 = 2 -+.equ ADC3 = 3 -+.equ ADC4 = 4 -+.equ ADC5 = 5 -+.equ ADC6 = 6 -+.equ ADC7 = 7 -+ -+; ADC Multiplexer Selection Register -+.equ ADMUX = 0x1b -+.equ MUX0 = 0 -+.equ MUX1 = 1 -+ -+; ADC Control and Status Register B -+.equ ADCSRB = 0x1c -+.equ ADTS0 = 0 -+.equ ADTS1 = 1 -+.equ ADTS2 = 2 -+ -+; ADC Control and Status Register A -+.equ ADCSRA = 0x1d -+.equ ADPS0 = 0 -+.equ ADPS1 = 1 -+.equ ADPS2 = 2 -+.equ ADIE = 3 -+.equ ADIF = 4 -+.equ ADATE = 5 -+.equ ADSC = 6 -+.equ ADEN = 7 -+ -+; Analog Comparator Control and Status Register -+.equ ACSR = 0x1f -+.equ ACIS0 = 0 -+.equ ACIS1 = 1 -+.equ ACIC = 2 -+.equ ACIE = 3 -+.equ ACI = 4 -+.equ ACO = 5 -+.equ ACD = 7 -+ -+; Input Capture Register 0 -+.equ ICR0L = 0x22 -+.equ ICR0H = 0x23 -+ -+; Output Compare Register 0 B -+.equ OCR0BL = 0x24 -+.equ OCR0BH = 0x25 -+ -+; Output Compare Register 0 A -+.equ OCR0AL = 0x26 -+.equ OCR0AH = 0x27 -+ -+; Timer/Counter0 -+.equ TCNT0L = 0x28 -+.equ TCNT0H = 0x29 -+ -+; Timer/Counter Interrupt Flag Register 0 -+.equ TIFR0 = 0x2a -+.equ TOV0 = 0 -+.equ OCF0A = 1 -+.equ OCF0B = 2 -+.equ ICF0 = 5 -+ -+; Timer/Counter Interrupt Mask Register 0 -+.equ TIMSK0 = 0x2b -+.equ TOIE0 = 0 -+.equ OCIE0A = 1 -+.equ OCIE0B = 2 -+.equ ICIE0 = 5 -+ -+; Timer/Counter0 Control Register C -+.equ TCCR0C = 0x2c -+.equ FOC0B = 6 -+.equ FOC0A = 7 -+ -+; Timer/Counter0 Control Register B -+.equ TCCR0B = 0x2d -+.equ CS00 = 0 -+.equ CS01 = 1 -+.equ CS02 = 2 -+.equ WGM02 = 3 -+.equ WGM03 = 4 -+.equ ICES0 = 6 -+.equ ICNC0 = 7 -+ -+; Timer/Counter0 Control Register A -+.equ TCCR0A = 0x2e -+.equ WGM00 = 0 -+.equ WGM01 = 1 -+.equ COM0B0 = 4 -+.equ COM0B1 = 5 -+.equ COM0A0 = 6 -+.equ COM0A1 = 7 -+ -+; General Timer/Counter Control Register -+.equ GTCCR = 0x2f -+.equ PSR = 0 -+.equ TSM = 7 -+ -+; Watchdog Timer Control and Status Register -+.equ WDTCSR = 0x31 -+.equ WDP0 = 0 -+.equ WDP1 = 1 -+.equ WDP2 = 2 -+.equ WDE = 3 -+.equ WDP3 = 5 -+.equ WDIE = 6 -+.equ WDIF = 7 -+ -+; Non-Volatile Memory Control and Status Register -+.equ NVMCSR = 0x32 -+.equ NVMBSY = 7 -+ -+; Non-Volatile Memory Command Register -+.equ NVMCMD = 0x33 -+.equ NVMCMD0 = 0 -+.equ NVMCMD1 = 1 -+.equ NVMCMD2 = 2 -+.equ NVMCMD3 = 3 -+.equ NVMCMD4 = 4 -+.equ NVMCMD5 = 5 -+ -+; Vcc Level Monitoring Control and Status Register -+.equ VLMCSR = 0x34 -+.equ VLM0 = 0 -+.equ VLM1 = 1 -+.equ VLM2 = 2 -+.equ VLMIE = 6 -+.equ VLMF = 7 -+ -+; Power Reduction Register -+.equ PRR = 0x35 -+.equ PRTIM0 = 0 -+.equ PRADC = 1 -+ -+; Clock Prescale Register -+.equ CLKPSR = 0x36 -+.equ CLKPS0 = 0 -+.equ CLKPS1 = 1 -+.equ CLKPS2 = 2 -+.equ CLKPS3 = 3 -+ -+; Clock Main Settings Register -+.equ CLKMSR = 0x37 -+.equ CLKMS0 = 0 -+.equ CLKMS1 = 1 -+ -+; Oscillator Calibration Register -+.equ OSCCAL = 0x39 -+.equ CAL0 = 0 -+.equ CAL1 = 1 -+.equ CAL2 = 2 -+.equ CAL3 = 3 -+.equ CAL4 = 4 -+.equ CAL5 = 5 -+.equ CAL6 = 6 -+.equ CAL7 = 7 -+ -+; Sleep Mode Control Register -+.equ SMCR = 0x3a -+.equ SE = 0 -+.equ SM0 = 1 -+.equ SM1 = 2 -+.equ SM2 = 3 -+ -+; Reset Flag Register -+.equ RSTFLR = 0x3b -+.equ PORF = 0 -+.equ EXTRF = 1 -+.equ WDRF = 3 -+ -+; Configuration Change Protection Register -+.equ CCP = 0x3c -+.equ CCP0 = 0 -+.equ CCP1 = 1 -+.equ CCP2 = 2 -+.equ CCP3 = 3 -+.equ CCP4 = 4 -+.equ CCP5 = 5 -+.equ CCP6 = 6 -+.equ CCP7 = 7 -+ -+; Stack Pointer Register -+.equ SPL = 0x3d -+.equ SPH = 0x3e -+ -+; Status Register -+.equ SREG = 0x3f -+.equ SREG_C = 0 -+.equ SREG_Z = 1 -+.equ SREG_N = 2 -+.equ SREG_V = 3 -+.equ SREG_S = 4 -+.equ SREG_H = 5 -+.equ SREG_T = 6 -+.equ SREG_I = 7 -+ -+; Indirect address registers -+.def XL = r26 -+.def XH = r27 -+.def YL = r28 -+.def YH = r29 -+.def ZL = r30 -+.def ZH = r31 -+ -+; Non-Volatile Memory Lock Bits -+.equ MAPPED_LOCKBITS_0 = 0x3f00 -+.equ NVLB1 = 0 -+.equ LB1 = 0 -+.equ NVLB2 = 1 -+.equ LB2 = 1 -+ -+; Flash Memory -+.equ PAGESIZE = 16 -+.equ FLASHEND = 0x01ff -+.equ MAPPED_FLASH_START = 0x4000 -+.equ MAPPED_FLASH_SIZE = 0x0400 -+.equ MAPPED_FLASH_END = 0x43ff -+ -+; RAM Memory -+.equ IOEND = 0x003f -+.equ RAMEND = 0x005f -+.equ SRAM_START = 0x0040 -+.equ SRAM_SIZE = 32 -+ -+; Configuration -+.equ MAPPED_CONFIG_0 = 0x3f40 -+.equ RSTDISBL = 0 -+.equ WDTON = 1 -+.equ CKOUT = 2 -+ -+; Calibration -+.equ MAPPED_CALIB_0 = 0x3f80 -+ -+; Signature -+.equ MAPPED_SIGN_0 = 0x3fc0 -+.equ MAPPED_SIGN_1 = 0x3fc1 -+.equ MAPPED_SIGN_2 = 0x3fc2 -+ -+; Interrupt Vectors -+.equ INT_VECTORS_SIZE = 11 -+.equ INT0addr = 0x0001 -+.equ PCI0addr = 0x0002 -+.equ ICP0addr = 0x0003 -+.equ OVF0addr = 0x0004 -+.equ OC0Aaddr = 0x0005 -+.equ OC0Baddr = 0x0006 -+.equ ACIaddr = 0x0007 -+.equ WDTaddr = 0x0008 -+.equ VLMaddr = 0x0009 -+.equ ADCCaddr = 0x000a -+ ---- /dev/null -+++ b/includes/tn4def.inc -@@ -0,0 +1,320 @@ -+; -+; Copyright (C) 2013 Milan Kupcevic -+; -+; You can redistribute and/or modify this file under the -+; terms of the GNU General Public License version 2, or -+; (at your option) any later version, as published by -+; the Free Software Foundation. -+; -+; This file is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program. If not, see . -+; -+; -+; Based on ATtiny4/5/9/10 Datasheet 8127F-AVR-02/2013. -+; -+ -+.device ATtiny4 -+ -+.equ SIGNATURE_000 = 0x1e -+.equ SIGNATURE_001 = 0x8f -+.equ SIGNATURE_002 = 0x0a -+ -+; Port B Input Pins -+.equ PINB = 0x00 -+.equ PINB0 = 0 -+.equ PINB1 = 1 -+.equ PINB2 = 2 -+.equ PINB3 = 3 -+ -+; Port B Data Direction Register -+.equ DDRB = 0x01 -+.equ DDRB0 = 0 -+.equ DDB0 = 0 -+.equ DDRB1 = 1 -+.equ DDB1 = 1 -+.equ DDRB2 = 2 -+.equ DDB2 = 2 -+.equ DDRB3 = 3 -+.equ DDB3 = 3 -+ -+; Port B Data Register -+.equ PORTB = 0x02 -+.equ PORTB0 = 0 -+.equ PB0 = 0 -+.equ PORTB1 = 1 -+.equ PB1 = 1 -+.equ PORTB2 = 2 -+.equ PB2 = 2 -+.equ PORTB3 = 3 -+.equ PB3 = 3 -+ -+; Port B Pull-up Enable Control Register -+.equ PUEB = 0x03 -+.equ PUEB0 = 0 -+.equ PUEB1 = 1 -+.equ PUEB2 = 2 -+.equ PUEB3 = 3 -+ -+; Port Control Register -+.equ PORTCR = 0x0c -+.equ BBMB = 1 -+ -+; Pin Change Mask Register -+.equ PCMSK = 0x10 -+.equ PCINT0 = 0 -+.equ PCINT1 = 1 -+.equ PCINT2 = 2 -+.equ PCINT3 = 3 -+ -+; Pin Change Interrupt Flag Register -+.equ PCIFR = 0x11 -+.equ PCIF0 = 0 -+ -+; Pin Change Interrupt Control Register -+.equ PCICR = 0x12 -+.equ PCIE0 = 0 -+ -+; External Interrupt Mask Register -+.equ EIMSK = 0x13 -+.equ INT0 = 0 -+ -+; External Interrupt Flag Register -+.equ EIFR = 0x14 -+.equ INTF0 = 0 -+ -+; External Interrupt Control Register A -+.equ EICRA = 0x15 -+.equ ISC00 = 0 -+.equ ISC01 = 1 -+ -+; Digital Input Disable Register 0 -+.equ DIDR0 = 0x17 -+.equ AIN0D = 0 -+.equ AIN1D = 1 -+ -+; Analog Comparator Control and Status Register -+.equ ACSR = 0x1f -+.equ ACIS0 = 0 -+.equ ACIS1 = 1 -+.equ ACIC = 2 -+.equ ACIE = 3 -+.equ ACI = 4 -+.equ ACO = 5 -+.equ ACD = 7 -+ -+; Input Capture Register 0 -+.equ ICR0L = 0x22 -+.equ ICR0H = 0x23 -+ -+; Output Compare Register 0 B -+.equ OCR0BL = 0x24 -+.equ OCR0BH = 0x25 -+ -+; Output Compare Register 0 A -+.equ OCR0AL = 0x26 -+.equ OCR0AH = 0x27 -+ -+; Timer/Counter0 -+.equ TCNT0L = 0x28 -+.equ TCNT0H = 0x29 -+ -+; Timer/Counter Interrupt Flag Register 0 -+.equ TIFR0 = 0x2a -+.equ TOV0 = 0 -+.equ OCF0A = 1 -+.equ OCF0B = 2 -+.equ ICF0 = 5 -+ -+; Timer/Counter Interrupt Mask Register 0 -+.equ TIMSK0 = 0x2b -+.equ TOIE0 = 0 -+.equ OCIE0A = 1 -+.equ OCIE0B = 2 -+.equ ICIE0 = 5 -+ -+; Timer/Counter0 Control Register C -+.equ TCCR0C = 0x2c -+.equ FOC0B = 6 -+.equ FOC0A = 7 -+ -+; Timer/Counter0 Control Register B -+.equ TCCR0B = 0x2d -+.equ CS00 = 0 -+.equ CS01 = 1 -+.equ CS02 = 2 -+.equ WGM02 = 3 -+.equ WGM03 = 4 -+.equ ICES0 = 6 -+.equ ICNC0 = 7 -+ -+; Timer/Counter0 Control Register A -+.equ TCCR0A = 0x2e -+.equ WGM00 = 0 -+.equ WGM01 = 1 -+.equ COM0B0 = 4 -+.equ COM0B1 = 5 -+.equ COM0A0 = 6 -+.equ COM0A1 = 7 -+ -+; General Timer/Counter Control Register -+.equ GTCCR = 0x2f -+.equ PSR = 0 -+.equ TSM = 7 -+ -+; Watchdog Timer Control and Status Register -+.equ WDTCSR = 0x31 -+.equ WDP0 = 0 -+.equ WDP1 = 1 -+.equ WDP2 = 2 -+.equ WDE = 3 -+.equ WDP3 = 5 -+.equ WDIE = 6 -+.equ WDIF = 7 -+ -+; Non-Volatile Memory Control and Status Register -+.equ NVMCSR = 0x32 -+.equ NVMBSY = 7 -+ -+; Non-Volatile Memory Command Register -+.equ NVMCMD = 0x33 -+.equ NVMCMD0 = 0 -+.equ NVMCMD1 = 1 -+.equ NVMCMD2 = 2 -+.equ NVMCMD3 = 3 -+.equ NVMCMD4 = 4 -+.equ NVMCMD5 = 5 -+ -+; Vcc Level Monitoring Control and Status Register -+.equ VLMCSR = 0x34 -+.equ VLM0 = 0 -+.equ VLM1 = 1 -+.equ VLM2 = 2 -+.equ VLMIE = 6 -+.equ VLMF = 7 -+ -+; Power Reduction Register -+.equ PRR = 0x35 -+.equ PRTIM0 = 0 -+.equ PRADC = 1 -+ -+; Clock Prescale Register -+.equ CLKPSR = 0x36 -+.equ CLKPS0 = 0 -+.equ CLKPS1 = 1 -+.equ CLKPS2 = 2 -+.equ CLKPS3 = 3 -+ -+; Clock Main Settings Register -+.equ CLKMSR = 0x37 -+.equ CLKMS0 = 0 -+.equ CLKMS1 = 1 -+ -+; Oscillator Calibration Register -+.equ OSCCAL = 0x39 -+.equ CAL0 = 0 -+.equ CAL1 = 1 -+.equ CAL2 = 2 -+.equ CAL3 = 3 -+.equ CAL4 = 4 -+.equ CAL5 = 5 -+.equ CAL6 = 6 -+.equ CAL7 = 7 -+ -+; Sleep Mode Control Register -+.equ SMCR = 0x3a -+.equ SE = 0 -+.equ SM0 = 1 -+.equ SM1 = 2 -+.equ SM2 = 3 -+ -+; Reset Flag Register -+.equ RSTFLR = 0x3b -+.equ PORF = 0 -+.equ EXTRF = 1 -+.equ WDRF = 3 -+ -+; Configuration Change Protection Register -+.equ CCP = 0x3c -+.equ CCP0 = 0 -+.equ CCP1 = 1 -+.equ CCP2 = 2 -+.equ CCP3 = 3 -+.equ CCP4 = 4 -+.equ CCP5 = 5 -+.equ CCP6 = 6 -+.equ CCP7 = 7 -+ -+; Stack Pointer Register -+.equ SPL = 0x3d -+.equ SPH = 0x3e -+ -+; Status Register -+.equ SREG = 0x3f -+.equ SREG_C = 0 -+.equ SREG_Z = 1 -+.equ SREG_N = 2 -+.equ SREG_V = 3 -+.equ SREG_S = 4 -+.equ SREG_H = 5 -+.equ SREG_T = 6 -+.equ SREG_I = 7 -+ -+; Indirect address registers -+.def XL = r26 -+.def XH = r27 -+.def YL = r28 -+.def YH = r29 -+.def ZL = r30 -+.def ZH = r31 -+ -+; Non-Volatile Memory Lock Bits -+.equ MAPPED_LOCKBITS_0 = 0x3f00 -+.equ NVLB1 = 0 -+.equ LB1 = 0 -+.equ NVLB2 = 1 -+.equ LB2 = 1 -+ -+; Flash Memory -+.equ PAGESIZE = 16 -+.equ FLASHEND = 0x00ff -+.equ MAPPED_FLASH_START = 0x4000 -+.equ MAPPED_FLASH_SIZE = 0x0200 -+.equ MAPPED_FLASH_END = 0x41ff -+ -+; RAM Memory -+.equ IOEND = 0x003f -+.equ RAMEND = 0x005f -+.equ SRAM_START = 0x0040 -+.equ SRAM_SIZE = 32 -+ -+; Configuration -+.equ MAPPED_CONFIG_0 = 0x3f40 -+.equ RSTDISBL = 0 -+.equ WDTON = 1 -+.equ CKOUT = 2 -+ -+; Calibration -+.equ MAPPED_CALIB_0 = 0x3f80 -+ -+; Signature -+.equ MAPPED_SIGN_0 = 0x3fc0 -+.equ MAPPED_SIGN_1 = 0x3fc1 -+.equ MAPPED_SIGN_2 = 0x3fc2 -+ -+; Interrupt Vectors -+.equ INT_VECTORS_SIZE = 10 -+.equ INT0addr = 0x0001 -+.equ PCI0addr = 0x0002 -+.equ ICP0addr = 0x0003 -+.equ OVF0addr = 0x0004 -+.equ OC0Aaddr = 0x0005 -+.equ OC0Baddr = 0x0006 -+.equ ACIaddr = 0x0007 -+.equ WDTaddr = 0x0008 -+.equ VLMaddr = 0x0009 -+ ---- /dev/null -+++ b/includes/tn5def.inc -@@ -0,0 +1,358 @@ -+; -+; Copyright (C) 2013 Milan Kupcevic -+; -+; You can redistribute and/or modify this file under the -+; terms of the GNU General Public License version 2, or -+; (at your option) any later version, as published by -+; the Free Software Foundation. -+; -+; This file is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program. If not, see . -+; -+; -+; Based on ATtiny4/5/9/10 Datasheet 8127F-AVR-02/2013. -+; -+ -+.device ATtiny5 -+ -+.equ SIGNATURE_000 = 0x1e -+.equ SIGNATURE_001 = 0x8f -+.equ SIGNATURE_002 = 0x09 -+ -+; Port B Input Pins -+.equ PINB = 0x00 -+.equ PINB0 = 0 -+.equ PINB1 = 1 -+.equ PINB2 = 2 -+.equ PINB3 = 3 -+ -+; Port B Data Direction Register -+.equ DDRB = 0x01 -+.equ DDRB0 = 0 -+.equ DDB0 = 0 -+.equ DDRB1 = 1 -+.equ DDB1 = 1 -+.equ DDRB2 = 2 -+.equ DDB2 = 2 -+.equ DDRB3 = 3 -+.equ DDB3 = 3 -+ -+; Port B Data Register -+.equ PORTB = 0x02 -+.equ PORTB0 = 0 -+.equ PB0 = 0 -+.equ PORTB1 = 1 -+.equ PB1 = 1 -+.equ PORTB2 = 2 -+.equ PB2 = 2 -+.equ PORTB3 = 3 -+.equ PB3 = 3 -+ -+; Port B Pull-up Enable Control Register -+.equ PUEB = 0x03 -+.equ PUEB0 = 0 -+.equ PUEB1 = 1 -+.equ PUEB2 = 2 -+.equ PUEB3 = 3 -+ -+; Port Control Register -+.equ PORTCR = 0x0c -+.equ BBMB = 1 -+ -+; Pin Change Mask Register -+.equ PCMSK = 0x10 -+.equ PCINT0 = 0 -+.equ PCINT1 = 1 -+.equ PCINT2 = 2 -+.equ PCINT3 = 3 -+ -+; Pin Change Interrupt Flag Register -+.equ PCIFR = 0x11 -+.equ PCIF0 = 0 -+ -+; Pin Change Interrupt Control Register -+.equ PCICR = 0x12 -+.equ PCIE0 = 0 -+ -+; External Interrupt Mask Register -+.equ EIMSK = 0x13 -+.equ INT0 = 0 -+ -+; External Interrupt Flag Register -+.equ EIFR = 0x14 -+.equ INTF0 = 0 -+ -+; External Interrupt Control Register A -+.equ EICRA = 0x15 -+.equ ISC00 = 0 -+.equ ISC01 = 1 -+ -+; Digital Input Disable Register 0 -+.equ DIDR0 = 0x17 -+.equ ADC0D = 0 -+.equ AIN0D = 0 -+.equ ADC1D = 1 -+.equ AIN1D = 1 -+.equ ADC2D = 2 -+.equ ADC3D = 3 -+ -+; ADC Data Register -+.equ ADCL = 0x19 -+.equ ADC0 = 0 -+.equ ADC1 = 1 -+.equ ADC2 = 2 -+.equ ADC3 = 3 -+.equ ADC4 = 4 -+.equ ADC5 = 5 -+.equ ADC6 = 6 -+.equ ADC7 = 7 -+ -+; ADC Multiplexer Selection Register -+.equ ADMUX = 0x1b -+.equ MUX0 = 0 -+.equ MUX1 = 1 -+ -+; ADC Control and Status Register B -+.equ ADCSRB = 0x1c -+.equ ADTS0 = 0 -+.equ ADTS1 = 1 -+.equ ADTS2 = 2 -+ -+; ADC Control and Status Register A -+.equ ADCSRA = 0x1d -+.equ ADPS0 = 0 -+.equ ADPS1 = 1 -+.equ ADPS2 = 2 -+.equ ADIE = 3 -+.equ ADIF = 4 -+.equ ADATE = 5 -+.equ ADSC = 6 -+.equ ADEN = 7 -+ -+; Analog Comparator Control and Status Register -+.equ ACSR = 0x1f -+.equ ACIS0 = 0 -+.equ ACIS1 = 1 -+.equ ACIC = 2 -+.equ ACIE = 3 -+.equ ACI = 4 -+.equ ACO = 5 -+.equ ACD = 7 -+ -+; Input Capture Register 0 -+.equ ICR0L = 0x22 -+.equ ICR0H = 0x23 -+ -+; Output Compare Register 0 B -+.equ OCR0BL = 0x24 -+.equ OCR0BH = 0x25 -+ -+; Output Compare Register 0 A -+.equ OCR0AL = 0x26 -+.equ OCR0AH = 0x27 -+ -+; Timer/Counter0 -+.equ TCNT0L = 0x28 -+.equ TCNT0H = 0x29 -+ -+; Timer/Counter Interrupt Flag Register 0 -+.equ TIFR0 = 0x2a -+.equ TOV0 = 0 -+.equ OCF0A = 1 -+.equ OCF0B = 2 -+.equ ICF0 = 5 -+ -+; Timer/Counter Interrupt Mask Register 0 -+.equ TIMSK0 = 0x2b -+.equ TOIE0 = 0 -+.equ OCIE0A = 1 -+.equ OCIE0B = 2 -+.equ ICIE0 = 5 -+ -+; Timer/Counter0 Control Register C -+.equ TCCR0C = 0x2c -+.equ FOC0B = 6 -+.equ FOC0A = 7 -+ -+; Timer/Counter0 Control Register B -+.equ TCCR0B = 0x2d -+.equ CS00 = 0 -+.equ CS01 = 1 -+.equ CS02 = 2 -+.equ WGM02 = 3 -+.equ WGM03 = 4 -+.equ ICES0 = 6 -+.equ ICNC0 = 7 -+ -+; Timer/Counter0 Control Register A -+.equ TCCR0A = 0x2e -+.equ WGM00 = 0 -+.equ WGM01 = 1 -+.equ COM0B0 = 4 -+.equ COM0B1 = 5 -+.equ COM0A0 = 6 -+.equ COM0A1 = 7 -+ -+; General Timer/Counter Control Register -+.equ GTCCR = 0x2f -+.equ PSR = 0 -+.equ TSM = 7 -+ -+; Watchdog Timer Control and Status Register -+.equ WDTCSR = 0x31 -+.equ WDP0 = 0 -+.equ WDP1 = 1 -+.equ WDP2 = 2 -+.equ WDE = 3 -+.equ WDP3 = 5 -+.equ WDIE = 6 -+.equ WDIF = 7 -+ -+; Non-Volatile Memory Control and Status Register -+.equ NVMCSR = 0x32 -+.equ NVMBSY = 7 -+ -+; Non-Volatile Memory Command Register -+.equ NVMCMD = 0x33 -+.equ NVMCMD0 = 0 -+.equ NVMCMD1 = 1 -+.equ NVMCMD2 = 2 -+.equ NVMCMD3 = 3 -+.equ NVMCMD4 = 4 -+.equ NVMCMD5 = 5 -+ -+; Vcc Level Monitoring Control and Status Register -+.equ VLMCSR = 0x34 -+.equ VLM0 = 0 -+.equ VLM1 = 1 -+.equ VLM2 = 2 -+.equ VLMIE = 6 -+.equ VLMF = 7 -+ -+; Power Reduction Register -+.equ PRR = 0x35 -+.equ PRTIM0 = 0 -+.equ PRADC = 1 -+ -+; Clock Prescale Register -+.equ CLKPSR = 0x36 -+.equ CLKPS0 = 0 -+.equ CLKPS1 = 1 -+.equ CLKPS2 = 2 -+.equ CLKPS3 = 3 -+ -+; Clock Main Settings Register -+.equ CLKMSR = 0x37 -+.equ CLKMS0 = 0 -+.equ CLKMS1 = 1 -+ -+; Oscillator Calibration Register -+.equ OSCCAL = 0x39 -+.equ CAL0 = 0 -+.equ CAL1 = 1 -+.equ CAL2 = 2 -+.equ CAL3 = 3 -+.equ CAL4 = 4 -+.equ CAL5 = 5 -+.equ CAL6 = 6 -+.equ CAL7 = 7 -+ -+; Sleep Mode Control Register -+.equ SMCR = 0x3a -+.equ SE = 0 -+.equ SM0 = 1 -+.equ SM1 = 2 -+.equ SM2 = 3 -+ -+; Reset Flag Register -+.equ RSTFLR = 0x3b -+.equ PORF = 0 -+.equ EXTRF = 1 -+.equ WDRF = 3 -+ -+; Configuration Change Protection Register -+.equ CCP = 0x3c -+.equ CCP0 = 0 -+.equ CCP1 = 1 -+.equ CCP2 = 2 -+.equ CCP3 = 3 -+.equ CCP4 = 4 -+.equ CCP5 = 5 -+.equ CCP6 = 6 -+.equ CCP7 = 7 -+ -+; Stack Pointer Register -+.equ SPL = 0x3d -+.equ SPH = 0x3e -+ -+; Status Register -+.equ SREG = 0x3f -+.equ SREG_C = 0 -+.equ SREG_Z = 1 -+.equ SREG_N = 2 -+.equ SREG_V = 3 -+.equ SREG_S = 4 -+.equ SREG_H = 5 -+.equ SREG_T = 6 -+.equ SREG_I = 7 -+ -+; Indirect address registers -+.def XL = r26 -+.def XH = r27 -+.def YL = r28 -+.def YH = r29 -+.def ZL = r30 -+.def ZH = r31 -+ -+; Non-Volatile Memory Lock Bits -+.equ MAPPED_LOCKBITS_0 = 0x3f00 -+.equ NVLB1 = 0 -+.equ LB1 = 0 -+.equ NVLB2 = 1 -+.equ LB2 = 1 -+ -+; Flash Memory -+.equ PAGESIZE = 16 -+.equ FLASHEND = 0x00ff -+.equ MAPPED_FLASH_START = 0x4000 -+.equ MAPPED_FLASH_SIZE = 0x0200 -+.equ MAPPED_FLASH_END = 0x41ff -+ -+; RAM Memory -+.equ IOEND = 0x003f -+.equ RAMEND = 0x005f -+.equ SRAM_START = 0x0040 -+.equ SRAM_SIZE = 32 -+ -+; Configuration -+.equ MAPPED_CONFIG_0 = 0x3f40 -+.equ RSTDISBL = 0 -+.equ WDTON = 1 -+.equ CKOUT = 2 -+ -+; Calibration -+.equ MAPPED_CALIB_0 = 0x3f80 -+ -+; Signature -+.equ MAPPED_SIGN_0 = 0x3fc0 -+.equ MAPPED_SIGN_1 = 0x3fc1 -+.equ MAPPED_SIGN_2 = 0x3fc2 -+ -+; Interrupt Vectors -+.equ INT_VECTORS_SIZE = 11 -+.equ INT0addr = 0x0001 -+.equ PCI0addr = 0x0002 -+.equ ICP0addr = 0x0003 -+.equ OVF0addr = 0x0004 -+.equ OC0Aaddr = 0x0005 -+.equ OC0Baddr = 0x0006 -+.equ ACIaddr = 0x0007 -+.equ WDTaddr = 0x0008 -+.equ VLMaddr = 0x0009 -+.equ ADCCaddr = 0x000a -+ ---- /dev/null -+++ b/includes/tn9def.inc -@@ -0,0 +1,320 @@ -+; -+; Copyright (C) 2013 Milan Kupcevic -+; -+; You can redistribute and/or modify this file under the -+; terms of the GNU General Public License version 2, or -+; (at your option) any later version, as published by -+; the Free Software Foundation. -+; -+; This file is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program. If not, see . -+; -+; -+; Based on ATtiny4/5/9/10 Datasheet 8127F-AVR-02/2013. -+; -+ -+.device ATtiny9 -+ -+.equ SIGNATURE_000 = 0x1e -+.equ SIGNATURE_001 = 0x90 -+.equ SIGNATURE_002 = 0x08 -+ -+; Port B Input Pins -+.equ PINB = 0x00 -+.equ PINB0 = 0 -+.equ PINB1 = 1 -+.equ PINB2 = 2 -+.equ PINB3 = 3 -+ -+; Port B Data Direction Register -+.equ DDRB = 0x01 -+.equ DDRB0 = 0 -+.equ DDB0 = 0 -+.equ DDRB1 = 1 -+.equ DDB1 = 1 -+.equ DDRB2 = 2 -+.equ DDB2 = 2 -+.equ DDRB3 = 3 -+.equ DDB3 = 3 -+ -+; Port B Data Register -+.equ PORTB = 0x02 -+.equ PORTB0 = 0 -+.equ PB0 = 0 -+.equ PORTB1 = 1 -+.equ PB1 = 1 -+.equ PORTB2 = 2 -+.equ PB2 = 2 -+.equ PORTB3 = 3 -+.equ PB3 = 3 -+ -+; Port B Pull-up Enable Control Register -+.equ PUEB = 0x03 -+.equ PUEB0 = 0 -+.equ PUEB1 = 1 -+.equ PUEB2 = 2 -+.equ PUEB3 = 3 -+ -+; Port Control Register -+.equ PORTCR = 0x0c -+.equ BBMB = 1 -+ -+; Pin Change Mask Register -+.equ PCMSK = 0x10 -+.equ PCINT0 = 0 -+.equ PCINT1 = 1 -+.equ PCINT2 = 2 -+.equ PCINT3 = 3 -+ -+; Pin Change Interrupt Flag Register -+.equ PCIFR = 0x11 -+.equ PCIF0 = 0 -+ -+; Pin Change Interrupt Control Register -+.equ PCICR = 0x12 -+.equ PCIE0 = 0 -+ -+; External Interrupt Mask Register -+.equ EIMSK = 0x13 -+.equ INT0 = 0 -+ -+; External Interrupt Flag Register -+.equ EIFR = 0x14 -+.equ INTF0 = 0 -+ -+; External Interrupt Control Register A -+.equ EICRA = 0x15 -+.equ ISC00 = 0 -+.equ ISC01 = 1 -+ -+; Digital Input Disable Register 0 -+.equ DIDR0 = 0x17 -+.equ AIN0D = 0 -+.equ AIN1D = 1 -+ -+; Analog Comparator Control and Status Register -+.equ ACSR = 0x1f -+.equ ACIS0 = 0 -+.equ ACIS1 = 1 -+.equ ACIC = 2 -+.equ ACIE = 3 -+.equ ACI = 4 -+.equ ACO = 5 -+.equ ACD = 7 -+ -+; Input Capture Register 0 -+.equ ICR0L = 0x22 -+.equ ICR0H = 0x23 -+ -+; Output Compare Register 0 B -+.equ OCR0BL = 0x24 -+.equ OCR0BH = 0x25 -+ -+; Output Compare Register 0 A -+.equ OCR0AL = 0x26 -+.equ OCR0AH = 0x27 -+ -+; Timer/Counter0 -+.equ TCNT0L = 0x28 -+.equ TCNT0H = 0x29 -+ -+; Timer/Counter Interrupt Flag Register 0 -+.equ TIFR0 = 0x2a -+.equ TOV0 = 0 -+.equ OCF0A = 1 -+.equ OCF0B = 2 -+.equ ICF0 = 5 -+ -+; Timer/Counter Interrupt Mask Register 0 -+.equ TIMSK0 = 0x2b -+.equ TOIE0 = 0 -+.equ OCIE0A = 1 -+.equ OCIE0B = 2 -+.equ ICIE0 = 5 -+ -+; Timer/Counter0 Control Register C -+.equ TCCR0C = 0x2c -+.equ FOC0B = 6 -+.equ FOC0A = 7 -+ -+; Timer/Counter0 Control Register B -+.equ TCCR0B = 0x2d -+.equ CS00 = 0 -+.equ CS01 = 1 -+.equ CS02 = 2 -+.equ WGM02 = 3 -+.equ WGM03 = 4 -+.equ ICES0 = 6 -+.equ ICNC0 = 7 -+ -+; Timer/Counter0 Control Register A -+.equ TCCR0A = 0x2e -+.equ WGM00 = 0 -+.equ WGM01 = 1 -+.equ COM0B0 = 4 -+.equ COM0B1 = 5 -+.equ COM0A0 = 6 -+.equ COM0A1 = 7 -+ -+; General Timer/Counter Control Register -+.equ GTCCR = 0x2f -+.equ PSR = 0 -+.equ TSM = 7 -+ -+; Watchdog Timer Control and Status Register -+.equ WDTCSR = 0x31 -+.equ WDP0 = 0 -+.equ WDP1 = 1 -+.equ WDP2 = 2 -+.equ WDE = 3 -+.equ WDP3 = 5 -+.equ WDIE = 6 -+.equ WDIF = 7 -+ -+; Non-Volatile Memory Control and Status Register -+.equ NVMCSR = 0x32 -+.equ NVMBSY = 7 -+ -+; Non-Volatile Memory Command Register -+.equ NVMCMD = 0x33 -+.equ NVMCMD0 = 0 -+.equ NVMCMD1 = 1 -+.equ NVMCMD2 = 2 -+.equ NVMCMD3 = 3 -+.equ NVMCMD4 = 4 -+.equ NVMCMD5 = 5 -+ -+; Vcc Level Monitoring Control and Status Register -+.equ VLMCSR = 0x34 -+.equ VLM0 = 0 -+.equ VLM1 = 1 -+.equ VLM2 = 2 -+.equ VLMIE = 6 -+.equ VLMF = 7 -+ -+; Power Reduction Register -+.equ PRR = 0x35 -+.equ PRTIM0 = 0 -+.equ PRADC = 1 -+ -+; Clock Prescale Register -+.equ CLKPSR = 0x36 -+.equ CLKPS0 = 0 -+.equ CLKPS1 = 1 -+.equ CLKPS2 = 2 -+.equ CLKPS3 = 3 -+ -+; Clock Main Settings Register -+.equ CLKMSR = 0x37 -+.equ CLKMS0 = 0 -+.equ CLKMS1 = 1 -+ -+; Oscillator Calibration Register -+.equ OSCCAL = 0x39 -+.equ CAL0 = 0 -+.equ CAL1 = 1 -+.equ CAL2 = 2 -+.equ CAL3 = 3 -+.equ CAL4 = 4 -+.equ CAL5 = 5 -+.equ CAL6 = 6 -+.equ CAL7 = 7 -+ -+; Sleep Mode Control Register -+.equ SMCR = 0x3a -+.equ SE = 0 -+.equ SM0 = 1 -+.equ SM1 = 2 -+.equ SM2 = 3 -+ -+; Reset Flag Register -+.equ RSTFLR = 0x3b -+.equ PORF = 0 -+.equ EXTRF = 1 -+.equ WDRF = 3 -+ -+; Configuration Change Protection Register -+.equ CCP = 0x3c -+.equ CCP0 = 0 -+.equ CCP1 = 1 -+.equ CCP2 = 2 -+.equ CCP3 = 3 -+.equ CCP4 = 4 -+.equ CCP5 = 5 -+.equ CCP6 = 6 -+.equ CCP7 = 7 -+ -+; Stack Pointer Register -+.equ SPL = 0x3d -+.equ SPH = 0x3e -+ -+; Status Register -+.equ SREG = 0x3f -+.equ SREG_C = 0 -+.equ SREG_Z = 1 -+.equ SREG_N = 2 -+.equ SREG_V = 3 -+.equ SREG_S = 4 -+.equ SREG_H = 5 -+.equ SREG_T = 6 -+.equ SREG_I = 7 -+ -+; Indirect address registers -+.def XL = r26 -+.def XH = r27 -+.def YL = r28 -+.def YH = r29 -+.def ZL = r30 -+.def ZH = r31 -+ -+; Non-Volatile Memory Lock Bits -+.equ MAPPED_LOCKBITS_0 = 0x3f00 -+.equ NVLB1 = 0 -+.equ LB1 = 0 -+.equ NVLB2 = 1 -+.equ LB2 = 1 -+ -+; Flash Memory -+.equ PAGESIZE = 16 -+.equ FLASHEND = 0x01ff -+.equ MAPPED_FLASH_START = 0x4000 -+.equ MAPPED_FLASH_SIZE = 0x0400 -+.equ MAPPED_FLASH_END = 0x43ff -+ -+; RAM Memory -+.equ IOEND = 0x003f -+.equ RAMEND = 0x005f -+.equ SRAM_START = 0x0040 -+.equ SRAM_SIZE = 32 -+ -+; Configuration -+.equ MAPPED_CONFIG_0 = 0x3f40 -+.equ RSTDISBL = 0 -+.equ WDTON = 1 -+.equ CKOUT = 2 -+ -+; Calibration -+.equ MAPPED_CALIB_0 = 0x3f80 -+ -+; Signature -+.equ MAPPED_SIGN_0 = 0x3fc0 -+.equ MAPPED_SIGN_1 = 0x3fc1 -+.equ MAPPED_SIGN_2 = 0x3fc2 -+ -+; Interrupt Vectors -+.equ INT_VECTORS_SIZE = 10 -+.equ INT0addr = 0x0001 -+.equ PCI0addr = 0x0002 -+.equ ICP0addr = 0x0003 -+.equ OVF0addr = 0x0004 -+.equ OC0Aaddr = 0x0005 -+.equ OC0Baddr = 0x0006 -+.equ ACIaddr = 0x0007 -+.equ WDTaddr = 0x0008 -+.equ VLMaddr = 0x0009 -+ diff -Nru avra-1.3.0/debian/patches/typo-fixes.patch avra-1.4.2+dfsg/debian/patches/typo-fixes.patch --- avra-1.3.0/debian/patches/typo-fixes.patch 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/patches/typo-fixes.patch 2023-03-22 12:55:53.000000000 +0000 @@ -0,0 +1,101 @@ +Description: typo fixes +Author: Milan Kupcevic +Forwarded: https://github.com/Ro5bert/avra/pull/60 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/README.md ++++ b/README.md +@@ -1,6 +1,6 @@ + # AVRA + +-*Assember for the Atmel AVR microcontroller family* ++*Assembler for the Atmel AVR microcontroller family* + + AVRA is an assembler for Atmel AVR microcontrollers, and it is almost + compatible with Atmel's own assembler, AVRASM32. AVRA is written in C99. +@@ -9,7 +9,7 @@ + + There are some differences between the original Atmel assembler AVRASM32 and + AVRA. Basically, AVRA is designed to replace AVRASM32 without special changes +-in your current Atmel AVR Studio enviroment. Command line options have been ++in your current Atmel AVR Studio environment. Command line options have been + adapted as far as possible. Jumping to fault-containing lines directly by + double-clicking on the error message in the output window does work as with + AVRASM32. +@@ -39,7 +39,7 @@ + + #### Debugging support + +-AVRA creates a coff file everytime assembly is sucessful. This ++AVRA creates a coff file every time assembly is successful. This + file allows AVR Studio or any coff compatible debugger to simulate + or emulate the program. + +--- a/USAGE.md ++++ b/USAGE.md +@@ -5,10 +5,10 @@ + control the output filename with `-o`. See `--help` for more options (not all + options work). + +-## Warning Supression ++## Warning Suppression + +-There is a possibility to supress certain warnings. +-Currently only register reassignment warnings can be supressed: ++There is a possibility to suppress certain warnings. ++Currently only register reassignment warnings can be suppressed: + + avra -W NoRegDef + +@@ -34,7 +34,7 @@ + Both versions are equivalent, as AVRA will implicitly define `network` to be 1 + in the second case. (Although, if you really want `network` to be 1, you + should use the first version.) You may want to assemble a specific part of your +-code depeding on a define or switch setting. You can test your defined word on ++code depending on a define or switch setting. You can test your defined word on + existence (`.ifdef` and `.ifndef`) as well as on the value it represents. The + following code shows a way to prevent error messages due to testing undefined + constants: +@@ -69,7 +69,7 @@ + + ### Directives `.nolist` and `.list` + +-The ouput to the list file can be paused and resumed by the `.nolist` and ++The output to the list file can be paused and resumed by the `.nolist` and + `.list` directives. After AVRA discovers a `.nolist` while assembling, it + stops output to the list file. After a `.list` directive is detected, AVRA + continues the normal list file output. +@@ -131,7 +131,7 @@ + + ### Automatic Type Conversion For Macros + +-Values representing more than 8 bits are usualy kept in a set of byte wide ++Values representing more than 8 bits are usually kept in a set of byte wide + registers. To simplify 16 bit operations, words can be written as `r16:r17`. In + this example, `r16` contains the most significant byte and register `r17` + contains the least significant byte. In the same way, a 24 bit value stored +@@ -168,7 +168,7 @@ + .def w = r20 ; working registers + .def v = r21 + +-If we substract the 16 bit value `c:d` from `a:b`, we usually have to use the ++If we subtract the 16 bit value `c:d` from `a:b`, we usually have to use the + following command sequence: + + sub b,d +@@ -278,7 +278,7 @@ + + + ; This writes 9999 into the memory at 'counter' using only the working +- ; register for transfering the values. ++ ; register for transferring the values. + + poke [counter,w:w,9999] + +@@ -379,5 +379,5 @@ + + If you get an "internal assembler error" please contact the project maintainer + via the [GitHub issue tracker](https://github.com/Ro5bert/avra/issues). Be sure +-to include a code example and a description of your working enviroment. ++to include a code example and a description of your working environment. + diff -Nru avra-1.3.0/debian/rules avra-1.4.2+dfsg/debian/rules --- avra-1.3.0/debian/rules 2016-05-24 03:39:29.000000000 +0000 +++ avra-1.4.2+dfsg/debian/rules 2023-03-22 04:48:12.000000000 +0000 @@ -5,11 +5,17 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all %: - dh $@ --sourcedirectory=src + dh $@ -override_dh_auto_configure: - cd src; AUTOMAKE="automake --foreign" autoreconf -i - dh_auto_configure --sourcedirectory=src +override_dh_auto_build: + dh_auto_build -- \ + PREFIX=/usr \ + TARGET_INCLUDE_PATH=/usr/share/avra -override_dh_installchangelogs: - dh_installchangelogs doc/ChangeLog.html +override_dh_auto_install: + dh_auto_install -- \ + PREFIX=/usr \ + TARGET_INCLUDE_PATH=/usr/share/avra + +override_dh_missing: + dh_missing --list-missing diff -Nru avra-1.3.0/debian/tests/control avra-1.4.2+dfsg/debian/tests/control --- avra-1.3.0/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/debian/tests/control 2023-03-22 12:55:53.000000000 +0000 @@ -0,0 +1,2 @@ +Test-Command: avra --devices | grep ATmega328 +Depends: avra diff -Nru avra-1.3.0/debian/watch avra-1.4.2+dfsg/debian/watch --- avra-1.3.0/debian/watch 2013-09-07 18:58:54.000000000 +0000 +++ avra-1.4.2+dfsg/debian/watch 2023-03-22 01:39:58.000000000 +0000 @@ -1,2 +1,7 @@ -version=3 -http://sf.net/avra/ avra-([[:alnum:]\.]*)(?:-src|)\.tar\.(?:gz|bz2|xz) +version=4 +opts="searchmode=plain,compression=xz,repack,repacksuffix=+dfsg,\ +dversionmangle=s:.dfsg[0-9]*::,\ +filenamemangle=s%@ANY_VERSION@$%@PACKAGE@-$1.tar.gz%,\ +uversionmangle=s:(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|a|b)\d*)$:$1~$2:" \ +https://api.github.com/repos/Ro5bert/avra/tags?per_page=50 \ +https://api.github.com/repos/[^/]+/[^/]+/tarball/refs/tags/@ANY_VERSION@ diff -Nru avra-1.3.0/doc/asciidoc-xhtml11.js avra-1.4.2+dfsg/doc/asciidoc-xhtml11.js --- avra-1.3.0/doc/asciidoc-xhtml11.js 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/asciidoc-xhtml11.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -var asciidoc = { // Namespace. - -///////////////////////////////////////////////////////////////////// -// Table Of Contents generator -///////////////////////////////////////////////////////////////////// - -/* Author: Mihai Bazon, September 2002 - * http://students.infoiasi.ro/~mishoo - * - * Table Of Content generator - * Version: 0.4 - * - * Feel free to use this script under the terms of the GNU General Public - * License, as long as you do not remove or alter this notice. - */ - - /* modified by Troy D. Hanson, September 2006. License: GPL */ - /* modified by Stuart Rackham, 2006, 2009. License: GPL */ - -// toclevels = 1..4. -toc: function (toclevels) { - - function getText(el) { - var text = ""; - for (var i = el.firstChild; i != null; i = i.nextSibling) { - if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. - text += i.data; - else if (i.firstChild != null) - text += getText(i); - } - return text; - } - - function TocEntry(el, text, toclevel) { - this.element = el; - this.text = text; - this.toclevel = toclevel; - } - - function tocEntries(el, toclevels) { - var result = new Array; - var re = new RegExp('[hH]([2-'+(toclevels+1)+'])'); - // Function that scans the DOM tree for header elements (the DOM2 - // nodeIterator API would be a better technique but not supported by all - // browsers). - var iterate = function (el) { - for (var i = el.firstChild; i != null; i = i.nextSibling) { - if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { - var mo = re.exec(i.tagName); - if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { - result[result.length] = new TocEntry(i, getText(i), mo[1]-1); - } - iterate(i); - } - } - } - iterate(el); - return result; - } - - var toc = document.getElementById("toc"); - var entries = tocEntries(document.getElementById("content"), toclevels); - for (var i = 0; i < entries.length; ++i) { - var entry = entries[i]; - if (entry.element.id == "") - entry.element.id = "_toc_" + i; - var a = document.createElement("a"); - a.href = "#" + entry.element.id; - a.appendChild(document.createTextNode(entry.text)); - var div = document.createElement("div"); - div.appendChild(a); - div.className = "toclevel" + entry.toclevel; - toc.appendChild(div); - } - if (entries.length == 0) - toc.parentNode.removeChild(toc); -}, - - -///////////////////////////////////////////////////////////////////// -// Footnotes generator -///////////////////////////////////////////////////////////////////// - -/* Based on footnote generation code from: - * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html - */ - -footnotes: function () { - var cont = document.getElementById("content"); - var noteholder = document.getElementById("footnotes"); - var spans = cont.getElementsByTagName("span"); - var refs = {}; - var n = 0; - for (i=0; i" + - "" + - n + ". " + note + ""; - spans[i].innerHTML = - "[" + n + "]"; - var id =spans[i].getAttribute("id"); - if (id != null) refs["#"+id] = n; - } - } - if (n == 0) - noteholder.parentNode.removeChild(noteholder); - else { - // Process footnoterefs. - for (i=0; i" + n + "]"; - } - } - } -} - -} diff -Nru avra-1.3.0/doc/build-website.sh avra-1.4.2+dfsg/doc/build-website.sh --- avra-1.3.0/doc/build-website.sh 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/build-website.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -#!/bin/sh - -VERS="1.3.0" -DATE="2010-06-28" - -ASCIIDOC_HTML="asciidoc --unsafe --backend=xhtml11 --conf-file=layout1.conf --attribute icons --attribute iconsdir=./images/icons --attribute=badges --attribute=revision=$VERS --attribute=date=$DATE" - -$ASCIIDOC_HTML -a index-only index.txt -$ASCIIDOC_HTML ChangeLog.txt -$ASCIIDOC_HTML downloads.txt -$ASCIIDOC_HTML README.txt diff -Nru avra-1.3.0/doc/ChangeLog.html avra-1.4.2+dfsg/doc/ChangeLog.html --- avra-1.3.0/doc/ChangeLog.html 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/ChangeLog.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ - - - - - - - - - - -AVRA ChangeLog - - -
-
AVRA
-
Assember for the Atmel AVR microcontroller family
-
- - - - - -
- - - - - - - -
- -
-

Version 1.3.0 (20100628)

-
-

by Jerry Jacobs

-
Additions and changes
    -
  • -

    -Added new targets, ATtiny13A, ATtiny24/A, ATtiny44/A, ATtiny84, ATtiny2313A, - ATtiny4313, ATmega328P -

    -
  • -
  • -

    -Added mingw32 support for building windows binairies from linux host -

    -
  • -
  • -

    -Removed obsolete Dev-C++ for windows building -

    -
  • -
  • -

    -Updated documentation and rewritten in asciidoc markup language -

    -
  • -
-
Bug fixes
    -
  • -

    -FIXED: 1934647: Handle also # directives because include files don’t use . directives. -

    -
  • -
  • -

    -FIXED: 1970530: Make whitespace character possible between function name and open bracket. -

    -
  • -
  • -

    -FIXED: 1970630: Make line continuation possible with backslash as the last character of a line. -

    -
  • -
  • -

    -FIXED: 2929406: Change incorrect argument --includedir to includepath. -

    -
  • -
-
-

Version 1.2.3 (20071115)

-
-

by Burkhard Arenfeld

-
    -
  • -

    -Fix bug 1697037 (Error with single character ;) -

    -
  • -
  • -

    -Better check for line termination. Now a single CR or a FF generates an warning message. Code with bad CR - termination could appear, if you edit CR-LF terminated files (WIN/DOS) with linux (LF only) editors. -

    -
  • -
  • -

    -Add patch 1604128 from Jim Galbraith (New devices ATtiny25/45/85, small fix for ATmega8 (no jmp, call instruction)) -

    -
  • -
  • -

    -Fix bug in handling of special tags (%HOUR% …). A % without a special tag was replaced by previous tag value. -

    -
  • -
  • -

    -Use a global timestamp for all functions which needs a time (pi→time). -

    -
  • -
  • -

    -Fix bug in handling of unknown args (E.g.: avra --abc → Segfault). -

    -
  • -
  • -

    -Fix segfault if .error directive without parameter is used. -

    -
  • -
  • -

    -Add a warning, if characters with code > 127 are used in .db strings and fix listing output. -

    -
  • -
  • -

    -Take a look at Testcode_avra-1_2_3.asm, which demonstrate some differences between 1.2.3 and previous releases -

    -
  • -
  • -

    -AVR000.zip contains some header files for different devices. -

    -
  • -
  • -

    -Included avra binary was created with ubuntu 7.10 linux -

    -
  • -
-
Bug fixes
    -
  • -

    -FIXED: 1462900: Segfault, if error in -D parameter. -

    -
  • -
  • -

    -FIXED: 1742436: Error in .dseg size check. -

    -
  • -
  • -

    -FIXED: 1742437: Error in EEPROM presence check -

    -
  • -
-
-

Version 1.2.2 (20070511)

-
-

by Burkhard Arenfeld

-
    -
  • -

    -Check in print_msg() if filename is NULL. Avoid printing a NULL-Pointer. -

    -
  • -
  • -

    -Warning, if no .DEVICE was found, because address range check doesn’t work without it -

    -
  • -
  • -

    -Error, if more than one .DEVICE was found. -

    -
  • -
  • -

    -Error, if .DEVICE is after any assembled code or .ORG directive, because .DEVICE resets the address - counters and the assembler builds wrong code. -

    -
  • -
  • -

    -Create a list of program segments (see orglist). Every .ORG, .DEVICE, .?SEG is stored, so the - assembler now can check for overlapping segments. Now overlapped segments in Flash, Data or EEPROM memory - are detected. Very usefull, if .ORG is used to build tables or bootloader code at specific addresses. -

    -
  • -
  • -

    -Better check for exceeding device space in RAM, Flash or EEPROM memory. Now not the total count of - assembled memory is used, instead every assembled address range is checked. -

    -
  • -
  • -

    -.DSEG and .ESEG now generates an error, if device has no RAM / EEPROM. -

    -
  • -
  • -

    -Now a warning appears, if a .DEF name is already used as constant or label. Atmel assembler generates this - warning, too. -

    -
  • -
  • -

    -Fix a small bug in the example program. -

    -
  • -
-
-

Version 1.2.1 (20061117)

-
-

by Roland Riegel

-
    -
  • -

    -Some of the high end AVRs use the SRAM adress range from 0x60 to 0x100 for IO extension. - Avra so far used to start with SRAM Usage at 0x60. This is now set from case by case. -

    -
  • -
-
-

Version 1.2.0 (20061015)

-
-

by Burkhard Arenfeld

-
    -
  • -

    -Patch segfault, if .error is given without parameter -

    -
  • -
  • -

    -Patch segfault, if .device is given with an invalid parameter -

    -
  • -
  • -

    -Check in predef_dev() if symbol is already defined. Can happens, if someone - tries to define the symbol with the -D parameter. E.g.: avra -D ATMEGA8 Test.asm - now generate error message, because ATMEGA8 is reserved -

    -
  • -
  • -

    -Add .elseif directive. It’s the same like .elif. (Original Atmel assembler use .elseif - and not .elif) -

    -
  • -
  • -

    -In .db lines strings can now contain , and ; characters. -

    -
  • -
  • -

    -Allow forward declaration of constants (.equ) except for .ifdef and .ifndef. - Invalid forward declarations are checked now. (In the first pass undefined Symbols in - .ifdef and .ifndef parameters are stored in a blacklist and checked in the second pass) -

    -
  • -
  • -

    -Extend the .message directive for better debugging. Now it accept not only a String. - You can use a list of expressions like in a .db directive as parameter. -

    -
  • -
  • -

    -The assembler pass variable moved into the pi struct. I deleted the pass variable from - a lot of functions. -

    -
  • -
  • -

    -New functions in avra.c. It was easier for me, to understand the code without the - for(label = first; …)-loops. Replaced a lot of for(label = …) -loops by one of this - functions. -

    -
  • -
-
-

Version 1.1.1 (20060906)

-
-
    -
  • -

    -right shift operator bug -

    -
  • -
  • -

    -LPM is supported on ATtiny26 but avra say it isn’t -

    -
  • -
  • -

    -bugfix for jmp/call opcode -

    -
  • -
  • -

    -crash due to a strcmp with null pointer when parsing the cmd line args -

    -
  • -
-
-

Version 1.1.0 (20051227)

-
-

by Tobias Weber

-
    -
  • -

    -.DW defines were missing in the listfile. -

    -
  • -
  • -

    -Support for mega8515. -

    -
  • -
  • -

    -Fix for generic register names and extended macro syntax. -

    -
  • -
  • -

    -Makefile for lcc-win32 Compiler. -

    -
  • -
  • -

    -Changed "global" keyword to ".global". -

    -
  • -
  • -

    -Added .includepath directive that allows setting include path. -

    -
  • -
  • -

    -segfault when not passing any sourcefiles. -

    -
  • -
  • -

    ---define FOO=2 does not work as claimed by the documentation. -

    -
  • -
  • -

    -Added return value, indicating whether avra failed or succeded. -

    -
  • -
  • -

    -Added support for automake utilities. See manual for more info. -

    -
  • -
  • -

    -if no code is present, eeprom hex file will be written anyway. -

    -
  • -
  • -

    -added -W NoRegDef for suppressing Register assignment warnings. -

    -
  • -
  • -

    -.db values were sometimes wrong printed in lst file with 6 leading F. -

    -
  • -
  • -

    -Added BYTE1() function equivalent to LOW(). -

    -
  • -
  • -

    -The character " (pharentesis) could not be use as single character like " -

    -
  • -
-
-

Version 1.0.1 (20040610)

-
-

by Tobias Weber

-
    -
  • -

    -Added meta tags for time and date. -

    -
  • -
  • -

    -Expression of .elif was cutted off in list file - fixed. -

    -
  • -
  • -

    -.equ, .org, .defines added to list file output. -

    -
  • -
  • -

    -Values and expressions of .db assignemts are now listed in listfile. -

    -
  • -
  • -

    -Added Support for ATmega48, ATmega88 and ATmega168. -

    -
  • -
  • -

    -Added .include error file name print out. -

    -
  • -
  • -

    -Fixed seg fault that could happen while using .LIST directive with no - listfile switched on. -

    -
  • -
  • -

    -Error when using comments within macros that made use of sign @ fixed. -

    -
  • -
  • -

    -Listfile lines are now prefixed with the current segment C,D,E for - code, data and eeprom. -

    -
  • -
-
-

Version 1.0.0 (20040214)

-
-

by Tobias Weber

-
    -
  • -

    -Added support for ATtiny13 and ATtiny2313 -

    -
  • -
  • -

    -List file command line syntax now AVRASM compatible -

    -
  • -
  • -

    -Map file command line syntax now AVRASM compatible -

    -
  • -
  • -

    -Fixed problem with limited macro label running numbers -

    -
  • -
  • -

    -Now multiple labels can be used within macros -

    -
  • -
  • -

    -Fixed error output line number for included files -

    -
  • -
  • -

    -code cleaned up -

    -
  • -
-
-

Version 0.9.1 (20030602)

-
-

by Tobias Weber

-
    -
  • -

    -fixed code for Linux compiler -

    -
  • -
  • -

    -fixed nested macro labels -

    -
  • -
  • -

    -code cleaned up -

    -
  • -
-
-

Version 0.9 (20030523)

-
-

by Tobias Weber

-
    -
  • -

    -Added labels to macros -

    -
  • -
  • -

    -Added special codes dst and src -

    -
  • -
  • -

    -Added directive .endmacro, only .endm was allowed so far -

    -
  • -
  • -

    -Added a return(0); at the end of main() to quiet the Borland C++ 5.5 - compiler (Jim Galbraith) -

    -
  • -
  • -

    -Fixed wrong flash size calculation (Jim Galbraith) -

    -
  • -
  • -

    -In device.c, added ATtiny26 to struct device device_list[] (Jim Galbraith) -

    -
  • -
-
-

Version 0.8 (20030307)

-
-

by Tobias Weber

-
    -
  • -

    -Added new macro assembler coding facilities -

    -
  • -
  • -

    -Added error description for .include directives -

    -
  • -
-
-

Version 0.7 (20000217)

-
-
    -
  • -

    -Added supported() function to check in a .if if a instruction is - supported (From Lesha Bogdanow <boga@inbox.ru>). -

    -
  • -
  • -

    -Added checking of which mnemonic that work on the different AVRs - (From Lesha Bogdanow <boga@inbox.ru>). -

    -
  • -
  • -

    -Added constants DEVICE, FLASH_SIZE, RAM_SIZE and - EEPROM_SIZE (From Lesha Bogdanow <boga@inbox.ru>). -

    -
  • -
  • -

    -Added tiny devices (From Lesha Bogdanow <boga@inbox.ru>). -

    -
  • -
  • -

    -Changed error on constant out of range into a warning. -

    -
  • -
  • -

    -Added support for instructions: (E)LPM Rd,Z(+), SPM, ESPM, BREAK, - MOVW, MULS, MULSU, FMUL, FMULS, FMULSU -

    -
  • -
  • -

    -Added support for new devices: ATmega8, ATmega16, ATmega32, - ATmega128, ATmega162, ATmega163, ATmega323, AT94K -

    -
  • -
  • -

    -Added --devices switch to list all supported devices. -

    -
  • -
  • -

    -Fixed bug in map file name when the name had more than one . (dot) -

    -
  • -
  • -

    -Added option --includedirs to add additional include dirs in - search path. -

    -
  • -
  • -

    -Added support for creation of intel hex 32 files to be able to - address memory above 64KB. Uses 02 records for addresses up to 1MB - and 04 record for addresses above 1MB. -

    -
  • -
-
-

Version 0.6 (20000124)

-
-
-
-

Version 0.5 (19990331)

-
-
    -
  • -

    -Bugfix: a inline string copy did not terminate string. -

    -
  • -
  • -

    -Fixed bug causing --define symbol=value not to work. -

    -
  • -
  • -

    -Added output of memory usage. -

    -
  • -
  • -

    -Fixed bug when there was a { in a comment. -

    -
  • -
  • -

    -Fixed count for data segment. -

    -
  • -
  • -

    -Fix to make a forward referenced label in .db/.dw work. -

    -
  • -
  • -

    -Added ATmega161 and ATtiny15 in list. -

    -
  • -
  • -

    -rjmp and rcall now wraps around with 4k word devices. -

    -
  • -
  • -

    -Fixed bug when branching backwards with BRBS or BRBC -

    -
  • -
-
-

Version 0.4 (19990202)

-
-
    -
  • -

    -Added support for global keyword to use on labels in macros. -

    -
  • -
  • -

    -Fixed get_next_token to handle commas inside ' ' -

    -
  • -
  • -

    -Fixed bug when searching for correct macro_call, so recursive - and nested macros will work. -

    -
  • -
  • -

    -Now handles commas in strings. -

    -
  • -
  • -

    -Added fix to handle semi colon in a string. -

    -
  • -
  • -

    -Improved mnemonic parsing for ld and st -

    -
  • -
-
-
-

- -
-
- - diff -Nru avra-1.3.0/doc/downloads.html avra-1.4.2+dfsg/doc/downloads.html --- avra-1.3.0/doc/downloads.html 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/downloads.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - - - - - - - - - -Downloads - - -
-
AVRA
-
Assember for the Atmel AVR microcontroller family
-
- - - - - -
- - - - - - - -
- -
-
-
-

The latest release can always be downloaded from sourceforge.

- -
-
-
-

- -
-
- - diff -Nru avra-1.3.0/doc/downloads.txt avra-1.4.2+dfsg/doc/downloads.txt --- avra-1.3.0/doc/downloads.txt 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/downloads.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -Downloads -========= - -The latest release can always be downloaded from sourceforge. - -http://sourceforge.net/projects/avra/files Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/highlighter.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/highlighter.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/10.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/10.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/11.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/11.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/12.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/12.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/13.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/13.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/14.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/14.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/15.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/15.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/1.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/1.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/2.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/2.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/3.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/3.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/4.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/4.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/5.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/5.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/6.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/6.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/7.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/7.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/8.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/8.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/callouts/9.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/callouts/9.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/caution.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/caution.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/example.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/example.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/home.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/home.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/important.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/important.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/next.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/next.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/note.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/note.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/prev.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/prev.png differ diff -Nru avra-1.3.0/doc/images/icons/README avra-1.4.2+dfsg/doc/images/icons/README --- avra-1.3.0/doc/images/icons/README 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/images/icons/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook -icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency -from the Jimmac icons to get round MS IE and FOP PNG incompatibilies. - -Stuart Rackham Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/tip.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/tip.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/up.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/up.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/icons/warning.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/icons/warning.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/smallnew.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/smallnew.png differ Binary files /tmp/tmpvn5kyt4v/UOp4Pdj4jz/avra-1.3.0/doc/images/tiger.png and /tmp/tmpvn5kyt4v/XvXL7uD45d/avra-1.4.2+dfsg/doc/images/tiger.png differ diff -Nru avra-1.3.0/doc/index.html avra-1.4.2+dfsg/doc/index.html --- avra-1.3.0/doc/index.html 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - - - - - - - - - - - -AVRA Home Page - - -
-
AVRA
-
Assember for the Atmel AVR microcontroller family
-
- - - - - -
- - - - - - - -
- -
-
-
-
-
-
-
-

Introduction

-
-

AVRA is an assembler for Atmel AVR microcontrollers, and it is almost -compatible with Atmel’s own assembler AVRASM32. The programming -principles and conceptions are based on the ANSI programming language "C".

-

The initial version of AVRA was written by John Anders Haugum in 1999. He -released all versions until v0.7. All later versions were released by Tobias -Weber. And version 1.3.0 is released by Jerry Jacobs.

-
-
-

- -
-
- - diff -Nru avra-1.3.0/doc/index.txt avra-1.4.2+dfsg/doc/index.txt --- avra-1.3.0/doc/index.txt 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/index.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -AVRA Home Page -============== - -.{revdate}: AVRA {revnumber} Released -************************************************************************ -This release contains a few improvements, a couple of bug fixes and -documentation updates. - -Read the link:ChangeLog.html[ChangeLog] for a full list of all -additions, changes and bug fixes. Changes are documented in the -updated link:README.html[Readme]. See the -link:downloads.html[Downloads] page for sourcecode and binary releases. -************************************************************************ - -Introduction ------------- -AVRA is an assembler for Atmel AVR microcontrollers, and it is almost -compatible with Atmel's own assembler AVRASM32. The programming -principles and conceptions are based on the ANSI programming language "C". - -The initial version of AVRA was written by John Anders Haugum in 1999. He -released all versions until v0.7. All later versions were released by Tobias -Weber. And version 1.3.0 is released by Jerry Jacobs. diff -Nru avra-1.3.0/doc/layout1.conf avra-1.4.2+dfsg/doc/layout1.conf --- avra-1.3.0/doc/layout1.conf 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/layout1.conf 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -# -# AsciiDoc website. -# Three division table based layout (layout1). -# -# +-----------------------------------------------------+ -# | #layout-banner | -# +--------------+--------------------------------------+ -# | | | -# | | | -# | #layout-menu | #layout-content | -# | | | -# | | | -# | | | -# +--------------+--------------------------------------+ -# -# - The #layout-menu and #layout-content divisions are contained in a -# two cell table. -# I would be nice to use pure CSS for the layout but the table is better for -# this layout because: -# -# * The column widths automatically size to fit column width (specifically -# the #layout-menu) -# * The column heights automatically size to the tallest. -# -# - The #layout-content division is a container for AsciiDoc page documents. -# - Documents rendered in the #layout-content use the standard AsciiDoc -# xhtml11 backend stylesheets. - -[specialwords] -monospacedwords=(?u)\\?\basciidoc\(1\) (?u)\\?\ba2x\(1\) - -[header] - - - - - -ifdef::index-only[] - - -endif::index-only[] - -{doctype-manpage} - - - - -ifdef::asciimath[] - -endif::asciimath[] -ifdef::latexmath[] - -endif::latexmath[] -{doctitle} - - -
-
AVRA
-
Assember for the Atmel AVR microcontroller family
-
- - - - - -
- - - - - - - -
-# Article, book header. -ifndef::doctype-manpage[] - -endif::doctype-manpage[] -# Man page header. -ifdef::doctype-manpage[] - -endif::doctype-manpage[] -
- -[footer] -
-{disable-javascript%

} - -
-
- - diff -Nru avra-1.3.0/doc/layout1.css avra-1.4.2+dfsg/doc/layout1.css --- avra-1.3.0/doc/layout1.css 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/layout1.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -body { - background-color: white; - margin: 1%; -} - -h1 { - margin-top: 0.5em; -} - -#layout-banner { - background-color: #73a0c5; - color: white; - font-family: sans-serif; - text-align: left; - padding: 0.8em 20px; -} - -#layout-title { - font-family: monospace; - font-size: 3.5em; - font-weight: bold; - letter-spacing: 0.2em; - margin: 0; -} - -#layout-description { - font-size: 1.2em; - letter-spacing: 0.1em; -} - -#layout-menu { - background-color: #f4f4f4; - border-right: 3px solid #eeeeee; - padding-top: 0.8em; - padding-left: 20px; - padding-right: 0.8em; - font-size: 1.1em; - font-family: sans-serif; - font-weight: bold; -} -#layout-menu a { - line-height: 2em; - margin-left: 0.5em; -} -#layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover { - color: #527bbd; - text-decoration: none; -} -#layout-menu a:hover { - color: navy; - text-decoration: none; -} -#layout-menu #page-source { - border-top: 2px solid silver; - margin-top: 0.2em; -} - -#layout-content { - margin-left: 1.0em; -} - -@media print { - #layout-banner { display: none; } - #layout-menu { display: none; } -} diff -Nru avra-1.3.0/doc/Makefile avra-1.4.2+dfsg/doc/Makefile --- avra-1.3.0/doc/Makefile 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -### -# Sourceforge helper Makefile -### -USER=jerryjacobs -HOSTNAME=shell.sourceforge.net -PROJECT=avra -HTDOCS=/home/groups/a/av/avra/htdocs - -all: help - -upload: htdocs_scp htdocs_chmod - -### -# Help message -### -help: - @echo "No command specified! Available commands:" - @echo - @echo "Current settings" - @echo "----------------" - @echo " User: ${USER}" - @echo " Hostname: ${HOSTNAME}" - @echo " Project: ${PROJECT}" - @echo " Remote htdoc: ${HTDOCS}" - @echo - @echo "Shell commands" - @echo "--------------" - @echo " * shell, open a shell" - @echo " * shell_create, create a shell" - @echo - @echo "htdocs commands" - @echo "---------------" - @echo " * htdocs_scp, copy all files from current dir to remote htdocs" - @echo " * htdocs_rm, remove all files from remote htdocs" - -### -# Shell -### -shell: - ssh ${USER},${PROJECT}@${HOSTNAME} - -shell_create: - ssh ${USER},${PROJECT}@${HOSTNAME} create - -### -# htdocs -### -htdocs_scp: - scp -r * ${USER}@${HOSTNAME}:${HTDOCS} - -htdocs_chmod: - ssh ${USER}@${HOSTNAME} chmod -Rv ug+rw ${HTDOCS}/* - -htdocs_rm: - ssh ${USER}@${HOSTNAME} rm -Rv ${HTDOCS}/* diff -Nru avra-1.3.0/doc/README.html avra-1.4.2+dfsg/doc/README.html --- avra-1.3.0/doc/README.html 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/README.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,759 +0,0 @@ - - - - - - - - - - -README - - -
-
AVRA
-
Assember for the Atmel AVR microcontroller family
-
- - - - - -
- - - - - - - -
- -
-

General and licensing information

-
-

AVRA v1.3.0 - Assember for the Atmel AVR microcontroller family

-

Licensing information

-

This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. Please read below for for information.

-

Disclaimer

-

This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details.

-

GNU General Public License

-

You should have received a copy of the GNU General Public License -along with this program; see the file "COPYING". If not, visit -http://www.gnu.org or write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. You can -also contact the authors of AVRA to receive a copy of the COPYING file.

-
-

Atmel, AVR, AVR Studio, Intel, Windows are registered enterprises, brands -and registered trademarks. The mentioned companies have no relation to -AVRA and are therefore not responslible for any problems that occur when -using AVRA. Many thanks for your products, support and efforts.

-
-

Introducion

-
-

AVRA is an assembler for Atmel AVR microcontrollers, and it is almost -compatible with Atmel’s own assembler AVRASM32. The programming -principles and conceptions are based on the ANSI programming language "C".

-

The initial version of AVRA was written by John Anders Haugum. He released -all versions until v0.7. All later versions were released by Tobias Weber.

-

Differences between AVRA and AVRASM32

-

There are some differences between the original Atmel assembler AVRASM32 and AVRA. Basically AVRA is designed to replace AVRASM32 without special changes in your current Atmel AVR Studio enviroment. -Command line options have been adapted as far as it was possible until now. Jumping to fault containing line directly by double-clicking on the error message in the output window does work as with AVRASM32.

-

The differences in detail

-
    -
  • -

    -Support for some extra preprocessor directives. -

    -
    -
    -
    .define, .undef, .ifdef, .ifndef, .if, .else, .endif, .elif, .elseif, .warning
    -
    -
  • -
  • -

    -Not all command line options are supported. - Specifying an eeprom file (-e) is not supported. All eeprom data is - put out into a file called program.eep.hex and always Intel hex - format. Other hex file formats than Intel are currently not supported. -

    -
  • -
  • -

    -Forward references not supported for .ifdef and .ifndef directives. - This makes sure, that directives like .ifdef and .undef are working - properly. If you are familiar with the C programming language, you - should get easily into AVRA. See chapter "Programming techniques" for - more information about how to write proper code. -

    -
  • -
  • -

    -Enhanced macro support - AVRA has some new features for writing flexible macros. This should - increase the ability to reuse code e.g. build your own library. -

    -
  • -
  • -

    -Debugging support - AVRA creates a coff file everytime the assembly was sucessful. This - file allows AVR Studio or any coff compatible debugger to simulate - or emulate the program. -

    -
  • -
  • -

    -Meta tags for assembly time - This helps you tracking versions of your software and can also be - used to generate customer specific serial numbers. -

    -
  • -
-

Compatibility

-

Since AVRA is written in ANSI C, it should be possible to compile it on -most system platforms. If you have problems compiling AVRA, please leave -a message on the sourceforge message board or send a mail to the -authors of AVRA.

-
-

Installation

-
-

To install avra you should copy the avra-executable to an apropriate -location. To compile you should rename the appropriate makefile, and -perform a make (use smake for Amiga SAS/C, and nmake for Mickeysoft -visual c++).

-

Linux

-

To compile avra you need gcc and the automake utilities. These will create -a ./configure script that evaluates your system enviroment. To get the -AVRA executable, you have to issue the following commands:

-

aclocal -autoconf -automake -a -./configure -make && make install

-

AmigaOS

-

avra can be copied any apropriate directory. If you are using the source -distribution a make install will do the same.

-

Microsoft Windows

-

If you received the Windows binary package, look into the \bin -directory where you can find avra.exe. This should be copied to any -apropriate location. You can also overwrite AVRASM32.EXE in your -Atmel AVR Studio. If you want to compile it yourself you could download then -OpenWatcom C/C++ Toolchain for windows and create a new project and add the C -and H files to it and compile.

-

Apple OS X

-

If you recieved the Apple OS X binary package, look into the bin directory this -file is compiled universal and should run on intel 32 and 64 bit and powerpc. If -you want to compile it yourself go to the src directory and invoke make -f -makefiles/Makefiles.osx and then the executable should be created.

-
-

Synopsis

-
-

Command line usage

-
-
-
usage: AVRA [-f][O|M|I|G] output file type
-         [-o <filename>] output file name
-         [-l <filename>] generate list file
-         [-m <mapfile>] generate map file
-         [--define <symbol>[=<value>]]  [--includedir <dir>] [--listmac]
-         [--max_errors <number>] [--devices] [--version]
-         [-h] [--help] general help
-         [-W NoRegDef] supress register redefinition warnings
-         <file to assemble>
-
-

Parameter list

-
-
-
--listfile    -l : Create list file
---mapfile     -m : Create map file
---define      -D : Define symbol.
---includedir  -I : Additional include dirs.
---listmac        : List macro expansion in listfile.
---max_errors     : Maximum number of errors before exit
-                   (default: 10)
---devices        : List out supported devices.
---version        : Version information.
---help, -h       : This help text.
-
-

Warning supression

-

Since avra 1.1 there is a possibility to supress certain warnings. -Currently only register reassignment warnings can be supressed.

-

Example: avra -W NoRegDef

-
-

Programming techniques

-
-

Using directives

-

AVRA offers a number of directives that are not part of Atmel’s -assembler. These directives should help you creating versatile code that -can be designed more modular.

-

Directive .define

-

To define a constant, use ".define". This does the same thing as ".equ", -it is just a little more C style. Keep in mind that AVRA is not case -sensitive. Do not mix ".def" and ".define", because ".def" is used to -assign registers only. This is due to backward compatibility to Atmel’s -AVRASM32. Here is an example on how .define can be used.

-
-
-
.define network 1
-
-

Now "network" is set to the value 1. You may want to assemble a specific -part of your code depeding on a define or switch setting. You can test -your defined word on existence (.ifdef and .ifndef) as well as on the -value it represents. The following code shows a way to prevent error -messages due to testing undefined constants. Conditional directives must -always end with an .endif directive.

-
-
-
.ifndef network
-.define network 0
-.endif
-
-

Directive .if and .else

-

The three lines in the last example set the default value of "network". -In the next example, you see how we can use default values. If a constant -has not defined previously, it is set to zero. Now you can test wether -e.g. network support is included into the assemby process.

-
-
-
.if network = 1
-.include "include\tcpip.asm"
-.else
-.include "include\dummynet.asm"
-.endif
-
-

In the second part of the above listing you see the use of .else, which -defines the part of the condition that is being executed if the equation -of the preceding .if statement is not equal. You can also use the else -statement to test another equasion. For that purpose use .elif, which -means "else if". Always close this conditional part with ".endif"

-

Directive .error

-

This directive can be used to throw errors if a part in the code has reached -that should not be reached. The following example shows how we can stop -the assembly process if a particular value has not been previously set.

-
-
-
.ifndef network
-.error "network is not configured!" ;the assembler stops here
-
-

Directive .nolist and .list

-

The ouput to the list file can be paused by this two directives. After -avra discovers a .nolist while assembling, it stops output to the list file. -After a .list directive is detected, it continues the normal list file output.

-

Directive .includepath

-

By default, any file that is included from within the source file must -either be a single filename or a complete absolute path. With the directive -.includepath you can set an additional include path . Furthermore you can -set as many include paths as you want. Be sure not no use same filename -in separate includes, because then it is no longer clear which one avra -should take.

-
-

Using include files

-
-

To avoid multiple inclusions of include files, you may use some pre- -processor directives. See example file stack.asm that is being included -into the main programm file as well as in other include files.

-
-
-
.ifndef _STACK_ASM_
-.define _STACK_ASM_
-
-
-
-
.include "include/config.inc"
-
-
-
-
; *** stack macro ***
-
-
-
-
.dseg
-m_stack:    .byte __stack_size__
-.cseg
-
-
-
-
.macro      stack_setup
-    load    [v:w,m_stack + __stack_size__]
-    outp    [SPREG,v:w]
-.endm
-
-
-
-
.endif ; avoid multiple inclusion of stack.asm
-
-

Using build date meta tags

-

If you like to implement compiler build time and date into your -program, you can make use of some sepcial tags that avra supports.

-
-
-
%MINUTE%  is being replaced by the current minute (00-59)
-%HOUR%    is being replaced by the current hour (00-23)
-%DAY%     is being replaced by the current day of month (01-31)
-%MONTH%   is being replaced by the current month (01-12)
-%YEAR%    is being replaced by the current year (2004-9999)
-
-
-
-
buildtime: .db "Release date %DAY%.%MONTH%.%YEAR% %HOUR%:%MINUTE%"
-
-

This line will then assembled by avra into:

-
-
-
buildtime: .db "Release date 10.05.2004 19:54"
-
-

You may also create a self defined serial number with meta tags:

-
-
-
.define serialnumber %DAY% + %MONTH%*31 + (%YEAR% - 2000) *31*12
-
-

The %TAG% is translated before any other parsing happens. The real -output can be found in the list file.

-
-

Macro features

-
-

Sometimes you have to work with 16 bit or greater variables stored -in 8 bit registers. The enhanced macro support allows you to write short -and flexible macros that simplify access to big variables. The extended -mode is active, as soon as you use parenthesis like this "[ ]" to wrap -macro parameters.

-

Auto type conversion for macros

-

Values representing more than 8 Bits are usualy kept in a set of byte -wide registers. To simplify 16 Bit or greater operations, I added a new -language definitions. Words can be written as r16:r17, whereas register -r16 contains the higher part and register r17 the lower part of this -16 Bit value.

-

Macro data types

-

There are 3 data types that can be used. They will be added as character -separated by one underline character.

-
-
-
immediate values  _i
-registers         _8,_16,_24,_32,_40,_48,_56,_64
-void parameter    _v
-
-

16 Bit Source and Destionation registers dst and src

-
-
-
src = YH:YL
-dst = ZH:ZL
-
-

Within the parenthesis, the two words src and dst are interpreted as YH:YL -and ZH:ZL. Normal code outside of the macro parameter parenthesis can -still make use of these special key words "src" and "dst".

-

Examples for automatic type conversion

-

To simplify the parameters in the demonstration below, we need to -redefine some registers.

-
-
-
.def    a = r16   ; general purpose registers
-.def    b = r17
-.def    c = r18
-.def    d = r19
-
-
-
-
.def    w = r20   ; working register
-.def    v = r21   ; working register
-
-

If we substract 16 Bit values stored in a, higher byte and b, lower byte -with that in c:d, we usually have to use the following command sequence:

-
-
-
sub     b,d
-sbc     a,c
-
-

Now we can do the following steps to simplify 16 or more Bit manipulations

-
-
-
.macro  subs
-.message "no parameters specified"
-.endm
-
-
-
-
.macro  subs_16_16
-sub     @1,@3
-sbc     @0,@2
-.endm
-
-
-
-
.macro  subs_16_8
-sub     @1,@2
-sbci    @0,0
-.endm
-
-
-
-
;now we can write a 16 Bit subraction as:
-
-
-
-
subs    [a:b,c:d]
-
-
-
-
;or for calculating 16 minus 8 Bit
-
-
-
-
subs    [a:b,c]
-
-

Overloading macros

-

Like in you are used to C functions, you can write macros for different -parameter lists. If you would like to have a versatile macro, you can -specify a unique macro for each parameter situation. See the next sample.

-
-
-
.macro  load
-
-
-
-
; this message is shown if you use the macro within your code
-; specifying no parameters. If your macro allows the case where
-; no parameters are given, exchange .message with your code.
-
-
-
-
.message "no parameters specified"
-.endm
-
-
-
-
; Here we define the macro "load" for the case it is being used
-; with two registers as first parameter and a immediate (constant)
-; value as second parameter.
-
-
-
-
.macro  load_16_i
-ldi     @0,high(@2)
-ldi     @1,low(@2)
-.endm
-
-
-
-
; the same case, but now with a 32 bit register value as first
-; parameter
-
-
-
-
.macro  load_32_i
-ldi     @0,BYTE4(@4)
-ldi     @1,BYTE3(@4)
-ldi     @2,high(@4)
-ldi     @3,low(@4)
-.endm
-
-
-
-
; Now let's see how these macros are being used in the code
-
-
-
-
load    [a:b,15]     ;uses macro load_16_i to load immediate
-
-
-
-
load    [a:b:c:d,15] ;uses macro load_32_i to load immediate
-
-

More examples

-
-
-
.dseg
-counter  .byte 2
-.cseg
-
-
-
-
.macro   poke
-.message "no parameters"
-.endm
-
-
-
-
.macro   poke_i_16_i
-ldi      @1,high(@3)
-sts      @0+0,@1
-ldi      @2,low(@3)
-sts      @0+1,@2
-.endm
-
-
-
-
.macro   poke_i_i
-ldi      w,@1
-sts      @0+0,w
-.endm
-
-
-
-
.macro   poke_i_v_i
-ldi      w,high(@3)
-sts      @0+0,w
-ldi      w,low(@3)
-sts      @0+1,w
-.endm
-
-
-
-
.macro   poke_i_v_v_v_i
-ldi      w,high(@3)
-sts      @0+0,w
-ldi      w,low(@3)
-sts      @0+1,w
-ldi      w,BYTE3(@3)
-sts      @0+2,w
-ldi      w,BYTE4(@3)
-sts      @0+3,w
-.endm
-
-
-
-
; this writes '9999' into the memory at 'counter'
-; uses only the working register for transfering the values.
-
-
-
-
poke     [counter,w:w,9999]
-
-
-
-
; works same as above, but the transferred value '9999' is also
-; kept in the pair of register a:b
-
-
-
-
poke     [counter,a:b,9999]
-
-
-
-
; in my design 'w' is always working reg. which implies that
-; it cannot be used for normal variables. The following example
-; uses poke_i_i because the parameter contains two immediate values.
-
-
-
-
poke     [counter,9999] ;uses poke_i_i
-
-
-
-
; to be able to choose between a 8,16 or 32 Bit operation, you just
-; add a void parameter.
-
-
-
-
poke     [counter,,9999] ;uses poke_i_v_i
-
-
-
-
; and the same for 32 Bit pokes
-
-
-
-
poke     [counter,,,,9999] ;uses poke_i_v_v_v_i
-
-

Loops within macros

-

One problem you may have experienced, is that labels defined within macros -are defined twice if you call the macro for example two times. Now you can -use labels for macro loops. Loops within macros must end with _%. the -"%" symbol is replaced by a running number.

-

Loop example

-
-
-
; Definition of the macro
-
-
-
-
.macro   write_8_8
-write_%:
-     st      Z+,@0
-     dec     @1
-     brne    write_%
-.endm
-
-
-
-
; Use in user code
-
-
-
-
write   [a,b]
-write   [c,d]
-
-
-
-
; After assembling this code, the result looks like this
-
-
-
-
write_1:
-     st          Z+,a
-     dec         b
-     brne        write_1
-write_2:
-     st          Z+,c
-     dec         d
-     brne        write_2
-
-
-

Warnings and Errors

-
-

Some errors and warnings may confuse you a little bit so we will try to -clear some frequently asked questions about such cases.

-

Constant out of range

-

This warning occurs if a value exceeds the byte or word value of a assignment. -Read the comment posted by Jim Galbraith:

-

The expression (~0x80) is a Bitwise Not operation. This -operator returns the input expression with all its bits -inverted. If 0x80 represents -128, then 0x7f, or +127 -should be ok. If this is considered as a 32-bit expression -(AVRA internal representation), then it appears to be more -like oxffffffff-0x80 or 0xffffffff0x80. The result would then -be 0xffffff7f. The assembler would then have to be told or it -would have to decide, based on context, how much -significance to assign to the higher bits. I have also -encountered such conditions with various assemblers, -including AVRA. To make sure the assembler does what I -really want, I use a construct like 0xff-0x80 or 0xff0x80. -This way the bit significance cannot extend beyond bit-7 and -there cannot be any misunderstanding.

-

Can’t use .DB directive in data segment

-
DB and .DW is only used to assign constant data in eeprom or code space.

The reason why using it within data segment is forbidden is, that you -cannot set ram content at assembly time. The values must be programmed into -ROM area and at boot read from ROM into RAM. This is up to the user code. -You can only allocate memory for your variables using labels and the .byte -directive.

-
-
-
.dseg
-my_string: .byte 15
-
-

BYTE directive

-
BYTE directive can only be used in data segment (.DSEG)

This directive cannot be used in code or eeprom region because this only -allocates memory without assgning distinct values to it. Please use .db -or .dw instead.

-

Internal assembler error

-

If you get an "Internal assembler error" please contact the project maintainer -by sending him a code example and a description of your working enviroment.

-
-

AVRA internals

-
-

This section provides thoughts of the avra internal design. I have to admit -that the code of avra is anything else than clean and optimized. To increase -the code readability I will try to give you some standards that should improve -quality. The following standards are similar to what GNU proposes.

-

Coding standards

-

Tab space is always 2 spaces. The Tab character (ascii 9) is not used. -if,while,for are always opened on the same line but closed on the next line. -The closing bracket is in the same column as the first letter of the loop -directive.

-
-
-
Example:
-
-
-
-
    while(i > 0) {
-     do_something();
-    }
-
-
-

Credits

-
-

We would like to thank the following people for giving contributions, -patches and bug reports, as well as suggestions and new ideas.

-
-
-
      Jon Anders Haugum (project founder)
-      Burkhard Arenfeld (release 1.2.0)
-      Tobias Weber (old maintainer)
-      Jerry Jacobs (release 1.3.0)
-      Bernt Hembre
-      Nils Strøm
-      Roberto Biancardi
-      Qwerty Jones
-      Ben Hitchcock (Maker of the mac port)
-      Daniel Drotos
-      Laurence Boyd II
-      Varuzhan Danielyan
-      Laurence Turner
-      Eugene R. O'Bryan
-      Dmitry Dicky
-      Bob Harris (Maker of coff support)
-      Tobias Weber (enhanced macro support)
-      Lesha Bogdanow
-      Jim Galbraith
-      Mark Brinicombe
-      Igor Nikolayenko
-      Peter Hettkamp
-      Herb Poppe
-      David Burke
-      Alexey Pavluchenko
-      Alan Probandt
-      Mariusz Matuszek
-      Arne Rossius
-      Marti Tichacek
-      Patrick Parity
-      Johannes Overmann
-      Roland Riegel
-      Peter Katzmann
-      Donald D. Davis
-
-

And all the anonymous people who submitted patches!

-

Thank you for your work and support.

-
-

References

-
-
-
-
http://www.suprafluid.com/avra
-http://www.avrfreaks.de
-http://www.atmel.com
-
-
-
-

- -
-
- - diff -Nru avra-1.3.0/doc/README.txt avra-1.4.2+dfsg/doc/README.txt --- avra-1.3.0/doc/README.txt 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/README.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,679 +0,0 @@ -README -====== - -General and licensing information ---------------------------------- -AVRA v1.3.0 - Assember for the Atmel AVR microcontroller family - -Licensing information -~~~~~~~~~~~~~~~~~~~~~ - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. Please read below for for information. - -Disclaimer -~~~~~~~~~~ - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -GNU General Public License -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You should have received a copy of the GNU General Public License -along with this program; see the file "COPYING". If not, visit -http://www.gnu.org or write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. You can -also contact the authors of AVRA to receive a copy of the COPYING file. - -Trademarks and copyright -~~~~~~~~~~~~~~~~~~~~~~~~ - -Atmel, AVR, AVR Studio, Intel, Windows are registered enterprises, brands -and registered trademarks. The mentioned companies have no relation to -AVRA and are therefore not responslible for any problems that occur when -using AVRA. Many thanks for your products, support and efforts. - - -Introducion ------------ - -AVRA is an assembler for Atmel AVR microcontrollers, and it is almost -compatible with Atmel's own assembler AVRASM32. The programming -principles and conceptions are based on the ANSI programming language "C". - -The initial version of AVRA was written by John Anders Haugum. He released -all versions until v0.7. All later versions were released by Tobias Weber. - - -Differences between AVRA and AVRASM32 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are some differences between the original Atmel assembler AVRASM32 and AVRA. Basically AVRA is designed to replace AVRASM32 without special changes in your current Atmel AVR Studio enviroment. -Command line options have been adapted as far as it was possible until now. Jumping to fault containing line directly by double-clicking on the error message in the output window does work as with AVRASM32. - -The differences in detail -~~~~~~~~~~~~~~~~~~~~~~~~~ - - - Support for some extra preprocessor directives. - - .define, .undef, .ifdef, .ifndef, .if, .else, .endif, .elif, .elseif, .warning - - - Not all command line options are supported. - Specifying an eeprom file (-e) is not supported. All eeprom data is - put out into a file called program.eep.hex and always Intel hex - format. Other hex file formats than Intel are currently not supported. - - - Forward references not supported for .ifdef and .ifndef directives. - This makes sure, that directives like .ifdef and .undef are working - properly. If you are familiar with the C programming language, you - should get easily into AVRA. See chapter "Programming techniques" for - more information about how to write proper code. - - - Enhanced macro support - AVRA has some new features for writing flexible macros. This should - increase the ability to reuse code e.g. build your own library. - - - Debugging support - AVRA creates a coff file everytime the assembly was sucessful. This - file allows AVR Studio or any coff compatible debugger to simulate - or emulate the program. - - - Meta tags for assembly time - This helps you tracking versions of your software and can also be - used to generate customer specific serial numbers. - - -Compatibility -~~~~~~~~~~~~~ - -Since AVRA is written in ANSI C, it should be possible to compile it on -most system platforms. If you have problems compiling AVRA, please leave -a message on the sourceforge message board or send a mail to the -authors of AVRA. - - -Installation ------------- - -To install avra you should copy the avra-executable to an apropriate -location. To compile you should rename the appropriate makefile, and -perform a make (use smake for Amiga SAS/C, and nmake for Mickeysoft -visual c++). - - -Linux -~~~~~ - -To compile avra you need gcc and the automake utilities. These will create -a ./configure script that evaluates your system enviroment. To get the -AVRA executable, you have to issue the following commands: - -aclocal -autoconf -automake -a -./configure -make && make install - -AmigaOS -~~~~~~~ - -avra can be copied any apropriate directory. If you are using the source -distribution a 'make install' will do the same. - - -Microsoft Windows -~~~~~~~~~~~~~~~~~ - -If you received the Windows binary package, look into the \bin -directory where you can find avra.exe. This should be copied to any -apropriate location. You can also overwrite AVRASM32.EXE in your -Atmel AVR Studio. If you want to compile it yourself you could download then -OpenWatcom C/C++ Toolchain for windows and create a new project and add the C -and H files to it and compile. - -Apple OS X -~~~~~~~~~~ - -If you recieved the Apple OS X binary package, look into the bin directory this -file is compiled universal and should run on intel 32 and 64 bit and powerpc. If -you want to compile it yourself go to the src directory and invoke `make -f -makefiles/Makefiles.osx` and then the executable should be created. - - -Synopsis --------- - -Command line usage -~~~~~~~~~~~~~~~~~~ - - usage: AVRA [-f][O|M|I|G] output file type - [-o ] output file name - [-l ] generate list file - [-m ] generate map file - [--define [=]] [--includedir ] [--listmac] - [--max_errors ] [--devices] [--version] - [-h] [--help] general help - [-W NoRegDef] supress register redefinition warnings - - - -Parameter list -~~~~~~~~~~~~~~ - - --listfile -l : Create list file - --mapfile -m : Create map file - --define -D : Define symbol. - --includedir -I : Additional include dirs. - --listmac : List macro expansion in listfile. - --max_errors : Maximum number of errors before exit - (default: 10) - --devices : List out supported devices. - --version : Version information. - --help, -h : This help text. - - -Warning supression -~~~~~~~~~~~~~~~~~~ - -Since avra 1.1 there is a possibility to supress certain warnings. -Currently only register reassignment warnings can be supressed. - -Example: avra -W NoRegDef - - -Programming techniques ----------------------- - - -Using directives -~~~~~~~~~~~~~~~~ - -AVRA offers a number of directives that are not part of Atmel's -assembler. These directives should help you creating versatile code that -can be designed more modular. - -Directive .define -^^^^^^^^^^^^^^^^^ - -To define a constant, use ".define". This does the same thing as ".equ", -it is just a little more C style. Keep in mind that AVRA is not case -sensitive. Do not mix ".def" and ".define", because ".def" is used to -assign registers only. This is due to backward compatibility to Atmel's -AVRASM32. Here is an example on how .define can be used. - - .define network 1 - -Now "network" is set to the value 1. You may want to assemble a specific -part of your code depeding on a define or switch setting. You can test -your defined word on existence (.ifdef and .ifndef) as well as on the -value it represents. The following code shows a way to prevent error -messages due to testing undefined constants. Conditional directives must -always end with an .endif directive. - - .ifndef network - .define network 0 - .endif - -Directive .if and .else -^^^^^^^^^^^^^^^^^^^^^^^ - -The three lines in the last example set the default value of "network". -In the next example, you see how we can use default values. If a constant -has not defined previously, it is set to zero. Now you can test wether -e.g. network support is included into the assemby process. - - .if network = 1 - .include "include\tcpip.asm" - .else - .include "include\dummynet.asm" - .endif - -In the second part of the above listing you see the use of .else, which -defines the part of the condition that is being executed if the equation -of the preceding .if statement is not equal. You can also use the else -statement to test another equasion. For that purpose use .elif, which -means "else if". Always close this conditional part with ".endif" - -Directive .error -^^^^^^^^^^^^^^^^ - -This directive can be used to throw errors if a part in the code has reached -that should not be reached. The following example shows how we can stop -the assembly process if a particular value has not been previously set. - - .ifndef network - .error "network is not configured!" ;the assembler stops here - -Directive .nolist and .list -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The ouput to the list file can be paused by this two directives. After -avra discovers a .nolist while assembling, it stops output to the list file. -After a .list directive is detected, it continues the normal list file output. - -Directive .includepath -^^^^^^^^^^^^^^^^^^^^^^ - -By default, any file that is included from within the source file must -either be a single filename or a complete absolute path. With the directive -.includepath you can set an additional include path . Furthermore you can -set as many include paths as you want. Be sure not no use same filename -in separate includes, because then it is no longer clear which one avra -should take. - -Using include files -------------------- - -To avoid multiple inclusions of include files, you may use some pre- -processor directives. See example file stack.asm that is being included -into the main programm file as well as in other include files. - - .ifndef _STACK_ASM_ - .define _STACK_ASM_ - - .include "include/config.inc" - - ; *** stack macro *** - - .dseg - m_stack: .byte __stack_size__ - .cseg - - .macro stack_setup - load [v:w,m_stack + __stack_size__] - outp [SPREG,v:w] - .endm - - .endif ; avoid multiple inclusion of stack.asm - - -Using build date meta tags -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you like to implement compiler build time and date into your -program, you can make use of some sepcial tags that avra supports. - - %MINUTE% is being replaced by the current minute (00-59) - %HOUR% is being replaced by the current hour (00-23) - %DAY% is being replaced by the current day of month (01-31) - %MONTH% is being replaced by the current month (01-12) - %YEAR% is being replaced by the current year (2004-9999) - - buildtime: .db "Release date %DAY%.%MONTH%.%YEAR% %HOUR%:%MINUTE%" - -This line will then assembled by avra into: - - buildtime: .db "Release date 10.05.2004 19:54" - -You may also create a self defined serial number with meta tags: - - .define serialnumber %DAY% + %MONTH%*31 + (%YEAR% - 2000) *31*12 - -The %TAG% is translated before any other parsing happens. The real -output can be found in the list file. - -Macro features --------------- - -Sometimes you have to work with 16 bit or greater variables stored -in 8 bit registers. The enhanced macro support allows you to write short -and flexible macros that simplify access to big variables. The extended -mode is active, as soon as you use parenthesis like this "[ ]" to wrap -macro parameters. - -Auto type conversion for macros -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Values representing more than 8 Bits are usualy kept in a set of byte -wide registers. To simplify 16 Bit or greater operations, I added a new -language definitions. Words can be written as r16:r17, whereas register -r16 contains the higher part and register r17 the lower part of this -16 Bit value. - -Macro data types -^^^^^^^^^^^^^^^^ - -There are 3 data types that can be used. They will be added as character -separated by one underline character. - - immediate values _i - registers _8,_16,_24,_32,_40,_48,_56,_64 - void parameter _v - -16 Bit Source and Destionation registers 'dst' and 'src' - - src = YH:YL - dst = ZH:ZL - -Within the parenthesis, the two words src and dst are interpreted as YH:YL -and ZH:ZL. Normal code outside of the macro parameter parenthesis can -still make use of these special key words "src" and "dst". - -Examples for automatic type conversion -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To simplify the parameters in the demonstration below, we need to -redefine some registers. - - .def a = r16 ; general purpose registers - .def b = r17 - .def c = r18 - .def d = r19 - - .def w = r20 ; working register - .def v = r21 ; working register - -If we substract 16 Bit values stored in a, higher byte and b, lower byte -with that in c:d, we usually have to use the following command sequence: - - sub b,d - sbc a,c - -Now we can do the following steps to simplify 16 or more Bit manipulations - - .macro subs - .message "no parameters specified" - .endm - - .macro subs_16_16 - sub @1,@3 - sbc @0,@2 - .endm - - .macro subs_16_8 - sub @1,@2 - sbci @0,0 - .endm - - ;now we can write a 16 Bit subraction as: - - subs [a:b,c:d] - - ;or for calculating 16 minus 8 Bit - - subs [a:b,c] - - -Overloading macros -~~~~~~~~~~~~~~~~~~ - -Like in you are used to C functions, you can write macros for different -parameter lists. If you would like to have a versatile macro, you can -specify a unique macro for each parameter situation. See the next sample. - - .macro load - - ; this message is shown if you use the macro within your code - ; specifying no parameters. If your macro allows the case where - ; no parameters are given, exchange .message with your code. - - .message "no parameters specified" - .endm - - ; Here we define the macro "load" for the case it is being used - ; with two registers as first parameter and a immediate (constant) - ; value as second parameter. - - .macro load_16_i - ldi @0,high(@2) - ldi @1,low(@2) - .endm - - ; the same case, but now with a 32 bit register value as first - ; parameter - - .macro load_32_i - ldi @0,BYTE4(@4) - ldi @1,BYTE3(@4) - ldi @2,high(@4) - ldi @3,low(@4) - .endm - - ; Now let's see how these macros are being used in the code - - load [a:b,15] ;uses macro load_16_i to load immediate - - load [a:b:c:d,15] ;uses macro load_32_i to load immediate - - -More examples -~~~~~~~~~~~~~ - - .dseg - counter .byte 2 - .cseg - - .macro poke - .message "no parameters" - .endm - - .macro poke_i_16_i - ldi @1,high(@3) - sts @0+0,@1 - ldi @2,low(@3) - sts @0+1,@2 - .endm - - .macro poke_i_i - ldi w,@1 - sts @0+0,w - .endm - - .macro poke_i_v_i - ldi w,high(@3) - sts @0+0,w - ldi w,low(@3) - sts @0+1,w - .endm - - .macro poke_i_v_v_v_i - ldi w,high(@3) - sts @0+0,w - ldi w,low(@3) - sts @0+1,w - ldi w,BYTE3(@3) - sts @0+2,w - ldi w,BYTE4(@3) - sts @0+3,w - .endm - - - ; this writes '9999' into the memory at 'counter' - ; uses only the working register for transfering the values. - - poke [counter,w:w,9999] - - ; works same as above, but the transferred value '9999' is also - ; kept in the pair of register a:b - - poke [counter,a:b,9999] - - ; in my design 'w' is always working reg. which implies that - ; it cannot be used for normal variables. The following example - ; uses poke_i_i because the parameter contains two immediate values. - - poke [counter,9999] ;uses poke_i_i - - ; to be able to choose between a 8,16 or 32 Bit operation, you just - ; add a void parameter. - - poke [counter,,9999] ;uses poke_i_v_i - - ; and the same for 32 Bit pokes - - poke [counter,,,,9999] ;uses poke_i_v_v_v_i - -Loops within macros -~~~~~~~~~~~~~~~~~~~ - -One problem you may have experienced, is that labels defined within macros -are defined twice if you call the macro for example two times. Now you can -use labels for macro loops. Loops within macros must end with '_%'. the -"%" symbol is replaced by a running number. - -Loop example -^^^^^^^^^^^^ - - ; Definition of the macro - - .macro write_8_8 - write_%: - st Z+,@0 - dec @1 - brne write_% - .endm - - ; Use in user code - - write [a,b] - write [c,d] - - ; After assembling this code, the result looks like this - - write_1: - st Z+,a - dec b - brne write_1 - write_2: - st Z+,c - dec d - brne write_2 - -Warnings and Errors -------------------- - -Some errors and warnings may confuse you a little bit so we will try to -clear some frequently asked questions about such cases. - -Constant out of range -~~~~~~~~~~~~~~~~~~~~~ - -This warning occurs if a value exceeds the byte or word value of a assignment. -Read the comment posted by Jim Galbraith: - -The expression (~0x80) is a Bitwise Not operation. This -operator returns the input expression with all its bits -inverted. If 0x80 represents -128, then 0x7f, or +127 -should be ok. If this is considered as a 32-bit expression -(AVRA internal representation), then it appears to be more -like oxffffffff-0x80 or 0xffffffff^0x80. The result would then -be 0xffffff7f. The assembler would then have to be told or it -would have to decide, based on context, how much -significance to assign to the higher bits. I have also -encountered such conditions with various assemblers, -including AVRA. To make sure the assembler does what I -really want, I use a construct like 0xff-0x80 or 0xff^0x80. -This way the bit significance cannot extend beyond bit-7 and -there cannot be any misunderstanding. - -Can't use .DB directive in data segment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.DB and .DW is only used to assign constant data in eeprom or code space. -The reason why using it within data segment is forbidden is, that you -cannot set ram content at assembly time. The values must be programmed into -ROM area and at boot read from ROM into RAM. This is up to the user code. -You can only allocate memory for your variables using labels and the .byte -directive. - - .dseg - my_string: .byte 15 - -BYTE directive -~~~~~~~~~~~~~~ - -.BYTE directive can only be used in data segment (.DSEG) - -This directive cannot be used in code or eeprom region because this only -allocates memory without assgning distinct values to it. Please use .db -or .dw instead. - -Internal assembler error -~~~~~~~~~~~~~~~~~~~~~~~~ - -If you get an "Internal assembler error" please contact the project maintainer -by sending him a code example and a description of your working enviroment. - - -AVRA internals --------------- - -This section provides thoughts of the avra internal design. I have to admit -that the code of avra is anything else than clean and optimized. To increase -the code readability I will try to give you some standards that should improve -quality. The following standards are similar to what GNU proposes. - -Coding standards -~~~~~~~~~~~~~~~~ - -Tab space is always 2 spaces. The Tab character (ascii 9) is not used. -if,while,for are always opened on the same line but closed on the next line. -The closing bracket is in the same column as the first letter of the loop -directive. - - Example: ----- - while(i > 0) { - do_something(); - } ----- - - -Credits -------- - -We would like to thank the following people for giving contributions, -patches and bug reports, as well as suggestions and new ideas. - ----- - Jon Anders Haugum (project founder) - Burkhard Arenfeld (release 1.2.0) - Tobias Weber (old maintainer) - Jerry Jacobs (release 1.3.0) - Bernt Hembre - Nils Strøm - Roberto Biancardi - Qwerty Jones - Ben Hitchcock (Maker of the mac port) - Daniel Drotos - Laurence Boyd II - Varuzhan Danielyan - Laurence Turner - Eugene R. O'Bryan - Dmitry Dicky - Bob Harris (Maker of coff support) - Tobias Weber (enhanced macro support) - Lesha Bogdanow - Jim Galbraith - Mark Brinicombe - Igor Nikolayenko - Peter Hettkamp - Herb Poppe - David Burke - Alexey Pavluchenko - Alan Probandt - Mariusz Matuszek - Arne Rossius - Marti Tichacek - Patrick Parity - Johannes Overmann - Roland Riegel - Peter Katzmann - Donald D. Davis ----- - -And all the anonymous people who submitted patches! - -Thank you for your work and support. - -References ----------- - - http://www.suprafluid.com/avra - http://www.avrfreaks.de - http://www.atmel.com diff -Nru avra-1.3.0/doc/xhtml11.css avra-1.4.2+dfsg/doc/xhtml11.css --- avra-1.3.0/doc/xhtml11.css 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/xhtml11.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,367 +0,0 @@ -/* Debug borders */ -p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { -/* - border: 1px solid red; -*/ -} - -body { - margin: 1em 5% 1em 5%; -} - -a { - color: blue; - text-decoration: underline; -} -a:visited { - color: fuchsia; -} - -em { - font-style: italic; - color: navy; -} - -strong { - font-weight: bold; - color: #083194; -} - -tt { - color: navy; -} - -h1, h2, h3, h4, h5, h6 { - color: #527bbd; - font-family: sans-serif; - margin-top: 1.2em; - margin-bottom: 0.5em; - line-height: 1.3; -} - -h1, h2, h3 { - border-bottom: 2px solid silver; -} -h2 { - padding-top: 0.5em; -} -h3 { - float: left; -} -h3 + * { - clear: left; -} - -div.sectionbody { - font-family: serif; - margin-left: 0; -} - -hr { - border: 1px solid silver; -} - -p { - margin-top: 0.5em; - margin-bottom: 0.5em; -} - -ul, ol, li > p { - margin-top: 0; -} - -pre { - padding: 0; - margin: 0; -} - -span#author { - color: #527bbd; - font-family: sans-serif; - font-weight: bold; - font-size: 1.1em; -} -span#email { -} -span#revnumber, span#revdate, span#revremark { - font-family: sans-serif; -} - -div#footer { - font-family: sans-serif; - font-size: small; - border-top: 2px solid silver; - padding-top: 0.5em; - margin-top: 4.0em; -} -div#footer-text { - float: left; - padding-bottom: 0.5em; -} -div#footer-badges { - float: right; - padding-bottom: 0.5em; -} - -div#preamble { - margin-top: 1.5em; - margin-bottom: 1.5em; -} -div.tableblock, div.imageblock, div.exampleblock, div.verseblock, -div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, -div.admonitionblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -div.admonitionblock { - margin-top: 2.0em; - margin-bottom: 2.0em; - margin-right: 10%; - color: #606060; -} - -div.content { /* Block element content. */ - padding: 0; -} - -/* Block element titles. */ -div.title, caption.title { - color: #527bbd; - font-family: sans-serif; - font-weight: bold; - text-align: left; - margin-top: 1.0em; - margin-bottom: 0.5em; -} -div.title + * { - margin-top: 0; -} - -td div.title:first-child { - margin-top: 0.0em; -} -div.content div.title:first-child { - margin-top: 0.0em; -} -div.content + div.title { - margin-top: 0.0em; -} - -div.sidebarblock > div.content { - background: #ffffee; - border: 1px solid silver; - padding: 0.5em; -} - -div.listingblock > div.content { - border: 1px solid silver; - background: #f4f4f4; - padding: 0.5em; -} - -div.quoteblock, div.verseblock { - padding-left: 1.0em; - margin-left: 1.0em; - margin-right: 10%; - border-left: 5px solid #dddddd; - color: #777777; -} - -div.quoteblock > div.attribution { - padding-top: 0.5em; - text-align: right; -} - -div.verseblock > pre.content { - font-family: inherit; -} -div.verseblock > div.attribution { - padding-top: 0.75em; - text-align: left; -} -/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ -div.verseblock + div.attribution { - text-align: left; -} - -div.admonitionblock .icon { - vertical-align: top; - font-size: 1.1em; - font-weight: bold; - text-decoration: underline; - color: #527bbd; - padding-right: 0.5em; -} -div.admonitionblock td.content { - padding-left: 0.5em; - border-left: 3px solid #dddddd; -} - -div.exampleblock > div.content { - border-left: 3px solid #dddddd; - padding-left: 0.5em; -} - -div.imageblock div.content { padding-left: 0; } -span.image img { border-style: none; } -a.image:visited { color: white; } - -dl { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -dt { - margin-top: 0.5em; - margin-bottom: 0; - font-style: normal; - color: navy; -} -dd > *:first-child { - margin-top: 0.1em; -} - -ul, ol { - list-style-position: outside; -} -ol.arabic { - list-style-type: decimal; -} -ol.loweralpha { - list-style-type: lower-alpha; -} -ol.upperalpha { - list-style-type: upper-alpha; -} -ol.lowerroman { - list-style-type: lower-roman; -} -ol.upperroman { - list-style-type: upper-roman; -} - -div.compact ul, div.compact ol, -div.compact p, div.compact p, -div.compact div, div.compact div { - margin-top: 0.1em; - margin-bottom: 0.1em; -} - -div.tableblock > table { - border: 3px solid #527bbd; -} -thead, p.table.header { - font-family: sans-serif; - font-weight: bold; -} -tfoot { - font-weight: bold; -} -td > div.verse { - white-space: pre; -} -p.table { - margin-top: 0; -} -/* Because the table frame attribute is overriden by CSS in most browsers. */ -div.tableblock > table[frame="void"] { - border-style: none; -} -div.tableblock > table[frame="hsides"] { - border-left-style: none; - border-right-style: none; -} -div.tableblock > table[frame="vsides"] { - border-top-style: none; - border-bottom-style: none; -} - - -div.hdlist { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -div.hdlist tr { - padding-bottom: 15px; -} -dt.hdlist1.strong, td.hdlist1.strong { - font-weight: bold; -} -td.hdlist1 { - vertical-align: top; - font-style: normal; - padding-right: 0.8em; - color: navy; -} -td.hdlist2 { - vertical-align: top; -} -div.hdlist.compact tr { - margin: 0; - padding-bottom: 0; -} - -.comment { - background: yellow; -} - -.footnote, .footnoteref { - font-size: 0.8em; -} - -span.footnote, span.footnoteref { - vertical-align: super; -} - -#footnotes { - margin: 20px 0 20px 0; - padding: 7px 0 0 0; -} - -#footnotes div.footnote { - margin: 0 0 5px 0; -} - -#footnotes hr { - border: none; - border-top: 1px solid silver; - height: 1px; - text-align: left; - margin-left: 0; - width: 20%; - min-width: 100px; -} - - -@media print { - div#footer-badges { display: none; } -} - -div#toc { - margin-bottom: 2.5em; -} - -div#toctitle { - color: #527bbd; - font-family: sans-serif; - font-size: 1.1em; - font-weight: bold; - margin-top: 1.0em; - margin-bottom: 0.1em; -} - -div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { - margin-top: 0; - margin-bottom: 0; -} -div.toclevel2 { - margin-left: 2em; - font-size: 0.9em; -} -div.toclevel3 { - margin-left: 4em; - font-size: 0.9em; -} -div.toclevel4 { - margin-left: 6em; - font-size: 0.9em; -} diff -Nru avra-1.3.0/doc/xhtml11-manpage.css avra-1.4.2+dfsg/doc/xhtml11-manpage.css --- avra-1.3.0/doc/xhtml11-manpage.css 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/xhtml11-manpage.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* Overrides for manpage documents */ -h1 { - padding-top: 0.5em; - padding-bottom: 0.5em; - border-top: 2px solid silver; - border-bottom: 2px solid silver; -} -h2 { - border-style: none; -} -div.sectionbody { - margin-left: 5%; -} - -@media print { - div#toc { display: none; } -} - diff -Nru avra-1.3.0/doc/xhtml11-quirks.css avra-1.4.2+dfsg/doc/xhtml11-quirks.css --- avra-1.3.0/doc/xhtml11-quirks.css 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/doc/xhtml11-quirks.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* Workarounds for IE6's broken and incomplete CSS2. */ - -div.sidebar-content { - background: #ffffee; - border: 1px solid silver; - padding: 0.5em; -} -div.sidebar-title, div.image-title { - color: #527bbd; - font-family: sans-serif; - font-weight: bold; - margin-top: 0.0em; - margin-bottom: 0.5em; -} - -div.listingblock div.content { - border: 1px solid silver; - background: #f4f4f4; - padding: 0.5em; -} - -div.quoteblock-attribution { - padding-top: 0.5em; - text-align: right; -} - -pre.verseblock-content { - font-family: inherit; -} -div.verseblock-attribution { - padding-top: 0.75em; - text-align: left; -} - -div.exampleblock-content { - border-left: 3px solid #dddddd; - padding-left: 0.5em; -} - -/* IE6 sets dynamically generated links as visited. */ -div#toc a:visited { color: blue; } diff -Nru avra-1.3.0/examples/testcode_avra-1_2_3.asm avra-1.4.2+dfsg/examples/testcode_avra-1_2_3.asm --- avra-1.3.0/examples/testcode_avra-1_2_3.asm 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/examples/testcode_avra-1_2_3.asm 2020-07-18 23:19:00.000000000 +0000 @@ -1,5 +1,6 @@ .device ATmega8 - .org 0 .db 1,2 + .org 0 + .db 1,2 .message "The previous line is ignored with avra-1.2.2 because .org 0 is terminated with CR only. " .message "This is line 5 but avra-1.2.2 shows line 4" .db "X%MINUTE%YEAR%" ; Take a look at this percent chars too : % % % % diff -Nru avra-1.3.0/examples/throttle_divide.asm avra-1.4.2+dfsg/examples/throttle_divide.asm --- avra-1.3.0/examples/throttle_divide.asm 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/examples/throttle_divide.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -;throttle_divide.asm -; -;******************************************************************************** -;* div16u * -;* Second Level Subroutine * -;* * -;* Program from Atmel file avr200.asm * -;* * -;* Since the 25kHz pwm cycle is 64 clock cycles long, this subroutine * -;* requires 3.67 to 3.92 25kHz clock cycles. * -;* * -;* A single line was added which adds 3 to Cycle_count * -;* * -;* Inputs: HILOCAL2:HILOCAL1 and B_TEMPLOCAL1:B_TEMPLOCAL * -;* Returns: HILOCAL2:HILOCAL1 = HILOCAL2:HILOCAL1 / B_TEMPLOCAL1:B_TEMPLOCAL * -;* LOLOCAL2:LOLOCAL1 = remainder * -;* Changed: B_TEMPLOCAL2 * -;* * -;* Calls: Not allowed * -;******************************************************************************** - - - B_TEMPLOCAL2 dcnt16u ; Local counter - - HILOCAL1 dd16uL ; 16 bit Innput - HILOCAL2 dd16uH - - B_TEMPLOCAL dv16uL ; 16 bit Input - B_TEMPLOCAL1 dv16uH - - HILOCAL1 dres16uL ; 16 bit Output - HILOCAL2 dres16uH - - LOWLOCAL1 drem16uL ; 16 bit Remainder - LOWLOCAL2 drem16uH ; - - - -; -;*************************************************************************** -;* -;* "div16u" - 16/16 Bit Unsigned Division -;* -;* This subroutine divides the two 16-bit numbers -;* "dd16uH:dd16uL" (dividend) and "dv16uH:dv16uL" (divisor). -;* The result is placed in "dres16uH:dres16uL" and the remainder in -;* "drem16uH:drem16uL". -;* -;* Number of words :19 -;* Number of cycles :235/251 (Min/Max) -;* Low registers used :2 (drem16uL,drem16uH) -;* High registers used :5 (dres16uL/dd16uL,dres16uH/dd16uH,dv16uL,dv16uH, -;* dcnt16u) -;* -;*************************************************************************** - -;***** Subroutine Register Variables - -;.def drem16uL= r14 ; Reassigned -;.def drem16uH= r15 -;.def dres16uL= r16 -;.def dres16uH= r17 -;.def dd16uL= r16 -;.def dd16uH= r17 -;.def dv16uL= r18 -;.def dv16uH= r19 -;.def dcnt16u= r20 - -;***** Code - -div16u: - clr drem16uL ; clear remainder Low byte - sub drem16uH,drem16uH ; clear remainder High byte and carry - ldi dcnt16u,17 ; init loop counter - -d16u_1: - rol dd16uL ; shift left dividend - rol dd16uH - dec dcnt16u ; decrement counter - brne d16u_2 ; if done - - subi Cycle_count,256-3 ; Add 3 to Cycle_count - - ret ; return - -d16u_2: - rol drem16uL ; shift dividend into remainder - rol drem16uH - - sub drem16uL,dv16uL ; remainder = remainder - divisor - sbc drem16uH,dv16uH ; - - brcc d16u_3 ; - - add drem16uL,dv16uL ; if result negative - adc drem16uH,dv16uH ; restore remainder - clc ; clear carry to be shifted into result - rjmp d16u_1 ; - -d16u_3: ; if result NOT negative - sec ; set carry to be shifted into result - rjmp d16u_1 - -; - -;******************************************************************************** -;* DIVIDE_16_SIMPLE * -;* Second Level Subroutine * -;* * -;* Inputs: dd16uH:dd16ul and dv16uL * -;* Returns: dres16uH:dres16uL = dd8uH:dd8uL / 2^dv16uL * -;* * -;* Changed: nothing else * -;* N.B that dd16uH, dd16uL, dv16uH and dv16uL are aliases for: * -;* dd16uH=error_hi * -;* dd16uL=error_lo * -;* dv16uH=B_TempX * -;* dv16uL=B_TempX * -;* dcnt16u=B_TempX * -;* Calls: Not allowed * -;******************************************************************************** - - -DIVIDE_16_SIMPLE: - inc dv16uL -DIVIDE_16_SIMPLE_LOOP: - dec dv16uL ; decrement counter - brne DIVIDE_BY_2 - ret - -DIVIDE_BY_2: - asr dd16uH ; divide by two - ror dd16uL - rjmp DIVIDE_16_SIMPLE_LOOP - diff -Nru avra-1.3.0/examples/throttle_multiply.asm avra-1.4.2+dfsg/examples/throttle_multiply.asm --- avra-1.3.0/examples/throttle_multiply.asm 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/examples/throttle_multiply.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -;throttle_multiply.asm -; -;******************************************************************************** -;* mpy8u * -;* Second Level Subroutine * -;* * -;* Program from Atmel file avr200.asm * -;* * -;* Since the 25kHz pwm cycle is 64 clock cycles long, this subroutine * -;* requires just under 1 25kHz clock cycles. * -;* * -;* A single line was added which adds 3 to Cycle_count * -;* * -;* Inputs: HILOCAL1 and B_TEMPLOCAL * -;* * -;* Returns: HILOCAL1 x B_TEMPLOCAL = B_TEMPLOCAL1:B_TEMPLOCAL * -;* * -;* Changed: B_TEMPLOCAL2 * -;* * -;* Calls: Not allowed * -;******************************************************************************** - - HILOCAL1 mc8u ; multiplicand - B_TEMPLOCAL mp8u ; multiplier - B_TEMPLOCAL m8uL ; result Low byte - B_TEMPLOCAL1 m8uH ; result High byte - B_TEMPLOCAL2 mcnt8u ; loop counter - - -; -;*************************************************************************** -;* -;* "mpy8u" - 8x8 Bit Unsigned Multiplication -;* -;* This subroutine multiplies the two register variables mp8u and mc8u. -;* The result is placed in registers m8uH, m8uL -;* -;* Number of words :9 + return -;* Number of cycles :58 + return -;* Low registers used :None -;* High registers used :4 (mp8u,mc8u/m8uL,m8uH,mcnt8u) -;* -;* Note: Result Low byte and the multiplier share the same register. -;* This causes the multiplier to be overwritten by the result. -;* -;*************************************************************************** - -;***** Subroutine Register Variables - -;.def mc8u =r16 ;multiplicand -;.def mp8u =r17 ;multiplier -;.def m8uL =r17 ;result Low byte -;.def m8uH =r18 ;result High byte -;.def mcnt8u =r19 ;loop counter - -;***** Code - - -mpy8u: - clr m8uH ;clear result High byte - ldi mcnt8u,8 ;init loop counter - lsr mp8u ;rotate multiplier - -m8u_1: - brcc m8u_2 ;carry set - add m8uH,mc8u ;add multiplicand to result High byte -m8u_2: - ror m8uH ;rotate right result High byte - ror m8uL ;rotate right result L byte and multiplier - dec mcnt8u ;decrement loop counter - brne m8u_1 ;if not done, loop more - ret - -; diff -Nru avra-1.3.0/.gitignore avra-1.4.2+dfsg/.gitignore --- avra-1.3.0/.gitignore 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/.gitignore 2020-07-18 23:19:00.000000000 +0000 @@ -1,5 +1,10 @@ archives releases patches +/src/avra *.o *.exe +*.obj +*.hex +*.cof +*.lst diff -Nru avra-1.3.0/includes/1200def.inc avra-1.4.2+dfsg/includes/1200def.inc --- avra-1.3.0/includes/1200def.inc 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/includes/1200def.inc 2020-07-18 23:19:00.000000000 +0000 @@ -1,297 +1,297 @@ -;***** THIS IS A MACHINE GENERATED FILE - DO NOT EDIT ******************** -;***** Created: 2005-01-11 10:30 ******* Source: AT90S1200.xml *********** -;************************************************************************* -;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y -;* -;* Number : AVR000 -;* File Name : "1200def.inc" -;* Title : Register/Bit Definitions for the AT90S1200 -;* Date : 2005-01-11 -;* Version : 2.14 -;* Support E-mail : avr@atmel.com -;* Target MCU : AT90S1200 -;* -;* DESCRIPTION -;* When including this file in the assembly program file, all I/O register -;* names and I/O register bit names appearing in the data book can be used. -;* In addition, the six registers forming the three data pointers X, Y and -;* Z have been assigned names XL - ZH. Highest RAM address for Internal -;* SRAM is also defined -;* -;* The Register names are represented by their hexadecimal address. -;* -;* The Register Bit names are represented by their bit number (0-7). -;* -;* Please observe the difference in using the bit names with instructions -;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" -;* (skip if bit in register set/cleared). The following example illustrates -;* this: -;* -;* in r16,PORTB ;read PORTB latch -;* sbr r16,(1< #include #include @@ -38,170 +38,240 @@ struct args *args; args = malloc(sizeof(struct args)); - if(args) { + if (args) { args->arg = malloc(sizeof(struct arg) * arg_count); - if(args->arg) { + if (args->arg) { args->count = arg_count; args->first_data = NULL; - return(args); + return (args); } free(args); } printf("Error: Unable to allocate memory\n"); - return(NULL); + return (NULL); +} + +const struct dataset * +match_dataset(const struct dataset datasets[], const char *key) +{ + const struct dataset *ds; + for (ds = datasets; + ds->dset_name != NULL; ds++) { + if (strncmp(key, ds->dset_name, + strlen(ds->dset_name)) == 0) { + return ds; + } + } + return NULL; +} + +void +print_dataset(const struct dataset datasets[]) +{ + const struct dataset *ds; + printf("either "); + for (ds = datasets; + ds->dset_name != NULL; ds++) { + if (ds != datasets) { + if (ds[1].dset_name == NULL) + printf(" or "); + else + printf(", "); + } + printf("\"%s\"", ds->dset_name); + } + printf(".\n"); } +int +process_optvalue(const char *optname, struct arg *cur, const char *optval) +{ + int ok = True; + long numeric; + char *endptr; + const struct dataset *ds; + switch (cur->type) { + case ARGTYPE_NUMERIC: + if ((numeric = strtol(optval, &endptr, 10)) == 0) { + if (endptr == optval) { + printf("Error: %s needs a numeric argument (given %s)\n", optname, optval); + ok = False; + break; + } + cur->data.i = (int)numeric; + } + break; + case ARGTYPE_STRING: + cur->data.p = optval; + break; + case ARGTYPE_STRING_MULTISINGLE: + ok = add_arg(&cur->data.dl, optval); + break; + case ARGTYPE_CHOICE: + ds = match_dataset(cur->dataset, optval); + if (ds) { + cur->data.i = ds->dset_value; + } else { + printf("Error: Illegal value for %s: %s, should be ", optname, optval); + print_dataset(cur->dataset); + ok = False; + } + } + return ok; +} -int read_args(struct args *args, int argc, char *argv[]) +int +read_args(struct args *args, int argc, const char *argv[]) { int i, j, k, ok, i_old; struct data_list **last_data; - /*** init ***/ + ok = True; args->first_data = NULL; - /*** end of init ***/ last_data = &args->first_data; - for(i = 1; (i < argc) && ok; i++) { - if(argv[i][0] == '-') { + for (i = 1; (i < argc) && ok; i++) { + if (argv[i][0] == '-') { last_data = &args->first_data; - if(argv[i][1] == 0) { + if (argv[i][1] == 0) { printf("Error: Unknown option: -\n"); ok = False; - } else - if(argv[i][1] == '-') { + } else if (argv[i][1] == '-') { + j = 0; + while ((j != args->count) && strcmp(&argv[i][2], args->arg[j].longarg)) { + j++; + } + if (j == args->count) { + printf("Error: Unknown option: %s\n", argv[i]); + ok = False; + } else { + switch (args->arg[j].type) { + case ARGTYPE_STRING: + case ARGTYPE_STRING_MULTISINGLE: + case ARGTYPE_NUMERIC: + case ARGTYPE_CHOICE: + /* if argument is a string parameter we will do this: */ + if ((i + 1) == argc) { + printf("Error: No argument supplied with option: %s\n", argv[i]); + ok = False; + } else { + ok = process_optvalue(argv[i], &args->arg[j], argv[i+1]); + i++; + } + break; + case ARGTYPE_BOOLEAN: + args->arg[j].data.i = True; + break; + case ARGTYPE_STRING_MULTI: + last_data = &args->arg[j].data.dl; + break; + } + } + } else { + for (k = 1, i_old = i; (argv[i][k] != '\0') && ok && (i == i_old); k++) { j = 0; - while((j != args->count) && strcmp(&argv[i][2], args->arg[j].longarg)) { + while ((j != args->count) && (argv[i][k] != args->arg[j].letter)) j++; - } - if(j == args->count) { - printf("Error: Unknown option: %s\n", argv[i]); + if (j == args->count) { + printf("Error: Unknown option: -%c\n", argv[i][k]); ok = False; } else { - switch(args->arg[j].type) { - case ARGTYPE_STRING: - case ARGTYPE_STRING_MULTISINGLE: - /* if argument is a string parameter we will do this: */ - if((i + 1) == argc) { - printf("Error: No argument supplied with option: %s\n", argv[i]); + switch (args->arg[j].type) { + case ARGTYPE_STRING: + case ARGTYPE_STRING_MULTISINGLE: + case ARGTYPE_NUMERIC: + case ARGTYPE_CHOICE: + if (argv[i][k + 1] != '\0') { + printf("Error: Option -%c must be followed by it's argument\n", argv[i][k]); + ok = False; + } else { + if ((i + 1) == argc) { + printf("Error: No argument supplied with option: -%c\n", argv[i][k]); ok = False; - } else - if(args->arg[j].type != ARGTYPE_STRING_MULTISINGLE) - args->arg[j].data = argv[++i]; - else - ok = add_arg((struct data_list **)&args->arg[j].data, argv[++i]); - break; - case ARGTYPE_BOOLEAN: - args->arg[j].data = (char *)True; - break; - case ARGTYPE_STRING_MULTI: - last_data = (struct data_list **)&args->arg[j].data; - break; - } - } - } else { - for(k = 1, i_old = i; (argv[i][k] != '\0') && ok && (i == i_old); k++) { - j = 0; - while((j != args->count) && (argv[i][k] != args->arg[j].letter)) - j++; - if(j == args->count) { - printf("Error: Unknown option: -%c\n", argv[i][k]); - ok = False; - } else { - switch(args->arg[j].type) { - case ARGTYPE_STRING: - case ARGTYPE_STRING_MULTISINGLE: - if(argv[i][k + 1] != '\0') { - printf("Error: Option -%c must be followed by it's argument\n", argv[i][k]); - ok = False; - } else { - if((i + 1) == argc) { - printf("Error: No argument supplied with option: -%c\n", argv[i][k]); - ok = False; - } else - if(args->arg[j].type != ARGTYPE_STRING_MULTISINGLE) - args->arg[j].data = argv[++i]; - else - ok = add_arg((struct data_list **)&args->arg[j].data, argv[++i]); - } + } else + ok = process_optvalue(argv[i], &args->arg[j], argv[i+1]); + i++; + } + break; + case ARGTYPE_BOOLEAN: + args->arg[j].data.i = True; + break; + case ARGTYPE_STRING_MULTI: + last_data = &args->arg[j].data.dl; + break; + /* Parameters that have only one char attached */ + case ARGTYPE_CHAR_ATTACHED: + if ((i + 1) == argc) { + printf("Error: missing arguments: asm file"); + ok = False; + } else { + switch (argv[i][++k]) { + case 'O': + args->arg[j].data.i = AVRSTUDIO; break; - case ARGTYPE_BOOLEAN: - args->arg[j].data = (char *)True; + case 'G': + args->arg[j].data.i = GENERIC; break; - case ARGTYPE_STRING_MULTI: - last_data = (struct data_list **)&args->arg[j].data; + case 'I': + args->arg[j].data.i = INTEL; break; - /* Parameters that have only one char attached */ - case ARGTYPE_CHAR_ATTACHED: - if((i + 1) == argc) { - printf("Error: missing arguments: asm file"); - ok = False; - } else { - switch(argv[i][++k]) { - case 'O': - args->arg[j].data = (char *)AVRSTUDIO; - break; - case 'G': - args->arg[j].data = (char *)GENERIC; - break; - case 'I': - args->arg[j].data = (char *)INTEL; - break; - case 'M': - args->arg[j].data = (char *)MOTOROLA; - break; - default: - printf("Error: wrong file type '%c'",argv[i][2]); - ok = False; - } - } + case 'M': + args->arg[j].data.i = MOTOROLA; + break; + default: + printf("Error: wrong file type '%c'",argv[i][2]); + ok = False; + } } } } } + } } else ok = add_arg(last_data, argv[i]); } - return(ok); + return (ok); } -int add_arg(struct data_list **last_data, char *argv) +int +add_arg(struct data_list **last_data, const char *argv) { struct data_list *data; - while(*last_data) - last_data = &((*last_data)->next); + while (*last_data) + last_data = &((*last_data)->next); data = malloc(sizeof(struct data_list)); - if(data) { + if (data) { data->next = NULL; data->data = argv; *last_data = data; last_data = &data->next; } else { printf("Error: Unable to allocate memory\n"); - return(False); + return (False); } - return(True); + return (True); } -void free_args(struct args *args) +void +free_args(struct args *args) { int i; struct data_list *data, *temp; - for(data = args->first_data; data;) { + for (data = args->first_data; data;) { temp = data; data = data->next; free(temp); } - for(i = 0; i != args->count; i++) - if((args->arg[i].type == ARGTYPE_STRING_MULTI) - || (args->arg[i].type == ARGTYPE_STRING_MULTISINGLE)) - for(data = args->arg[i].data; data;) { + for (i = 0; i != args->count; i++) + if ((args->arg[i].type == ARGTYPE_STRING_MULTI) + || (args->arg[i].type == ARGTYPE_STRING_MULTISINGLE)) + for (data = args->arg[i].data.dl; data;) { temp = data; data = data->next; free(temp); @@ -210,13 +280,24 @@ } -void define_arg(struct args *args, int index, int type, char letter, char *longarg, void *def_value) +void +define_arg(struct args *args, int index, int type, char letter, char *longarg, const char *def_value, const struct dataset dataset[]) { args->arg[index].type = type; args->arg[index].letter = letter; args->arg[index].longarg = longarg; - args->arg[index].data = def_value; + args->arg[index].data.p = def_value; + args->arg[index].dataset = dataset; } -/* end of args.c */ +void +define_arg_int(struct args *args, int index, int type, char letter, char *longarg, int def_value, const struct dataset dataset[]) +{ + args->arg[index].type = type; + args->arg[index].letter = letter; + args->arg[index].longarg = longarg; + args->arg[index].data.i = def_value; + args->arg[index].dataset = dataset; +} +/* end of args.c */ diff -Nru avra-1.3.0/src/args.h avra-1.4.2+dfsg/src/args.h --- avra-1.3.0/src/args.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/args.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2006 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #ifndef _args_h_ @@ -33,11 +33,17 @@ ARGTYPE_STRING, /* Stringpointer in Data */ ARGTYPE_STRING_MULTI, /* List of strings in Data */ ARGTYPE_STRING_MULTISINGLE, /* List of strings in Data. requires an option for each element */ - ARGTYPE_CHAR_ATTACHED + ARGTYPE_CHAR_ATTACHED, + ARGTYPE_CHOICE, + ARGTYPE_NUMERIC }; -#define GET_ARG(args, argnum) (args->arg[argnum].data) -#define SET_ARG(args, argnum, value) (args->arg[argnum].data = (void *)value) +#define GET_ARG_I(args, argnum) (args->arg[argnum].data.i) +#define SET_ARG_I(args, argnum, value) (args->arg[argnum].data.i = (value)) +#define GET_ARG_P(args, argnum) (args->arg[argnum].data.p) +#define SET_ARG_P(args, argnum, value) (args->arg[argnum].data.p = (value)) +#define GET_ARG_LIST(args, argnum) (args->arg[argnum].data.dl) +#define SET_ARG_LIST(args, argnum, value) (args->arg[argnum].data.dl = (value)) struct args { struct arg *arg; @@ -45,23 +51,34 @@ struct data_list *first_data; }; +struct dataset { + int dset_value; + const char *const dset_name; +}; + struct arg { int type; char letter; char *longarg; - void *data; + union { + int i; + const char *p; + struct data_list *dl; + } data; + const struct dataset *dataset; }; struct data_list { struct data_list *next; - void *data; + const char *data; }; struct args *alloc_args(int arg_count); -int read_args(struct args *args, int argc, char *argv[]); -int add_arg(struct data_list **last_data, char *argv); +int read_args(struct args *args, int argc, const char *argv[]); +int add_arg(struct data_list **last_data, const char *argv); void free_args(struct args *args); -void define_arg(struct args *args, int index, int type, char letter, char *longarg, void *def_value); +void define_arg(struct args *args, int index, int type, char letter, char *longarg, const char *def_value, const struct dataset dataset[]); +void define_arg_int(struct args *args, int index, int type, char letter, char *longarg, int def_value, const struct dataset dataset[]); #endif /* end of args.h */ diff -Nru avra-1.3.0/src/avra.c avra-1.4.2+dfsg/src/avra.c --- avra-1.3.0/src/avra.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/avra.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2006 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #include @@ -37,645 +37,647 @@ #define debug 0 -const char *title = - "AVRA: advanced AVR macro assembler Version %i.%i.%i Build %i (%s)\n" - "Copyright (C) 1998-2010. Check out README file for more info\n" - "\n" - " AVRA is an open source assembler for Atmel AVR microcontroller family\n" - " It can be used as a replacement of 'AVRASM32.EXE' the original assembler\n" - " shipped with AVR Studio. We do not guarantee full compatibility for avra.\n" - "\n" - " AVRA comes with NO WARRANTY, to the extent permitted by law.\n" - " You may redistribute copies of avra under the terms\n" - " of the GNU General Public License.\n" - " For more information about these matters, see the files named COPYING.\n" - "\n"; +#ifndef VERSION +#define VERSION "undefined" +#endif + +const char *title = "AVRA: advanced AVR macro assembler (version %s)\n"; const char *usage = - "usage: avra [-f][O|M|I|G] output file type\n" - " [-o ] output file name\n" - " [-l ] generate list file\n" - " [-m ] generate map file\n" - "[--define [=]] [--includedir ] [--listmac]\n" - " [--max_errors ] [--devices] [--version]\n" - " [-h] [--help] general help\n" - " " - " \n" - "\n" - " --listfile -l : Create list file\n" - " --mapfile -m : Create map file\n" - " --define -D : Define symbol.\n" - " --includepath -I : Additional include paths.\n" - " --listmac : List macro expansion in listfile.\n" - " --max_errors : Maximum number of errors before exit\n" - " (default: 10)\n" - " --devices : List out supported devices.\n" - " --version : Version information.\n" - " --help, -h : This help text.\n" - "\n" - "Just replace the AVRASM32.EXE with AVRA.EXE in your\n" - "AVRStudio directories to avra's binary.\n"; - -int main(int argc, char *argv[]) -{ - int show_usage = False; - struct prog_info *pi=NULL; - struct args *args; - unsigned char c; + "usage: avra [-f][O|M|I|G] output file type\n" + " [-o ] output file name\n" + " [-d ] debug file name\n" + " [-e ] file name to output EEPROM contents\n" + " [-l ] generate list file\n" + " [-m ] generate map file\n" + " [--define [=]]\n" + " [-I ] [--listmac]\n" + " [--max_errors ] [--devices] [--version]\n" + " [-O e|w|i]\n" + " [-h] [--help] general help\n" + " \n" + "\n" + " --listfile -l : Create list file\n" + " --mapfile -m : Create map file\n" + " --define -D : Define symbol.\n" + " --includedir -I : Additional include paths. Default: %s\n" + " --listmac : List macro expansion in listfile.\n" + " --max_errors : Maximum number of errors before exit\n" + " (default: 10)\n" + " --devices : List out supported devices.\n" + " --version : Version information.\n" + " -O e|w|i : Issue error/warning/ignore overlapping code.\n" + " --help, -h : This help text.\n"; + +const struct dataset overlap_choice[4] = { + { OVERLAP_ERROR, "e"}, + { OVERLAP_WARNING, "w"}, + { OVERLAP_IGNORE, "i"}, + { -1, NULL} +}; + +const int SEG_BSS_DATA = 0x01; + +static struct prog_info PROG_INFO; +static struct segment_info CODE_SEG; +static struct segment_info DATA_SEG; +static struct segment_info EEPROM_SEG; + +int +main(int argc, const char *argv[]) +{ + int show_usage = False; + struct prog_info *pi; + struct args *args; + unsigned char c; #if debug == 1 - int i; - for(i = 0; i < argc; i++) { - printf(argv[i]); - printf("\n"); - } + int i; + for (i = 0; i < argc; i++) { + printf(argv[i]); + printf("\n"); + } #endif - printf(title, VER_MAJOR, VER_MINOR, VER_RELEASE, VER_BUILD, VER_DATE); + printf(title, VERSION); - args = alloc_args(ARG_COUNT); - if(args) { - define_arg(args, ARG_DEFINE, ARGTYPE_STRING_MULTISINGLE, 'D', "define", NULL); - define_arg(args, ARG_INCLUDEPATH, ARGTYPE_STRING_MULTISINGLE, 'I', "includepath", NULL); - define_arg(args, ARG_LISTMAC, ARGTYPE_BOOLEAN, 0, "listmac", "1"); - define_arg(args, ARG_MAX_ERRORS, ARGTYPE_STRING, 0, "max_errors", "10"); - define_arg(args, ARG_COFF, ARGTYPE_BOOLEAN, 0, "coff", NULL); - define_arg(args, ARG_DEVICES, ARGTYPE_BOOLEAN, 0, "devices", NULL); - define_arg(args, ARG_VER, ARGTYPE_BOOLEAN, 0, "version", NULL); - define_arg(args, ARG_HELP, ARGTYPE_BOOLEAN, 'h', "help", NULL); - define_arg(args, ARG_WRAP, ARGTYPE_BOOLEAN, 'w', "wrap", NULL); // Not implemented ? B.A. - define_arg(args, ARG_WARNINGS, ARGTYPE_STRING_MULTISINGLE, 'W', "warn", NULL); - define_arg(args, ARG_FILEFORMAT, ARGTYPE_CHAR_ATTACHED, 'f', "filetype", "0"); // Not implemented ? B.A. - define_arg(args, ARG_LISTFILE, ARGTYPE_STRING, 'l', "listfile", NULL); - define_arg(args, ARG_OUTFILE, ARGTYPE_STRING, 'o', "outfile", NULL); // Not implemented ? B.A. - define_arg(args, ARG_MAPFILE, ARGTYPE_STRING, 'm', "mapfile", NULL); - define_arg(args, ARG_DEBUGFILE, ARGTYPE_STRING, 'd', "debugfile", NULL); // Not implemented ? B.A. - define_arg(args, ARG_EEPFILE, ARGTYPE_STRING, 'e', "eepfile", NULL); // Not implemented ? B.A. - - - c = read_args(args, argc, argv); - - if(c != 0) { - if(!GET_ARG(args, ARG_HELP) && (argc != 1)) { - if(!GET_ARG(args, ARG_VER)) { - if(!GET_ARG(args, ARG_DEVICES)) { - pi = get_pi(args); - if(pi) { - get_rootpath(pi, args); /* get assembly root path */ - if (assemble(pi) != 0) { /* the main assembly call */ - exit(EXIT_FAILURE); - } - free_pi(pi); /* free all allocated memory */ - } - } - else { - list_devices(); /* list all supported devices */ - } - } - } - else - show_usage = True; - } - free_args(args); - } - else { - show_usage = True; - printf("\n"); - } - if(show_usage) { - printf("%s", usage); - } - exit(EXIT_SUCCESS); - return (0); /* compiler warning, JEG 4-23-03 */ -} - -void get_rootpath(struct prog_info *pi, struct args *args) -{ - int i; - int j; - char c; - struct data_list *data; - - data = args->first_data; - if(!data) - return; - while(data->next) data = ((data)->next); - - if (data != NULL) { - i = strlen((char *)data->data); - if (i > 0) { - pi->root_path = malloc(i + 1); - strcpy(pi->root_path,(char *)data->data); - j = 0; - do { - c = pi->root_path[i]; - if(c == '\\' || c == '/') { - j = i + 1; - break; - } - } while(i-- > 0); - pi->root_path[j] = '\0'; - return; - } - } - pi->root_path = ""; -} - - -int assemble(struct prog_info *pi) { - unsigned char c; - - if(pi->args->first_data) { - printf("Pass 1...\n"); - if(load_arg_defines(pi)==False) - return -1; - if(predef_dev(pi)==False) /* B.A.: Now with error check */ - return -1; - /*** FIRST PASS ***/ - def_orglist(pi); /* B.A. : Store first active segment and seg_addr (Default : Code, Adr=0) */ - c = parse_file(pi, (char *)pi->args->first_data->data); - fix_orglist(pi); /* B.A. : Update last active segment */ - test_orglist(pi); /* B.A.: Test for overlapping memory segments and out of chip space */ - if(c != False) { -#if debug == 1 - printf("error_count = %i\n", pi->error_count); + args = alloc_args(ARG_COUNT); + if (args) { + define_arg(args, ARG_DEFINE, ARGTYPE_STRING_MULTISINGLE, 'D', "define", NULL, NULL); + define_arg(args, ARG_INCLUDEPATH, ARGTYPE_STRING_MULTISINGLE, 'I', "includepath", NULL, NULL); + define_arg(args, ARG_LISTMAC, ARGTYPE_BOOLEAN, 0, "listmac", "1", NULL); + define_arg_int(args, ARG_MAX_ERRORS, ARGTYPE_NUMERIC, 0, "max_errors", 10, NULL); + define_arg(args, ARG_COFF, ARGTYPE_BOOLEAN, 0, "coff", NULL, NULL); + define_arg(args, ARG_DEVICES, ARGTYPE_BOOLEAN, 0, "devices", NULL, NULL); + define_arg(args, ARG_VER, ARGTYPE_BOOLEAN, 0, "version", NULL, NULL); + define_arg(args, ARG_HELP, ARGTYPE_BOOLEAN, 'h', "help", NULL, NULL); + define_arg(args, ARG_WRAP, ARGTYPE_BOOLEAN, 'w', "wrap", NULL, NULL); /* Not implemented ? B.A. */ + define_arg(args, ARG_WARNINGS, ARGTYPE_STRING_MULTISINGLE, 'W', "warn", NULL, NULL); + define_arg(args, ARG_FILEFORMAT, ARGTYPE_CHAR_ATTACHED, 'f', "filetype", "0", NULL); /* Not implemented ? B.A. */ + define_arg(args, ARG_LISTFILE, ARGTYPE_STRING, 'l', "listfile", NULL, NULL); + define_arg(args, ARG_OUTFILE, ARGTYPE_STRING, 'o', "outfile", NULL, NULL); + define_arg(args, ARG_MAPFILE, ARGTYPE_STRING, 'm', "mapfile", NULL, NULL); + define_arg(args, ARG_DEBUGFILE, ARGTYPE_STRING, 'd', "debugfile", NULL, NULL); + define_arg(args, ARG_EEPFILE, ARGTYPE_STRING, 'e', "eepfile", NULL, NULL); + define_arg_int(args, ARG_OVERLAP, ARGTYPE_CHOICE, 'O', "overlap", OVERLAP_ERROR, overlap_choice); + + + c = read_args(args, argc, argv); + + if (c != 0) { + if (!GET_ARG_I(args, ARG_HELP) && (argc != 1)) { + if (!GET_ARG_I(args, ARG_VER)) { + if (!GET_ARG_I(args, ARG_DEVICES)) { + pi = init_prog_info(&PROG_INFO, args); + if (pi) { + get_rootpath(pi, args); /* get assembly root path */ + if (assemble(pi) != 0) { /* the main assembly call */ + exit(EXIT_FAILURE); + } + free_pi(pi); /* free all allocated memory */ + } + } else { + list_devices(); /* list all supported devices */ + } + } + } else + show_usage = True; + } + free_args(args); + } else { + show_usage = True; + printf("\n"); + } + if (show_usage) { +#ifdef DEFAULT_INCLUDE_PATH + printf(usage, DEFAULT_INCLUDE_PATH); +#else + printf(usage, "."); #endif - /* B.A.: This part is obsolete. Now check is done in test_orglist() */ - /* before we go to the 2nd pass, make sure used space is ok */ - /* if(pi->eseg_count > pi->device->eeprom_size) { - print_msg(pi, MSGTYPE_ERROR, - "EEPROM space exceeded by %i bytes!", pi->eseg_count-pi->device->eeprom_size); + } + exit(EXIT_SUCCESS); + return (0); +} + +void +get_rootpath(struct prog_info *pi, struct args *args) +{ + int i; + int j; + char c; + struct data_list *data; + + data = args->first_data; + if (!data) + return; + while (data->next) data = ((data)->next); + + if (data != NULL) { + i = strlen((char *)data->data); + if (i > 0) { + pi->root_path = malloc(i + 1); + strcpy(pi->root_path,(char *)data->data); + j = 0; + do { + c = pi->root_path[i]; + if (c == '\\' || c == '/') { + j = i + 1; + break; + } + } while (i-- > 0); + pi->root_path[j] = '\0'; + return; + } + } + pi->root_path = ""; +} + + +int +assemble(struct prog_info *pi) +{ + unsigned char c; + + if (pi->args->first_data) { + printf("Pass 1...\n"); + if (load_arg_defines(pi)==False) return -1; - } - if(pi->cseg_count > pi->device->flash_size) { - print_msg(pi, MSGTYPE_ERROR, - "FLASH space exceeded by %i bytes!", pi->cseg_count-pi->device->flash_size); + if (predef_dev(pi)==False) return -1; - } */ - /* if there are no furter errors, we can continue with 2nd pass */ - if(pi->error_count == 0) { - prepare_second_pass(pi); - if(load_arg_defines(pi)==False) - return -1; - if(predef_dev(pi)==False) /* B.A.: Now with error check */ - return -1; - c = open_out_files(pi, pi->args->first_data->data); - if(c != 0) { - printf("Pass 2...\n"); - parse_file(pi, (char *)pi->args->first_data->data); - printf("done\n\n"); - print_orglist(pi); /* B.A.: List used memory segments */ - if(GET_ARG(pi->args, ARG_COFF) && (pi->error_count == 0)) { - write_coff_file(pi); - } - write_map_file(pi); - if(pi->error_count) { /* if there were errors */ - printf("\nAssembly aborted with %d errors and %d warnings.\n", pi->error_count, pi->warning_count); + /*** FIRST PASS ***/ + def_orglist(pi->cseg); + c = parse_file(pi, pi->args->first_data->data); + fix_orglist(pi->segment); + test_orglist(pi->cseg); + test_orglist(pi->dseg); + test_orglist(pi->eseg); + + if (c != False) { + /* if there are no further errors, we can continue with 2nd pass */ + if (pi->error_count == 0) { + pi->segment = pi->cseg; + rewind_segments(pi); + pi->pass=PASS_2; + if (load_arg_defines(pi)==False) + return -1; + if (predef_dev(pi)==False) + return -1; + /*** SECOND PASS ***/ + c = open_out_files(pi, pi->args->first_data->data, + GET_ARG_P(pi->args, ARG_OUTFILE), + GET_ARG_P(pi->args, ARG_DEBUGFILE), + GET_ARG_P(pi->args, ARG_EEPFILE)); + if (c != 0) { + printf("Pass 2...\n"); + parse_file(pi, pi->args->first_data->data); + printf("done\n\n"); + if (pi->list_file) + fprint_segments(pi->list_file, pi); + if (pi->coff_file && pi->error_count == 0) { + write_coff_file(pi); + } + write_map_file(pi); + if (pi->error_count) { + printf("\nAssembly aborted with %d errors and %d warnings.\n", pi->error_count, pi->warning_count); unlink_out_files(pi, pi->args->first_data->data); - } else { /* assembly was succesfull */ - if(pi->warning_count) - printf("\nAssembly complete with no errors (%d warnings).\n", pi->warning_count); - else - printf("\nAssembly complete with no errors.\n"); - close_out_files(pi); - } + } else { + if (pi->warning_count) + printf("\nAssembly complete with no errors (%d warnings).\n", pi->warning_count); + else + printf("\nAssembly complete with no errors.\n"); + close_out_files(pi); + } + } + } else { + unlink_out_files(pi, pi->args->first_data->data); } - } else { - unlink_out_files(pi, pi->args->first_data->data); - } - } - } else { - printf("Error: You need to specify a file to assemble\n"); - } - return pi->error_count; + } + } else { + printf("Error: You need to specify a file to assemble\n"); + } + return pi->error_count; } -int load_arg_defines(struct prog_info *pi) -{ - int i; - char *expr; - char buff[256]; - struct data_list *define; - - for(define = GET_ARG(pi->args, ARG_DEFINE); define; define = define->next) { - strcpy(buff, define->data); - expr = get_next_token( buff, TERM_EQUAL); - if(expr) { - // we reach this, when there is actually a value passed.. - if(!get_expr(pi, expr, &i)) { - return(False); - } - } else { - // if user didnt specify a value, we default to 1 - i = 1; - } - /* B.A. : New. Forward references allowed. But check, if everything is ok ... */ - if(pi->pass==PASS_1) { /* Pass 1 */ - if(test_constant(pi,buff,NULL)!=NULL) { - fprintf(stderr,"Error: Can't define symbol %s twice\n", buff); - return(False); - } - if(def_const(pi, buff, i)==False) - return(False); +int +load_arg_defines(struct prog_info *pi) +{ + int i; + char *expr; + char buff[256]; + struct data_list *define; + + for (define = GET_ARG_LIST(pi->args, ARG_DEFINE); define; define = define->next) { + strcpy(buff, define->data); + expr = get_next_token(buff, TERM_EQUAL); + if (expr) { + /* we reach this, when there is actually a value passed.. */ + if (!get_expr(pi, expr, &i)) { + return (False); + } + } else { + /* if user didnt specify a value, we default to 1 */ + i = 1; + } + /* Forward references allowed. But check, if everything is ok... */ + if (pi->pass==PASS_1) { /* Pass 1 */ + if (test_constant(pi,buff,NULL)!=NULL) { + fprintf(stderr,"Error: Can't define symbol %s twice\n", buff); + return (False); + } + if (def_const(pi, buff, i)==False) + return (False); } else { /* Pass 2 */ int j; - if(get_constant(pi, buff, &j)==False) { /* Defined in Pass 1 and now missing ? */ + if (get_constant(pi, buff, &j)==False) { /* Defined in Pass 1 and now missing ? */ fprintf(stderr,"Constant %s is missing in pass 2\n",buff); - return(False); + return (False); } - if(i != j) { + if (i != j) { fprintf(stderr,"Constant %s changed value from %d in pass1 to %d in pass 2\n",buff,j,i); - return(False); + return (False); } - /* OK. Definition is unchanged */ + /* OK. Definition is unchanged */ } } - return(True); + return (True); } -/****************************************** - * prog_info - ******************************************/ -struct prog_info *get_pi(struct args *args) { - struct prog_info *pi; +void +rewind_segments(struct prog_info *pi) +{ + pi->cseg->addr = pi->cseg->lo_addr; + pi->dseg->addr = pi->dseg->lo_addr; + pi->eseg->addr = pi->eseg->lo_addr; +} + +void +init_segment_size(struct prog_info *pi, struct device *device) +{ + pi->cseg->hi_addr = device->flash_size; + pi->cseg->cellsize = 2; + + pi->dseg->lo_addr = device->ram_start; + pi->dseg->hi_addr = device->ram_size+device->ram_start; + pi->dseg->cellsize = 1; + + pi->eseg->hi_addr = device->eeprom_size; + pi->eseg->cellsize = 1; + rewind_segments(pi); +} + + +struct prog_info * +init_prog_info(struct prog_info *pi, struct args *args) +{ struct data_list *warnings; - pi = (struct prog_info *)calloc(1, sizeof(struct prog_info)); - if(!pi) - return(NULL); memset(pi, 0, sizeof(struct prog_info)); pi->args = args; pi->device = get_device(pi,NULL); - if(GET_ARG(args, ARG_LISTFILE) == NULL) { + if (GET_ARG_P(args, ARG_LISTFILE) == NULL) { pi->list_on = False; } else { pi->list_on = True; } - if(GET_ARG(args, ARG_MAPFILE) == NULL) { + if (GET_ARG_P(args, ARG_MAPFILE) == NULL) { pi->map_on = False; } else { pi->map_on = True; } - for(warnings = GET_ARG(args, ARG_WARNINGS); warnings; warnings = warnings->next) { - if(!nocase_strcmp(warnings->data, "NoRegDef")) + for (warnings = GET_ARG_LIST(args, ARG_WARNINGS); warnings; warnings = warnings->next) { + if (!nocase_strcmp(warnings->data, "NoRegDef")) pi->NoRegDef = 1; } - pi->segment = SEGMENT_CODE; - pi->dseg_addr = pi->device->ram_start; - pi->max_errors = atoi(GET_ARG(args, ARG_MAX_ERRORS)); - pi->pass=PASS_1; /* B.A. : The pass variable is now stored in the pi struct */ - pi->time=time(NULL); /* B.A. : Now use a global timestamp */ - return(pi); -} - -void free_pi(struct prog_info *pi) { - free_defs(pi); /* B.A. : Now free in pi included structures first */ - free_labels(pi); - free_constants(pi); - free_variables(pi); - free_blacklist(pi); - free_orglist(pi); - free(pi); -} - -void prepare_second_pass(struct prog_info *pi) { - - pi->segment = SEGMENT_CODE; - pi->cseg_addr = 0; - pi->dseg_addr = pi->device->ram_start; - pi->eseg_addr = 0; - //pi->macro_nstlblnr = 0; - pi->pass=PASS_2; /* B.A. : Change to pass 2. Now stored in pi struct. */ - free_defs(pi); - // free_constants(pi); /* B.A. : Now don't kill stored constants. We need them in the second pass now */ - free_variables(pi); -} + pi->cseg = &CODE_SEG; + pi->dseg = &DATA_SEG; + pi->eseg = &EEPROM_SEG; + memset(pi->cseg, 0, sizeof(struct segment_info)); + memset(pi->dseg, 0, sizeof(struct segment_info)); + memset(pi->eseg, 0, sizeof(struct segment_info)); + + pi->cseg->name = "code"; + pi->dseg->name = "data"; + pi->eseg->name = "EEPROM"; + pi->cseg->ident = 'C'; + pi->dseg->ident = 'D'; + pi->eseg->ident = 'E'; + + pi->dseg->flags = SEG_BSS_DATA; + + pi->cseg->cellname = "word"; + pi->dseg->cellname = "byte"; + pi->eseg->cellname = "byte"; + pi->cseg->cellnames = "words"; + pi->dseg->cellnames = "bytes"; + pi->eseg->cellnames = "bytes"; + + init_segment_size(pi, pi->device); + + pi->cseg->pi = pi; + pi->dseg->pi = pi; + pi->eseg->pi = pi; + + pi->segment = pi->cseg; + + pi->max_errors = GET_ARG_I(args, ARG_MAX_ERRORS); + pi->pass=PASS_1; + pi->time=time(NULL); + pi->effective_overlap = GET_ARG_I(pi->args, ARG_OVERLAP); + pi->segment_overlap = SEG_DONT_OVERLAP; + return (pi); +} + +void +free_pi(struct prog_info *pi) +{ + free_defs(pi); + free_labels(pi); + free_constants(pi); + free_variables(pi); + free_ifdef_blacklist(pi); + free_ifndef_blacklist(pi); + free_orglist(pi); +} + +void +advance_ip(struct segment_info *si, int offset) +{ + si->addr += offset; + if (si->pi->pass == PASS_1) + si->count += offset; +} -void print_msg(struct prog_info *pi, int type, char *fmt, ... ) +void +print_msg(struct prog_info *pi, int type, char *fmt, ...) { char *pc; - if(type == MSGTYPE_OUT_OF_MEM) { + if (type == MSGTYPE_OUT_OF_MEM) { fprintf(stderr, "Error: Unable to allocate memory!\n"); } else { - if(type != MSGTYPE_APPEND) { /* B.A. Added for .message directive */ - if((pi->fi != NULL) && (pi->fi->include_file->name != NULL)) { /* B.A.: Skip, if filename or fi is NULL (Bug 1462900) */ - /* check if adding path name is needed*/ + if (type != MSGTYPE_APPEND) { + if ((pi->fi != NULL) && (pi->fi->include_file->name != NULL)) { + /* check if adding path name is needed */ pc = strstr(pi->fi->include_file->name, pi->root_path); - if(pc == NULL) { - fprintf(stderr, "%s%s(%d) : ", pi->root_path ,pi->fi->include_file->name, pi->fi->line_number); + if (pc == NULL) { + fprintf(stderr, "%s%s(%d) : ", pi->root_path,pi->fi->include_file->name, pi->fi->line_number); } else { fprintf(stderr, "%s(%d) : ", pi->fi->include_file->name, pi->fi->line_number); } } } - switch(type) { - case MSGTYPE_ERROR: - pi->error_count++; - fprintf(stderr, "Error : "); - break; - case MSGTYPE_WARNING: - pi->warning_count++; - fprintf(stderr, "Warning : "); - break; - case MSGTYPE_MESSAGE: -/* case MSGTYPE_MESSAGE_NO_LF: - case MSGTYPE_APPEND: */ - break; + switch (type) { + case MSGTYPE_ERROR: + pi->error_count++; + fprintf(stderr, "Error : "); + break; + case MSGTYPE_WARNING: + pi->warning_count++; + fprintf(stderr, "Warning : "); + break; + case MSGTYPE_MESSAGE: + /* case MSGTYPE_MESSAGE_NO_LF: + case MSGTYPE_APPEND: */ + break; } - if(type != MSGTYPE_APPEND) { /* B.A. Added for .message directive */ - if(pi->macro_call) { + if (type != MSGTYPE_APPEND) { + if (pi->macro_call) { fprintf(stderr, "[Macro: %s: %d:] ", pi->macro_call->macro->include_file->name, - pi->macro_call->line_index + pi->macro_call->macro->first_line_number); + pi->macro_call->line_index + pi->macro_call->macro->first_line_number); } } - if(fmt != NULL) { - va_list args; - va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); - } + if (fmt != NULL) { + va_list args; + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + } - if( (type != MSGTYPE_APPEND) && (type != MSGTYPE_MESSAGE_NO_LF) ) /* B.A. Added for .message directive */ + if ((type != MSGTYPE_APPEND) && (type != MSGTYPE_MESSAGE_NO_LF)) fprintf(stderr, "\n"); } } -/* B.A. : New functions to create / search / remove constant, variables, labels */ -/* def_const, def_var moved from device.c to this place */ -int def_const(struct prog_info *pi, const char *name, int value) -{ - struct label *label; - label = malloc(sizeof(struct label)); - if(!label) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - label->next = NULL; - if(pi->last_constant) - pi->last_constant->next = label; - else - pi->first_constant = label; - pi->last_constant = label; - label->name = malloc(strlen(name) + 1); - if(!label->name) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(label->name, name); - label->value = value; - return(True); -} - -int def_var(struct prog_info *pi, char *name, int value) -{ - struct label *label; - - for(label = pi->first_variable; label; label = label->next) - if(!nocase_strcmp(label->name, name)) { - label->value = value; - return(True); - } - label = malloc(sizeof(struct label)); - if(!label) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - label->next = NULL; - if(pi->last_variable) - pi->last_variable->next = label; - else - pi->first_variable = label; - pi->last_variable = label; - label->name = malloc(strlen(name) + 1); - if(!label->name) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(label->name, name); - label->value = value; - return(True); -} - - -int def_blacklist(struct prog_info *pi, const char *name) -{ - struct label *label; - label = malloc(sizeof(struct label)); - if(!label) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - label->next = NULL; - if(pi->last_blacklist) - pi->last_blacklist->next = label; - else - pi->first_blacklist = label; - pi->last_blacklist = label; - label->name = malloc(strlen(name) + 1); - if(!label->name) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(label->name, name); - label->value = 0; - return(True); -} - -/* B.A.: Store programmed areas for later check */ -int def_orglist(struct prog_info *pi) -{ +int +def_const(struct prog_info *pi, const char *name, int value) +{ + struct label *label; + label = malloc(sizeof(struct label)); + if (!label) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + label->next = NULL; + if (pi->last_constant) + pi->last_constant->next = label; + else + pi->first_constant = label; + pi->last_constant = label; + label->name = malloc(strlen(name) + 1); + if (!label->name) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(label->name, name); + label->value = value; + return (True); +} + +int +def_var(struct prog_info *pi, char *name, int value) +{ + struct label *label; + + for (label = pi->first_variable; label; label = label->next) + if (!nocase_strcmp(label->name, name)) { + label->value = value; + return (True); + } + label = malloc(sizeof(struct label)); + if (!label) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + label->next = NULL; + if (pi->last_variable) + pi->last_variable->next = label; + else + pi->first_variable = label; + pi->last_variable = label; + label->name = malloc(strlen(name) + 1); + if (!label->name) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(label->name, name); + label->value = value; + return (True); +} + +/* Store programmed areas for later check */ +int +def_orglist(struct segment_info *si) +{ struct orglist *orglist; - if(pi->pass != PASS_1) - return(True); - orglist = malloc(sizeof(struct orglist)); - if(!orglist) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - orglist->next = NULL; - if(pi->last_orglist) - pi->last_orglist->next = orglist; - else - pi->first_orglist = orglist; - pi->last_orglist = orglist; - orglist->segment=pi->segment; - switch(pi->segment) { - case SEGMENT_CODE: - orglist->start = pi->cseg_addr; - break; - case SEGMENT_DATA: - orglist->start = pi->dseg_addr; - break; - case SEGMENT_EEPROM: - orglist->start = pi->eseg_addr; - } - orglist->length=0; - return(True); -} - -/* B.A.: Fill length entry of last orglist */ -int fix_orglist(struct prog_info *pi) -{ - if(pi->pass != PASS_1) - return(True); - if((pi->last_orglist == NULL) || (pi->last_orglist->length!=0)) { - fprintf(stderr,"Internal Error: fix_orglist\n"); - return(False); - } - pi->last_orglist->segment=pi->segment; - switch(pi->segment) { - case SEGMENT_CODE: - pi->last_orglist->length = pi->cseg_addr - pi->last_orglist->start; - break; - case SEGMENT_DATA: - pi->last_orglist->length = pi->dseg_addr - pi->last_orglist->start; - break; - case SEGMENT_EEPROM: - pi->last_orglist->length = pi->eseg_addr - pi->last_orglist->start; + + si->pi->segment = si; + if (si->pi->pass != PASS_1) + return (True); + orglist = malloc(sizeof(struct orglist)); + if (!orglist) { + print_msg(si->pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + orglist->next = NULL; + if (si->last_orglist) + si->last_orglist->next = orglist; + else + si->first_orglist = orglist; + si->last_orglist = orglist; + orglist->segment = si; + orglist->start = si->addr; + orglist->length = 0; + orglist->segment_overlap = si->pi->segment_overlap; + return True; +} + +/* Fill length entry of last orglist */ +int +fix_orglist(struct segment_info *si) +{ + if (si->pi->pass != PASS_1) + return (True); + if ((si->last_orglist == NULL) || (si->last_orglist->length!=0)) { + fprintf(stderr,"Internal Error: fix_orglist\n"); + return (False); } - return(True); + si->last_orglist->segment = si; + si->last_orglist->length = si->addr - si->last_orglist->start; + return True; } -/* B.A.: Debug output of orglist */ -void print_orglist(struct prog_info *pi) -{ - struct orglist *orglist=pi->first_orglist; - printf("Used memory blocks:\n"); - while(orglist!=NULL) { - if(orglist->length) { /* Skip blocks with size == 0 */ - switch(orglist->segment) { - case SEGMENT_CODE: - printf(" Code "); break; - case SEGMENT_DATA: - printf(" Data "); break; - case SEGMENT_EEPROM: - printf(" EEPROM"); break; - printf("INVALID SEGMENT DATA !\n"); - } - printf(" : Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist->start,orglist->start+orglist->length-1,orglist->length); - } - orglist=orglist->next; +void +fprint_orglist(FILE *file, struct segment_info *si, struct orglist *orglist) +{ + fprintf(file, " %-6s : Start = 0x%04X, End = 0x%04X, Length = 0x%04X (%d %s), " + "Overlap=%c\n", + si->name, + orglist->start, + orglist->start + orglist->length - 1, + orglist->length, + orglist->length, + orglist->length == 1 ? si->cellname : si->cellnames, + orglist->segment_overlap == SEG_ALLOW_OVERLAP ? 'Y' : 'N'); +} + +void +fprint_seg_orglist(FILE *file, struct segment_info *si) +{ + struct orglist *orglist; + + for (orglist = si->first_orglist; + orglist != NULL; orglist = orglist->next) { + if (orglist->length > 0) + fprint_orglist(file, si, orglist); } } -/* B.A.: Test for overlapping segments and device space */ -int test_orglist(struct prog_info *pi) -{ - struct orglist *orglist2,*orglist=pi->first_orglist; +void +fprint_segments(FILE *file, struct prog_info *pi) +{ + fprintf(file, "Used memory blocks:\n"); + fprint_seg_orglist(file, pi->cseg); + fprint_seg_orglist(file, pi->dseg); + fprint_seg_orglist(file, pi->eseg); +} + +/* Test for overlapping segments and device space */ +int +test_orglist(struct segment_info *si) +{ + struct orglist *orglist, *orglist2; + int error_count=0; - if(pi->device->name==NULL) { + if (si->pi->device->name == NULL) { fprintf(stderr,"Warning : No .DEVICE definition found. Cannot make useful address range check !\n"); - pi->warning_count++; + si->pi->warning_count++; } - while(orglist!=NULL) { - if(orglist->length) { /* Skip blocks with size == 0 */ - // printf("Segment %d, Start = %5d, Length = %5d\n",orglist->segment,orglist->start,orglist->length); + + for (orglist = si->first_orglist; + orglist != NULL; + orglist=orglist->next) { + if (orglist->length > 0) { /* Make sure address area is valid */ - switch(orglist->segment) { - case SEGMENT_CODE: - if((orglist->start + orglist->length) > pi->device->flash_size) { - fprintf(stderr,"Code segment exceeds valid address range [0..0x%04X] :", - pi->device->flash_size-1); - fprintf(stderr," Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist->start,orglist->start+orglist->length-1,orglist->length); - error_count++; - } - break; - case SEGMENT_DATA: - if(pi->device->ram_size == 0) { - // Error message is generated in .DSEG directive. Skip ... - // fprintf(stderr,"This device has no RAM. Don't use .DSEG \n"); - // error_count++; - break; - } // Fix bug 1742436. Added missing pi->device->ram_start - if(((orglist->start + orglist->length) > (pi->device->ram_size + pi->device->ram_start)) || - (orglist->start < pi->device->ram_start)) { - fprintf(stderr,"Data segment exceeds valid address range [0x%04X..0x%04X] :", - pi->device->ram_start,pi->device->ram_start+pi->device->ram_size-1); - fprintf(stderr," Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist->start,orglist->start+orglist->length-1,orglist->length); - error_count++; - } - break; - case SEGMENT_EEPROM: // Fix bug 1742437 : replace ram_size by eeprom_size - if(pi->device->eeprom_size == 0) { - // Error message is generated in .ESEG directive. Skip ... - // fprintf(stderr,"This device has no EEPROM. Don't use .ESEG !\n"); - // error_count++; - break; - } - if((orglist->start + orglist->length) > pi->device->eeprom_size) { - fprintf(stderr,"EEPROM segment exceeds valid address range [0..0x%04X] :", - pi->device->eeprom_size-1); - fprintf(stderr," Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist->start,orglist->start+orglist->length-1,orglist->length); - error_count++; - } - break; + if (orglist->start < si->lo_addr) { + fprintf(stderr, "Segment start below allowed start address: 0x%04lX", + si->lo_addr); + fprint_orglist(stderr, si, orglist); + error_count ++; } + if (orglist->start + orglist->length > si->hi_addr) { + fprintf(stderr, "Segment start above allowed high address: 0x%04lX", + si->hi_addr); + fprint_orglist(stderr, si, orglist); + error_count ++; + } + /* Overlap-test */ - orglist2=orglist->next; - while(orglist2!=NULL) { - if((orglist != orglist2) && (orglist2->length) && (orglist->segment == orglist2->segment)) { - // printf("<> Segment %d, Start = %5d, Length = %5d\n",orglist2->segment,orglist2->start,orglist2->length); - if((orglist->start < (orglist2->start + orglist2->length)) && - (orglist2->start < ( orglist->start + orglist->length))) { - fprintf(stderr,"Error: Overlapping "); - switch(orglist->segment) { - case SEGMENT_CODE: - fprintf(stderr,"Code"); break; - case SEGMENT_DATA: - fprintf(stderr,"Data"); break; - case SEGMENT_EEPROM: - fprintf(stderr,"EEPROM"); break; + if ((si->pi->effective_overlap != OVERLAP_IGNORE) && + (orglist->segment_overlap == SEG_DONT_OVERLAP)) { + for (orglist2 = orglist->next; orglist2 != NULL; orglist2 = orglist2->next) { + if ((orglist != orglist2) && (orglist2->length > 0) + && (orglist2->segment_overlap == SEG_DONT_OVERLAP)) { + + if ((orglist->start < (orglist2->start + orglist2->length)) && + (orglist2->start < (orglist->start + orglist->length))) { + fprintf(stderr,"%s: Overlapping %s segments:\n", + si->pi->effective_overlap == OVERLAP_ERROR ? "Error" : "Warning", + si->name); + fprint_orglist(stderr, si, orglist); + fprint_orglist(stderr, si, orglist2); + fprintf(stderr,"Please check your .ORG directives !\n"); + if (si->pi->effective_overlap == OVERLAP_ERROR) + error_count++; + else + si->pi->warning_count++; } - fprintf(stderr,"-segments :\n"); - fprintf(stderr," Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist->start,orglist->start+orglist->length-1,orglist->length); - fprintf(stderr," Start = 0x%04X, End = 0x%04X, Length = 0x%04X\n", - orglist2->start,orglist2->start+orglist2->length-1,orglist2->length); - fprintf(stderr,"Please check your .ORG directives !\n"); - error_count++; } - } - orglist2=orglist2->next; - } + } + } /* Overlap-test */ } - orglist=orglist->next; } - if(!error_count) - return(True); - pi->error_count+=error_count; - return(False); -} - - + si->pi->error_count += error_count; + return (error_count > 0 ? False : True); +} /* Get the value of a label. Return FALSE if label was not found */ -int get_label(struct prog_info *pi,char *name,int *value) +int +get_label(struct prog_info *pi,char *name,int *value) { - struct label *label=search_symbol(pi,pi->first_label,name,NULL); - if(label==NULL) return False; - if(value!=NULL) *value=label->value; + struct label *label=search_symbol(pi,pi->first_label,name,NULL); + if (label==NULL) return False; + if (value!=NULL) *value=label->value; return True; } -int get_constant(struct prog_info *pi,char *name,int *value) +int +get_constant(struct prog_info *pi,char *name,int *value) { - struct label *label=search_symbol(pi,pi->first_constant,name,NULL); - if(label==NULL) return False; - if(value!=NULL) *value=label->value; + struct label *label=search_symbol(pi,pi->first_constant,name,NULL); + if (label==NULL) return False; + if (value!=NULL) *value=label->value; return True; } -int get_variable(struct prog_info *pi,char *name,int *value) +int +get_variable(struct prog_info *pi,char *name,int *value) { - struct label *label=search_symbol(pi,pi->first_variable,name,NULL); - if(label==NULL) return False; - if(value!=NULL) *value=label->value; + struct label *label=search_symbol(pi,pi->first_variable,name,NULL); + if (label==NULL) return False; + if (value!=NULL) *value=label->value; return True; } @@ -696,103 +698,181 @@ return search_symbol(pi,pi->first_variable,name,message); } -struct label *test_blacklist(struct prog_info *pi,char *name,char *message) -{ - return search_symbol(pi,pi->first_blacklist,name,message); -} - /* Search in label,constant,variable,blacklist - list for a matching entry */ /* Use first = pi->first_label,first_constant,first_variable,first_blacklist to select list */ /* If message != NULL Print error message if symbol is defined */ struct label *search_symbol(struct prog_info *pi,struct label *first,char *name,char *message) -{ +{ struct label *label; - for(label = first; label; label = label->next) - if(!nocase_strcmp(label->name, name)) { - if(message) { - print_msg(pi, MSGTYPE_ERROR, message, name); + for (label = first; label; label = label->next) + if (!nocase_strcmp(label->name, name)) { + if (message) { + print_msg(pi, MSGTYPE_ERROR, message, name); } - return(label); + return (label); + } + return (NULL); +} + +int +ifdef_blacklist(struct prog_info *pi) +{ + struct location *loc; + loc = malloc(sizeof(struct location)); + if (!loc) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return False; + } + loc->next = NULL; + if (pi->last_ifdef_blacklist) { + pi->last_ifdef_blacklist->next = loc; + } else { + pi->first_ifdef_blacklist = loc; + } + pi->last_ifdef_blacklist = loc; + loc->line_num = pi->fi->line_number; + loc->file_num = pi->fi->include_file->num; + return True; +} + +int +ifndef_blacklist(struct prog_info *pi) +{ + struct location *loc; + loc = malloc(sizeof(struct location)); + if (!loc) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return False; + } + loc->next = NULL; + if (pi->last_ifndef_blacklist) { + pi->last_ifndef_blacklist->next = loc; + } else { + pi->first_ifndef_blacklist = loc; + } + pi->last_ifndef_blacklist = loc; + loc->line_num = pi->fi->line_number; + loc->file_num = pi->fi->include_file->num; + return True; +} + +int +ifdef_is_blacklisted(struct prog_info *pi) +{ + return search_location(pi->first_ifdef_blacklist, pi->fi->line_number, pi->fi->include_file->num); +} + +int +ifndef_is_blacklisted(struct prog_info *pi) +{ + return search_location(pi->first_ifndef_blacklist, pi->fi->line_number, pi->fi->include_file->num); +} + +int +search_location(struct location *first, int line_num, int file_num) +{ + struct location *loc; + for (loc = first; loc; loc = loc->next) { + if (loc->line_num == line_num && loc->file_num == file_num) { + return True; } - return(NULL); + } + return False; +} + +void +free_defs(struct prog_info *pi) +{ + struct def *def, *temp_def; + for (def = pi->first_def; def;) { + temp_def = def; + def = def->next; + free(temp_def->name); + free(temp_def); + } + pi->first_def = NULL; + pi->last_def = NULL; +} + +void +free_labels(struct prog_info *pi) +{ + struct label *label, *temp_label; + for (label = pi->first_label; label;) { + temp_label = label; + label = label->next; + free(temp_label->name); + free(temp_label); + } + pi->first_label = NULL; + pi->last_label = NULL; +} + +void +free_constants(struct prog_info *pi) +{ + struct label *label, *temp_label; + for (label = pi->first_constant; label;) { + temp_label = label; + label = label->next; + free(temp_label->name); + free(temp_label); + } + pi->first_constant = NULL; + pi->last_constant = NULL; } +void +free_ifdef_blacklist(struct prog_info *pi) +{ + struct location *loc, *temp_loc; + for (loc = pi->first_ifdef_blacklist; loc;) { + temp_loc = loc; + loc = loc->next; + free(temp_loc); + } + pi->first_ifdef_blacklist = NULL; + pi->last_ifdef_blacklist = NULL; +} -void free_defs(struct prog_info *pi) +void +free_ifndef_blacklist(struct prog_info *pi) { - struct def *def, *temp_def; - for(def = pi->first_def; def;) { - temp_def = def; - def = def->next; - free(temp_def->name); - free(temp_def); - } - pi->first_def = NULL; - pi->last_def = NULL; -} - -void free_labels(struct prog_info *pi) -{ - struct label *label, *temp_label; - for(label = pi->first_label; label;) { - temp_label = label; - label = label->next; - free(temp_label->name); - free(temp_label); - } - pi->first_label = NULL; - pi->last_label = NULL; -} - -void free_constants(struct prog_info *pi) -{ - struct label *label, *temp_label; - for(label = pi->first_constant; label;) { - temp_label = label; - label = label->next; - free(temp_label->name); - free(temp_label); - } - pi->first_constant = NULL; - pi->last_constant = NULL; -} - -void free_blacklist(struct prog_info *pi) -{ - struct label *label, *temp_label; - for(label = pi->first_blacklist; label;) { - temp_label = label; - label = label->next; - free(temp_label->name); - free(temp_label); - } - pi->first_blacklist = NULL; - pi->last_blacklist = NULL; -} - -void free_variables(struct prog_info *pi) -{ - struct label *label, *temp_label; - for(label = pi->first_variable; label;) { - temp_label = label; - label = label->next; - free(temp_label->name); - free(temp_label); - } - pi->first_variable = NULL; - pi->last_variable = NULL; -} - -void free_orglist(struct prog_info *pi) -{ - struct orglist *orglist, *temp_orglist; - for(orglist = pi->first_orglist; orglist;) { - temp_orglist = orglist; - orglist = orglist->next; - free(temp_orglist); - } - pi->first_orglist = NULL; - pi->last_orglist = NULL; + struct location *loc, *temp_loc; + for (loc = pi->first_ifndef_blacklist; loc;) { + temp_loc = loc; + loc = loc->next; + free(temp_loc); + } + pi->first_ifndef_blacklist = NULL; + pi->last_ifndef_blacklist = NULL; +} + +void +free_variables(struct prog_info *pi) +{ + struct label *label, *temp_label; + for (label = pi->first_variable; label;) { + temp_label = label; + label = label->next; + free(temp_label->name); + free(temp_label); + } + pi->first_variable = NULL; + pi->last_variable = NULL; +} + +void +free_orglist(struct prog_info *pi) +{ + struct orglist *orglist, *temp_orglist; + for (orglist = pi->first_orglist; orglist;) { + temp_orglist = orglist; + orglist = orglist->next; + free(temp_orglist); + } + pi->first_orglist = NULL; + pi->last_orglist = NULL; } diff -Nru avra-1.3.0/src/avra.h avra-1.4.2+dfsg/src/avra.h --- avra-1.3.0/src/avra.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/avra.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2006 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,40 +20,24 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ -#ifndef _AVRA_H_ /* avoid multiple inclusion */ +#ifndef _AVRA_H_ #define _AVRA_H_ #include #include -#ifndef VER_MAJOR -# define VER_MAJOR 1 -#endif -#ifndef VER_MINOR -# define VER_MINOR 3 -#endif -#ifndef VER_RELEASE -# define VER_RELEASE 0 -#endif -#ifndef VER_BUILD -# define VER_BUILD 1 -#endif -#ifndef VER_DATE -# define VER_DATE "8 May 2010" -#endif - #define IS_HOR_SPACE(x) ((x == ' ') || (x == 9)) #define IS_LABEL(x) (isalnum(x) || (x == '%') || (x == '_')) #define IS_END_OR_COMMENT(x) ((x == ';') || (x == 10) || (x == 13) || (x == '\0') || (x == 12)) #define IS_ENDLINE(x) ((x == 10) || (x == 13) || (x == '\0') || (x == 12)) #define IS_SEPARATOR(x) ((x == ' ') || (x == ',') || (x == '[') || (x == ']')) -#define LINEBUFFER_LENGTH 256 +#define LINEBUFFER_LENGTH 4096 #define MAX_NESTED_MACROLOOPS 256 #define MAX_MACRO_ARGS 10 @@ -78,6 +62,7 @@ ARG_MAPFILE, /* --mapfile */ ARG_DEBUGFILE, /* --debugfile */ ARG_EEPFILE, /* --eepfile */ + ARG_OVERLAP, /* -O [w|e|i] */ ARG_COUNT }; @@ -86,9 +71,8 @@ MSGTYPE_WARNING, MSGTYPE_MESSAGE, MSGTYPE_OUT_OF_MEM, - MSGTYPE_MESSAGE_NO_LF, /* B.A. : Like MSGTYPE_MESSAGE, but without /n */ - MSGTYPE_APPEND /* B.A. : Print Message without any header and without /n. To append messages */ - /* MSGTYPE_INCLUDE B.A. Removed. Was not in used */ + MSGTYPE_MESSAGE_NO_LF, /* Like MSGTYPE_MESSAGE, but without /n */ + MSGTYPE_APPEND /* Print Message without any header and without /n. To append messages */ }; enum { @@ -103,6 +87,19 @@ }; enum { + OVERLAP_UNDEFINED = -1, + OVERLAP_DEFAULT = 0, + OVERLAP_IGNORE, + OVERLAP_WARNING, + OVERLAP_ERROR +}; + +enum { + SEG_DONT_OVERLAP = 0, + SEG_ALLOW_OVERLAP +}; + +enum { TERM_END = 0, TERM_SPACE, TERM_COMMA, @@ -114,8 +111,30 @@ /* Structures */ -struct prog_info -{ +struct prog_info; + +extern const int SEG_BSS_DATA; + +struct segment_info { + const char *name; + char ident; /* C, D, E */ + long addr; /* address in cells */ + long count; /* length in cells */ + long lo_addr; /* lowest addr supported */ + long hi_addr; /* one past highest addr supported */ + int cellsize; /* 1 for data/eeprom, 2 for flash */ + int flags; /* SEG_BSS_DATA */ + + struct prog_info *pi; + struct hex_file_info *hfi; + struct orglist *first_orglist; + struct orglist *last_orglist; + + const char *cellname; /* byte / word */ + const char *cellnames; /* bytes / words */ +}; + +struct prog_info { struct args *args; struct device *device; struct file_info *fi; @@ -127,15 +146,10 @@ char *list_line; char *root_path; FILE *obj_file; - struct hex_file_info *hfi; - struct hex_file_info *eep_hfi; - int segment; - int cseg_addr; - int dseg_addr; - int eseg_addr; - int cseg_count; - int dseg_count; - int eseg_count; + struct segment_info *segment; + struct segment_info *cseg; + struct segment_info *dseg; + struct segment_info *eseg; int error_count; int max_errors; int warning_count; @@ -149,26 +163,28 @@ struct label *last_constant; struct label *first_variable; struct label *last_variable; - struct label *first_blacklist; /* B.A. : List for undefined symbols. Needed to make forward references safe */ - struct label *last_blacklist; + struct location *first_ifdef_blacklist; + struct location *last_ifdef_blacklist; + struct location *first_ifndef_blacklist; + struct location *last_ifndef_blacklist; struct macro *first_macro; struct macro *last_macro; struct macro_call *first_macro_call; struct macro_call *last_macro_call; - struct orglist *first_orglist; /* B.A. : List of used memory segments. Needed for overlap-check */ + struct orglist *first_orglist; /* List of used memory segments. Needed for overlap-check */ struct orglist *last_orglist; + int effective_overlap; /* as specified by #pragma overlap */ + int segment_overlap; /* set by .NOOVERLAP, .OVERLAP */ int conditional_depth; - time_t time; /* B.A. : Use a global timestamp for listing header and %hour% ... tags */ + time_t time; /* Use a global timestamp for listing header and %hour% ... tags */ /* coff additions */ FILE *coff_file; /* Warning additions */ int NoRegDef; int pass; - }; -struct file_info -{ +struct file_info { FILE *fp; struct include_file *include_file; char buff[LINEBUFFER_LENGTH]; @@ -178,8 +194,7 @@ struct label *label; }; -struct hex_file_info -{ +struct hex_file_info { FILE *fp; int count; int linestart_addr; @@ -187,29 +202,25 @@ unsigned char hex_line[16]; }; -struct include_file -{ +struct include_file { struct include_file *next; char *name; int num; }; -struct def -{ +struct def { struct def *next; char *name; int reg; }; -struct label -{ +struct label { struct label *next; char *name; int value; }; -struct macro -{ +struct macro { struct macro *next; char *name; struct include_file *include_file; @@ -218,21 +229,20 @@ struct macro_label *first_label; }; -struct macro_label -{ +struct macro_label { char *label; struct macro_label *next; int running_number; + int flags; }; +extern const int ML_DEFINED; -struct macro_line -{ +struct macro_line { struct macro_line *next; char *line; }; -struct macro_call -{ +struct macro_call { struct macro_call *next; int line_number; struct include_file *include_file; @@ -245,67 +255,75 @@ struct label *last_label; }; -struct orglist -{ +struct orglist { struct orglist *next; - int segment; + struct segment_info *segment; int start; int length; + int segment_overlap; +}; + +struct location { + struct location *next; + int line_num; + int file_num; }; /* Prototypes */ /* avra.c */ int assemble(struct prog_info *pi); int load_arg_defines(struct prog_info *pi); -struct prog_info *get_pi(struct args *args); +struct prog_info *init_prog_info(struct prog_info *,struct args *args); void free_pi(struct prog_info *pi); -void prepare_second_pass(struct prog_info *pi); -void print_msg(struct prog_info *pi, int type, char *fmt, ... ); +void print_msg(struct prog_info *pi, int type, char *fmt, ...); void get_rootpath(struct prog_info *pi, struct args *args); +void init_segment_size(struct prog_info *pi, struct device *device); +void rewind_segments(struct prog_info *pi); +void advance_ip(struct segment_info *si, int offset); + int def_const(struct prog_info *pi, const char *name, int value); int def_var(struct prog_info *pi, char *name, int value); -int def_blacklist(struct prog_info *pi, const char *name); -int def_orglist(struct prog_info *pi); /* B.A. : Test for overlapping segments */ -int fix_orglist(struct prog_info *pi); -void print_orglist(struct prog_info *pi); -int test_orglist(struct prog_info *pi); +int def_orglist(struct segment_info *si); +int fix_orglist(struct segment_info *si); +void fprint_orglist(FILE *file, struct segment_info *si, struct orglist *orglist); +void fprint_sef_orglist(FILE *file, struct segment_info *si); +void fprint_segments(FILE *file, struct prog_info *pi); +int test_orglist(struct segment_info *si); int get_label(struct prog_info *pi,char *name,int *value); int get_constant(struct prog_info *pi,char *name,int *value); int get_variable(struct prog_info *pi,char *name,int *value); struct label *test_label(struct prog_info *pi,char *name,char *message); struct label *test_constant(struct prog_info *pi,char *name,char *message); struct label *test_variable(struct prog_info *pi,char *name,char *message); -struct label *test_blacklist(struct prog_info *pi,char *name,char *message); struct label *search_symbol(struct prog_info *pi,struct label *first,char *name,char *message); +int ifdef_blacklist(struct prog_info *pi); +int ifndef_blacklist(struct prog_info *pi); +int ifdef_is_blacklisted(struct prog_info *pi); +int ifndef_is_blacklisted(struct prog_info *pi); +int search_location(struct location *first, int line_num, int file_num); void free_defs(struct prog_info *pi); void free_labels(struct prog_info *pi); void free_constants(struct prog_info *pi); -void free_blacklist(struct prog_info *pi); +void free_ifdef_blacklist(struct prog_info *pi); +void free_ifndef_blacklist(struct prog_info *pi); void free_variables(struct prog_info *pi); void free_orglist(struct prog_info *pi); - /* parser.c */ -int parse_file(struct prog_info *pi, char *filename); +int parse_file(struct prog_info *pi, const char *filename); int parse_line(struct prog_info *pi, char *line); char *get_next_token(char *scratch, int term); char *fgets_new(struct prog_info *pi, char *s, int size, FILE *stream); /* expr.c */ int get_expr(struct prog_info *pi, char *data, int *value); -//int get_operator(char *op); -//int test_operator_at_precedence(int operator, int precedence); -//int calc(struct prog_info *pi, int left, int operator, int right); -//int get_function(char *function); -//int do_function(int function, int value); -//int log2(int value); int get_symbol(struct prog_info *pi, char *label_name, int *data); int par_length(char *data); /* mnemonic.c */ int parse_mnemonic(struct prog_info *pi); -int get_mnemonic_type(char *mnemonic); +int get_mnemonic_type(struct prog_info *pi); int get_register(struct prog_info *pi, char *data); int get_bitnum(struct prog_info *pi, char *data, int *ret); int get_indirect(struct prog_info *pi, char *operand); @@ -314,7 +332,7 @@ /* directiv.c */ int parse_directive(struct prog_info *pi); -int get_directive_type(char *directive); +int lookup_keyword(const char *const keyword_list[], const char *const keyword, int strict); char *term_string(struct prog_info *pi, char *string); int parse_db(struct prog_info *pi, char *next); void write_db(struct prog_info *pi, char byte, char *prev, int count); @@ -330,24 +348,25 @@ /* file.c */ -int open_out_files(struct prog_info *pi, char *filename); +int open_out_files(struct prog_info *pi, const char *basename, const char *outputfile, + const char *debugfile, const char *eepfile); void close_out_files(struct prog_info *pi); -struct hex_file_info *open_hex_file(char *filename); +struct hex_file_info *open_hex_file(const char *filename); void close_hex_file(struct hex_file_info *hfi); void write_ee_byte(struct prog_info *pi, int address, unsigned char data); void write_prog_word(struct prog_info *pi, int address, int data); void do_hex_line(struct hex_file_info *hfi); -FILE *open_obj_file(struct prog_info *pi, char *filename); +FILE *open_obj_file(struct prog_info *pi, const char *filename); void close_obj_file(struct prog_info *pi, FILE *fp); void write_obj_record(struct prog_info *pi, int address, int data); -void unlink_out_files(struct prog_info *pi, char *filename); +void unlink_out_files(struct prog_info *pi, const char *filename); /* map.c */ void write_map_file(struct prog_info *pi); char *Space(char *n); /* stdextra.c */ -char *nocase_strcmp(char *s, char *t); +char *nocase_strcmp(const char *s, const char *t); char *nocase_strncmp(char *s, char *t, int n); char *nocase_strstr(char *s, char *t); int atox(char *s); @@ -355,15 +374,16 @@ int atox_n(char *s, int n); char *my_strlwr(char *in); char *my_strupr(char *in); +char *snprint_list(char *buf, size_t limit, const char *const list[]); /* coff.c */ FILE *open_coff_file(struct prog_info *pi, char *filename); void write_coff_file(struct prog_info *pi); -void write_coff_eeprom( struct prog_info *pi, int address, unsigned char data); -void write_coff_program( struct prog_info *pi, int address, unsigned int data); +void write_coff_eeprom(struct prog_info *pi, int address, unsigned char data); +void write_coff_program(struct prog_info *pi, int address, unsigned int data); void close_coff_file(struct prog_info *pi, FILE *fp); -int parse_stabs( struct prog_info *pi, char *p ); -int parse_stabn( struct prog_info *pi, char *p ); +int parse_stabs(struct prog_info *pi, char *p); +int parse_stabn(struct prog_info *pi, char *p); #endif /* end of avra.h */ diff -Nru avra-1.3.0/src/bootstrap avra-1.4.2+dfsg/src/bootstrap --- avra-1.3.0/src/bootstrap 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/bootstrap 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/bin/sh -# This script configures, compiles and installs avra using automake utilities -cp ../{AUTHORS,ChangeLog,NEWS,README} . -aclocal -autoconf -automake -a -echo "Now you can run ./configure" diff -Nru avra-1.3.0/src/coff.c avra-1.4.2+dfsg/src/coff.c --- avra-1.3.0/src/coff.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/coff.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,29 +1,33 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * - * coff.c - Common Object File Format (COFF) support + * coff.c - Common Object File Format (COFF) support * - * This file was developed for the avra assembler in order to produce COFF output files - * for use with the Atmel AVR Studio. The Lean C Compiler (LCC) debugging stabs - * output was used as input to the assembler. The information used to develop this file - * was obtained from various sources on the Internet, most notably, the Free Software Foundation, - * The "stabs" debug format, ??? Chapter 7: Common Object File Format (COFF), + * This file was developed for the AVRA assembler in order to produce + * COFF output files for use with the Atmel AVR Studio. The Lean C + * Compiler (LCC) debugging stabs output was used as input to the + * assembler. The information used to develop this file was obtained + * from various sources on the Internet, most notably, the Free + * Software Foundation, The "stabs" debug format, ??? Chapter 7: + * Common Object File Format (COFF). + * + * This software has absolutely no warrantee! The money you paid for + * this will be promptly refunded if not fully satisfied. * - * This software has absolutely no warrantee! The money you paid for this will be - * promptly refunded if not fully satisfied. - * * Beta release 1/20/2000 by Bob Harris * - * This software has not been fully tested and probably has a few software deficiencies. - * Some software support may be possible by sending a problem description report to - * rth@mclean.sparta.com + * This software has not been fully tested and probably has a few + * software deficiencies. + * Some software support may be possible by sending a problem + * description report to rth@mclean.sparta.com * * Made the recommended change in write_coff_program(). - * Fixed an obvious typo in SkipPastDigits(). The if() statement was terminated - * with a semicolon, which terminated the if(); early. JEG 4-01-03 + * Fixed an obvious typo in SkipPastDigits(). The if() statement + * was terminated with a semicolon, which terminated the if(); early. + * JEG 4-01-03 */ #include @@ -37,2053 +41,2053 @@ #include "args.h" #include "coff.h" -#include "device.h" /* device flash and eeprom size */ +#include "device.h" struct FundamentalType { - char const *pString; - int Type; - int Size; + char const *pString; + int Type; + int Size; }; struct FundamentalType FundamentalTypes[] = { - {"null", T_NULL, 0}, - {"void", T_VOID, 0}, - {"char", T_CHAR, 1}, - {"short", T_SHORT, 1}, - {"int", T_INT, 1}, - {"long", T_LONG, 2}, - {"float", T_FLOAT, 4}, - {"double", T_DOUBLE, 4}, - {"struct", T_STRUCT, 0}, - {"union", T_UNION, 0}, - {"enum", T_ENUM, 0}, - {"moe", T_MOE, 0}, - {"unsigned char", T_UCHAR, 1}, - {"unsigned short", T_USHORT, 1}, - {"unsigned int", T_UINT, 1}, - {"unsigned long", T_ULONG, 2}, - {"long double", T_LNGDBL, 2}, - {"long long int", T_LONG, 2}, - {"long int", T_LONG, 2}, - {"unsigned long long", T_ULONG, 2}, - {"signed char", T_CHAR, 1}, - {0, 0} + {"null", T_NULL, 0}, + {"void", T_VOID, 0}, + {"char", T_CHAR, 1}, + {"short", T_SHORT, 1}, + {"int", T_INT, 1}, + {"long", T_LONG, 2}, + {"float", T_FLOAT, 4}, + {"double", T_DOUBLE, 4}, + {"struct", T_STRUCT, 0}, + {"union", T_UNION, 0}, + {"enum", T_ENUM, 0}, + {"moe", T_MOE, 0}, + {"unsigned char", T_UCHAR, 1}, + {"unsigned short", T_USHORT, 1}, + {"unsigned int", T_UINT, 1}, + {"unsigned long", T_ULONG, 2}, + {"long double", T_LNGDBL, 2}, + {"long long int", T_LONG, 2}, + {"long int", T_LONG, 2}, + {"unsigned long long", T_ULONG, 2}, + {"signed char", T_CHAR, 1}, + {0, 0} }; struct coff_info *ci; -/****************************************************************************************/ - -FILE *open_coff_file(struct prog_info *pi, char *filename){ - int ok /*, i*/; - FILE *fp; - //unsigned long *pu4; - char*p; - - - ci = calloc( 1, sizeof(struct coff_info) ); - if ( !ci ) - return( 0 ); - - ok = True; - /* default values */ - ci->CurrentFileNumber = 0; - ci->pRomMemory = 0; - ci->pEEPRomMemory = 0; - ci->MaxRomAddress = 0; - ci->MaxEepromAddress = 0; - ci->NeedLineNumberFixup = 0; - ci->GlobalStartAddress = -1; - ci->GlobalEndAddress = 0; - - /* Linked lists start out at zero */ - InitializeList( &ci->ListOfSectionHeaders ); - InitializeList( &ci->ListOfRawData ); - InitializeList( &ci->ListOfRelocations ); - InitializeList( &ci->ListOfLineNumbers ); - InitializeList( &ci->ListOfSymbols ); - InitializeList( &ci->ListOfGlobals ); - InitializeList( &ci->ListOfSpecials ); - InitializeList( &ci->ListOfUndefined ); - InitializeList( &ci->ListOfStrings ); - InitializeList( &ci->ListOfTypes ); - InitializeList( &ci->ListOfSplitLines ); - - /* add two default sections to SectionHeaders */ - if ( !AllocateListObject( &ci->ListOfSectionHeaders, sizeof(struct external_scnhdr) ) || - !AllocateListObject( &ci->ListOfSectionHeaders, sizeof(struct external_scnhdr) ) ) { - - fprintf(stderr, "\nOut of memory allocating section headers!"); - return( 0 ); - } - - /* add to string table */ - p = (char *)AllocateListObject( &ci->ListOfStrings, 4 ); - if ( !p ) { - fprintf(stderr, "\nOut of memory allocating string table space!"); - return( 0 ); - } - - /* Allocate space for binary output into ROM, and EEPROM memory buffers for COFF output */ - /* ASSUMES ci->device is accurate */ - if ( (ci->pRomMemory = AllocateListObject( &ci->ListOfRawData, pi->device->flash_size * 2 ) ) != 0) { - if ( (ci->pEEPRomMemory = AllocateListObject( &ci->ListOfRawData, pi->device->eeprom_size )) != 0) { - ok = True; /* only true if both buffers are properly allocated */ - /* now fill them with 0xff's to simulate flash erasure */ - memset( (void *)ci->pRomMemory, 0xff, pi->device->flash_size * 2 ); - memset( ( void *)ci->pEEPRomMemory, 0xff, pi->device->eeprom_size ); - } - } - if ( ok != True ) - return( 0 ); - - fp = fopen(filename,"wb"); - if ( fp == NULL ) { - fprintf(stderr,"Error: cannot write coff file\n"); - return( fp ); - } - /* simulate void type .stabs void:t15=r1;*/ - stab_add_local_type( "void", "15=r1;0;0;" ); - - return( fp ); -} - -/****************************************************************************************/ -void write_coff_file(struct prog_info *pi){ - - //FILE *fp; - //struct label *label; - char /* File[256],*/*p; - struct external_scnhdr *pSectionHdr; - struct syment *pEntry; - union auxent *pAux; - unsigned long *plong; - int NumberOfSymbols, SymbolIndex, LastFileIndex, LastFunctionIndex, LastFunctionAddress; - LISTNODE *pNode; - int LinesOffset, SymbolsOffset, StringsOffset, RawOffset; - struct lineno *pLine; - - /* add two special sections */ - /* one for .text */ - if ( ( pEntry = (struct syment*)AllocateTwoListObjects( &ci->ListOfSpecials, sizeof(struct syment) * 2 ) ) == 0 ) { - fprintf(stderr, "\nOut of memory allocating special headers for .text!"); - return; - } - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".text" ); - pEntry->n_value = 0; - pEntry->n_scnum = 1; - pEntry->n_type = 0; - pEntry->n_sclass = C_STAT; - pEntry->n_numaux = 1; - pEntry++; - pAux = (union auxent *)pEntry; - pAux->x_scn.x_scnlen = ci->MaxRomAddress + 2; - pAux->x_scn.x_nreloc = 0; - pAux->x_scn.x_nlinno = ci->ListOfLineNumbers.TotalItems; - /* one for .bss */ - if ( ( pEntry = (struct syment*)AllocateTwoListObjects( &ci->ListOfSpecials, sizeof(struct syment) * 2 ) ) == 0 ) { - fprintf(stderr, "\nOut of memory allocating special header for .bss!"); - return; - } - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".bss" ); - if ( ci->GlobalStartAddress == -1 ) { - ci->GlobalEndAddress = ci->GlobalStartAddress = 0x60; - } - pEntry->n_value = ci->GlobalStartAddress; - pEntry->n_scnum = 2; - pEntry->n_type = 0; - pEntry->n_sclass = C_STAT; - pEntry->n_numaux = 1; - pEntry++; - pAux = (union auxent *)pEntry; - pAux->x_scn.x_scnlen = 0; /* we don't store any data here */ - pAux->x_scn.x_nreloc = 0; - pAux->x_scn.x_nlinno = 0; - - /* one more for .data - eeprom ??? */ - - /* Calculate common offsets into the file */ - RawOffset = sizeof(struct external_filehdr) + ci->ListOfSectionHeaders.TotalBytes; - LinesOffset = RawOffset + ci->MaxRomAddress + 2; /* ignore eeprom for now */ - SymbolsOffset = LinesOffset + ci->ListOfLineNumbers.TotalBytes; - StringsOffset = SymbolsOffset + ci->ListOfSymbols.TotalBytes + ci->ListOfSpecials.TotalBytes + ci->ListOfGlobals.TotalBytes; - - /* Clean up loose ends in string table */ - if ( !(plong = (unsigned long *)FindFirstListObject(&ci->ListOfStrings)) ) { - fprintf(stderr,"\nInternal error in string table!"); - return; - } - *plong = ci->ListOfStrings.TotalBytes; /* Size of string table */ - - /* Clean up loose ends in symbol table */ - - /* symbol table - Filename value - index to next .file or global symbol */ - /* The value of that symbol equals the symbol table entry index of the next .file symbol or .global */ - LastFunctionAddress = ci->MaxRomAddress; - NumberOfSymbols = ci->ListOfSymbols.TotalItems + ci->ListOfSpecials.TotalItems + ci->ListOfGlobals.TotalItems; - SymbolIndex = LastFileIndex = NumberOfSymbols; - LastFunctionIndex = 0; /* set to zero on last function */ - for ( pEntry = (struct syment *)FindLastListObject(&ci->ListOfSymbols); - pEntry != 0; - pEntry = (struct syment *)FindNextLastListObject(&ci->ListOfSymbols) ) { - - /* Search for .file entries designated by C_FILE */ - if ( pEntry->n_sclass == C_FILE ) { - pEntry->n_value = LastFileIndex; - LastFileIndex = SymbolIndex; /* save current index */ - } - /* Search for Function entries C_EXT */ - else if ( pEntry->n_sclass == C_EXT ) { - pEntry++; - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_fsize = LastFunctionAddress - pEntry->n_value; /* function updated size */ - pAux->x_sym.x_fcnary.x_fcn.x_lnnoptr += LinesOffset; - LastFunctionAddress = pEntry->n_value; - pAux->x_sym.x_fcnary.x_fcn.x_endndx = LastFunctionIndex; /* point to next function index */ - pAux->x_sym.x_tvndx = 0; /* ??? */ - LastFunctionIndex = SymbolIndex; - } else if ( (pEntry->n_sclass == C_FCN ) || ( pEntry->n_sclass == C_BLOCK) ) { - if ( pEntry->n_name[1] == 'b' ) { - /* .bf and .bb */ - pEntry++; - pAux = (union auxent *)pEntry; - pAux->x_sym.x_fcnary.x_fcn.x_endndx = LastFunctionIndex; - } - } - /* else do nothing */ - - /* update current symbol index */ - pNode = GetCurrentNode( &ci->ListOfSymbols ); - SymbolIndex -= ( pNode->Size / sizeof(struct syment) ); - } - - // File Header - ci->FileHeader.f_magic = MAGIC_NUMBER_AVR; - ci->FileHeader.f_nscns = 2; -// ci->FileHeader.f_timdat = time( (time_t *)&ci->FileHeader.f_timdat); - ci->FileHeader.f_timdat = pi->time; - ci->FileHeader.f_symptr = SymbolsOffset; - ci->FileHeader.f_nsyms = NumberOfSymbols; - ci->FileHeader.f_opthdr = 0; - ci->FileHeader.f_flags = 0xff; /*F_RELFLG;*/ /* No relocation information available */ - - /* write it out */ - if ( fwrite(&ci->FileHeader, 1, sizeof(struct external_filehdr), pi->coff_file ) != sizeof(struct external_filehdr) ) { - fprintf(stderr,"\nFile error writing header ...(disk full?)"); - return; - } - - // Optional Information - - // Section 1 Header - pSectionHdr = (struct external_scnhdr *)FindFirstListObject(&ci->ListOfSectionHeaders); - if ( !pSectionHdr ) { - fprintf(stderr, "\nInternal Coff error - cannot find section header .text!"); - return; - } - memset( &pSectionHdr->s_name[0], 0, sizeof(struct external_scnhdr) ); - strcpy( &pSectionHdr->s_name[0], ".text"); - pSectionHdr->s_paddr = 0; - pSectionHdr->s_vaddr = 0; - pSectionHdr->s_size = ci->MaxRomAddress + 2; /* remember the last instruction */ - pSectionHdr->s_scnptr = RawOffset; - pSectionHdr->s_relptr = 0; - pSectionHdr->s_lnnoptr = LinesOffset; - pSectionHdr->s_nreloc = 0; - pSectionHdr->s_nlnno = ci->ListOfLineNumbers.TotalBytes/sizeof(struct lineno); - pSectionHdr->s_flags = STYP_TEXT; - - /* write it out */ - if ( fwrite(&pSectionHdr->s_name[0], 1, sizeof(struct external_scnhdr), pi->coff_file ) != sizeof(struct external_scnhdr) ) { - fprintf(stderr,"\nFile error writing section header ...(disk full?)"); - return; - } - - // Section 2 Header - pSectionHdr = (struct external_scnhdr *)FindNextListObject(&ci->ListOfSectionHeaders); - if ( !pSectionHdr ) { - fprintf(stderr, "\nInternal Coff error - cannot find section header .bss!"); - return; - } - memset( &pSectionHdr->s_name[0], 0, sizeof(struct external_scnhdr) ); - strcpy( &pSectionHdr->s_name[0], ".bss"); - /* later expansion */ - pSectionHdr->s_paddr = ci->GlobalStartAddress; - pSectionHdr->s_vaddr = ci->GlobalStartAddress; - pSectionHdr->s_flags = STYP_DATA; /* seems it should be STYP_BSS */ - - /* write it out */ - if ( fwrite(&pSectionHdr->s_name[0], 1, sizeof(struct external_scnhdr), pi->coff_file ) != sizeof(struct external_scnhdr) ) { - fprintf(stderr,"\nFile error writing section header ...(disk full?)"); - return; - } - - /* Section N Header - .data or eeprom */ - - // Raw Data for Section 1 - if ( (p = FindFirstListObject(&ci->ListOfRawData) ) == 0 ) { - fprintf(stderr,"\nInternal error - unable to find binary data!"); - return; - } - - /* write it out */ - if ( fwrite( p, 1, ci->MaxRomAddress + 2, pi->coff_file ) != (size_t)(ci->MaxRomAddress + 2) ) { - fprintf(stderr,"\nFile error writing raw .text data ...(disk full?)"); - return; - } - // Raw data for section n - - // Relocation Info for section 1 - - // Relocation info for section n - - // Line numbers for section 1 - for ( pLine = (struct lineno *)FindFirstListObject( &ci->ListOfLineNumbers ); - pLine != 0; - pLine = (struct lineno *)FindNextListObject( &ci->ListOfLineNumbers ) ) { - - pNode = GetCurrentNode( &ci->ListOfLineNumbers ); - - /* write it out */ - if ( fwrite( pLine, 1, pNode->Size, pi->coff_file ) != pNode->Size ) { - fprintf(stderr,"\nFile error writing line numbers ...(disk full?)"); - return; - } - } - - - // Line numbers for section n - - // Symbol table - for ( pEntry = (struct syment *)FindFirstListObject( &ci->ListOfSymbols ); - pEntry != 0; - pEntry = (struct syment *)FindNextListObject( &ci->ListOfSymbols ) ) { - - pNode = GetCurrentNode( &ci->ListOfSymbols ); - - /* write it out */ - if ( fwrite( pEntry, 1, pNode->Size, pi->coff_file ) != pNode->Size ) { - fprintf(stderr,"\nFile error writing symbol table ...(disk full?)"); - return; - } - } - - // Symbol table of Globals - for ( pEntry = (struct syment *)FindFirstListObject( &ci->ListOfGlobals ); - pEntry != 0; - pEntry = (struct syment *)FindNextListObject( &ci->ListOfGlobals ) ) { - - pNode = GetCurrentNode( &ci->ListOfGlobals ); - - /* write it out */ - if ( fwrite( pEntry, 1, pNode->Size, pi->coff_file ) != pNode->Size ) { - fprintf(stderr,"\nFile error writing global symbols ...(disk full?)"); - return; - } - } - - /* Specials .text, .bss, .data */ - - for ( pEntry = (struct syment *)FindFirstListObject( &ci->ListOfSpecials ); - pEntry != 0; - pEntry = (struct syment *)FindNextListObject( &ci->ListOfSpecials ) ) { - - pNode = GetCurrentNode( &ci->ListOfSpecials ); - - /* write it out */ - if ( fwrite( pEntry, 1, pNode->Size, pi->coff_file ) != pNode->Size ) { - fprintf(stderr,"\nFile error writing special symbols ...(disk full?)"); - return; - } - } - - // String Table - for ( p = (char *)FindFirstListObject( &ci->ListOfStrings ); - p != 0; - p = (char *)FindNextListObject( &ci->ListOfStrings ) ) { - - pNode = GetCurrentNode( &ci->ListOfStrings ); - - /* write it out */ - if ( fwrite( p, 1, pNode->Size, pi->coff_file ) != pNode->Size ) { - fprintf(stderr,"\nFile error writing strings data ...(disk full?)"); - return; - } - } - - return; -} - -/****************************************************************************************/ - -void write_coff_eeprom( struct prog_info *pi, int address, unsigned char data){ - - if ( !GET_ARG(pi->args, ARG_COFF) ) - return; - - /* Coff output keeps track of binary data in memory buffers */ - if ( ci->pEEPRomMemory ) { - if ( address <= pi->device->eeprom_size ) { - *(ci->pEEPRomMemory + address) = data; - if ( address >= ci->MaxEepromAddress ) - ci->MaxEepromAddress = address; /* keep high water mark */ - } else { - pi->error_count++; - fprintf(stderr, "Error: EEPROM address %d exceeds max range %d", address, pi->device->eeprom_size ); - } - } -} -/****************************************************************************************/ - -void write_coff_program( struct prog_info *pi, int address, unsigned int data){ - - unsigned char *pByte; - - if ( !GET_ARG(pi->args, ARG_COFF) ) - return; - - /* Coff output keeps track of binary data in memory buffers, address is in bytes not words */ - if ( ci->pRomMemory ) { -/* JEG if ( address <= pi->device->flash_size ) { */ /* JEG 4-23-03 */ - if ( address <= pi->device->flash_size*2 ) { - pByte = (unsigned char *)(ci->pRomMemory + address); /* point to low byte in memory */ - *pByte++ = (data & 0xff); /* low byte */ - *pByte = ((data >> 8) & 0xff); /* high byte */ - - if ( address >= ci->MaxRomAddress ) - ci->MaxRomAddress = address; /* keep high water mark */ - } else { - pi->error_count++; -/* JEG fprintf(stderr, "Error: FLASH address %d exceeds max range %d", address, pi->device->flash_size ); */ - fprintf(stderr, "Error: FLASH address %d exceeds max range %d", address, pi->device->flash_size*2 ); - } - } -} - -/****************************************************************************************/ - -void close_coff_file(struct prog_info *pi, FILE *fp){ - - /* close the output file */ - fclose( fp ); - pi->coff_file = 0; - - /* free all the internal memory buffers used by ci */ - - FreeList( &ci->ListOfSectionHeaders ); - FreeList( &ci->ListOfRawData ); - FreeList( &ci->ListOfRelocations ); - FreeList( &ci->ListOfLineNumbers ); - FreeList( &ci->ListOfSymbols ); - FreeList( &ci->ListOfGlobals ); - FreeList( &ci->ListOfUndefined ); - FreeList( &ci->ListOfStrings ); - FreeList( &ci->ListOfTypes ); - FreeList( &ci->ListOfSplitLines ); - - /* now free ci */ - free( ci ); - ci = 0; -} - -/****************************************************************************************/ - -int parse_stabs( struct prog_info *pi, char *p ){ - - int ok = True; - int TypeCode, n; - char *pString, *p2, *p3, *p4, *p5, *pType, *pEnd, *pp, *pJoined; - - - if ( !GET_ARG(pi->args, ARG_COFF) || ( pi->pass == PASS_1 ) ) - return(True); - - /* stabs debugging information is in the form: - .stabs "symbolic info string", HexorDecimalTypecode, parm3, parm4, parm5 - parm1, parm2, parm3 depend on typecode - - N_LSYM 0x80 local sym: name,,0,type,offset - N_OPT 0x3c compiler options - N_SO 0x64 source file name: name,,0,0,address - N_SOL 0x84 #included file name: name,,0,0,address - N_FUN 0x24 procedure: name,,0,linenumber,address - N_GSYM 0x20 global symbol: name,,0,type,0 - N_LCSYM 0x28 .lcomm symbol: name,,0,type,address - N_STSYM 0x26 static symbol: name,,0,type,address - N_RSYM 0x40 register sym: name,,0,type,register - N_PSYM 0xa0 parameter: name,,0,type,offset - - */ - - /* Look for multiple commands per line */ - - /* .stabs "linktag:T19=s46next:20=*19,0,16;last:20,16,16;a:21=ar1;0;2;22=ar1;0;3;1,32,96;\\",128,0,0,0 */ - /* .stabs "b:23=ar1;0;4;24=ar1;0;5;2,128,240;;",128,0,0,0 */ - - - /* Look for continuation lines per line */ - - /* Get String information as a token */ - /* Parse the tokens in the stabn line buffer */ - pString = get_next_token(p, TERM_DOUBLEQUOTE ); /* zap first doublequote */ - p2 = get_next_token(pString, TERM_DOUBLEQUOTE ); /* zap last doublequote */ - p2 = get_next_token(p2, TERM_COMMA ); /* zap comma */ - p3 = get_next_token(p2, TERM_COMMA ); - p4 = get_next_token(p3, TERM_COMMA ); - p5 = get_next_token(p4, TERM_COMMA ); - pEnd = get_next_token(p5, TERM_END ); /* zap CR LF, make ASCIIZ */ - - if ( !pString || !p2 || !p3 || !p4 || !p5 ) - return( False ); - - /* Check for split lines */ - n = strlen( pString ); - if ( ( pString[n - 1] == '\\' ) && (pString[n - 2] == '\\') ) { - /* We have a continuation string here */ - pString[n - 2] = 0; - n -= 2; - if ( !(pp = (char *)AllocateListObject( &ci->ListOfSplitLines, n + 1 )) ) { - fprintf(stderr, "\nOut of memory allocating continuation line!"); - return( False ); - } - strcpy( pp, pString ); /* loose the continuation characters */ - return(True); - } - if ( ci->ListOfSplitLines.TotalItems > 0 ) { - /* Join lines together and process */ - if ( !(pJoined = calloc( 1, n + ci->ListOfSplitLines.TotalBytes ) ) ) { - fprintf(stderr, "\nOut of memory joining continuation lines!"); - return( False ); - } - for ( pp = (char *)FindFirstListObject( &ci->ListOfSplitLines ); - pp != 0; - pp = (char *)FindNextListObject( &ci->ListOfSplitLines ) ) { - - strcat( pJoined, pp ); /* connect the lines */ - } - strcat( pJoined, pString ); - FreeList( &ci->ListOfSplitLines ); - if ( !AddListObject( &ci->ListOfSplitLines, pJoined, n + ci->ListOfSplitLines.TotalBytes ) ) { - fprintf(stderr, "\nUnable to add joined continuation line"); - return( False ); - } - pString = pJoined; - } - - - if ( *p2 == '0' ) - TypeCode = atox(p2); /* presume to be hex 0x */ - else - TypeCode = atoi(p2); - - switch ( TypeCode ) { - - case N_OPT: /* compiler options */ - break; /* nothing used here */ - - case N_SO: /* source file name: name,,0,0,address */ - ok = stab_add_filename( pString, p5 ); - break; - - case N_GSYM: /* global symbol: name,,0,type,0 */ - pType = get_next_token(pString, TERM_COLON ); /* separate at colon */ - ok = stab_add_global( pi, pString, pType ); - break; - - case N_FUN: /* procedure: name,,0,linenumber,address */ - ok = stab_add_function( pi, pString, p5 ); - break; - - case N_LSYM: /* local sym: name,,0,type,offset */ - /* pString, p2 = TypeCode, p3 = 0, p4 = 0, p5 = offset */ - pType = get_next_token(pString, TERM_COLON ); /* pType = symbol descriptor (character after the colon) */ - if ( *pType == 't') - ok = stab_add_local_type( pString, ++pType ); - else if (*pType == 'T') - ok = stab_add_tag_type( pString, ++pType ); - else - ok = stab_add_local( pi, pString, pType, p5 ); - break; - - case N_RSYM: /* Symbol:[P|r]type,0,size,register */ - pType = get_next_token(pString, TERM_COLON ); /* separate at colon */ - ok = stab_add_local_register( pi, pString, pType, p5 ); - break; - - case N_LCSYM: /* .lcomm symbol: name,,0,type,address */ - ok = True; - break; /* ignore constants */ - - case N_STSYM: /* static symbol: name,,0,type,address */ - pType = get_next_token(pString, TERM_COLON ); /* separate at colon */ - ok = stab_add_static_symbol( pi, pString, pType, p5 ); - break; - - case N_PSYM: /* parameter: name,,0,type,offset */ - pType = get_next_token(pString, TERM_COLON ); /* separate at colon */ - ok = stab_add_parameter_symbol( pi, pString, pType, p5 ); - break; - - case N_SOL: /* #included file name: name,,0,0,address */ - ok = True; - break; /* ignore include files */ - - default: - ok = False; - } - - if ( ci->ListOfSplitLines.TotalItems > 0 ) - FreeList( &ci->ListOfSplitLines ); - - return( ok ); -} -/****************************************************************************************/ - -int parse_stabn( struct prog_info *pi, char *p ){ - - int ok = True; - int TypeCode /* , LineNumber */, Level; - char *p1, *p2, *p3, *p4, *pLabel, *pFunction, *pEnd; - - /* stabn debugging information is in the form: - .stabn TypeCode, 0, parm1, parm2 - parm1 is level - parm2 is Label-Function - - compiler currently produces the following TypeCodes: - N_LBRAC 0xc0 left bracket: 0,,0,nesting level,address - N_RBRAC 0xe0 right bracket: 0,,0,nesting level,address - N_SLINE 0x44 src line: 0,,0,linenumber,address - */ - - if ( !GET_ARG(pi->args, ARG_COFF) || ( pi->pass == PASS_1 ) ) - return(True); - - /* Parse the tokens in the stabn line buffer */ - p1 = get_next_token(p, TERM_SPACE ); - p2 = get_next_token(p1, TERM_COMMA ); - p3 = get_next_token(p2, TERM_COMMA ); - p4 = get_next_token(p3, TERM_COMMA ); - pEnd = get_next_token(p4, TERM_END ); /* zap CR LF, make ASCIIZ */ - - if ( !p1 || !p2 || !p3 || !p4 ) - return( False ); - - /* first convert TypeCode to binary */ - if ( *p1 == '0' ) - TypeCode = atox(p1); /* presume to be hex 0x */ - else - TypeCode = atoi(p1); - - Level = atoi(p3); /* line number or level */ - pLabel = p4; /* Assembly label */ - pFunction = get_next_token( pLabel, TERM_DASH ); /* Function */ - - switch ( TypeCode ) { - case N_SLINE: /* src line: 0,,0,linenumber,address */ - ok = stab_add_lineno( pi, Level, pLabel, pFunction ); - break; - - case N_LBRAC: /* left bracket: 0,,0,nesting level,address */ - ok = stab_add_lbracket( pi, Level, pLabel, pFunction ); - break; - - case N_RBRAC: /* right bracket: 0,,0,nesting level,address */ - ok = stab_add_rbracket( pi, Level, pLabel, pFunction ); - break; - - default: - fprintf(stderr, "\nUnknown .stabn TypeCode = 0x%x", TypeCode ); - ok = False; - } - return( ok ); -} - -/****************************************************************************************/ -int stab_add_lineno( struct prog_info *pi, int LineNumber, char *pLabel, char *pFunction ){ - - int Address; - struct lineno *pln; - struct syment *pEntry; - union auxent *pAux; - - /* Allocate LineNumber Table entry and fill it in */ - pln = (struct lineno *)AllocateListObject(&ci->ListOfLineNumbers, sizeof(struct lineno) ); - if ( !pln ) { - fprintf(stderr, "\nOut of memory allocating lineno table for function %s", pFunction ); - return( False ); - } - /* set value field to be address of label in bytes */ - if ( !get_symbol(pi, pLabel, &Address) ) { - fprintf(stderr, "\nUnable to locate label %s", pLabel ); - return( False ); - } - pln->l_addr.l_paddr = Address * 2; /* need byte quanities */ - - /* Line number is relative to beginning of function, starts at 1 */ - if ( ci->FunctionStartLine == 0 ) { - /* This line number is that same as the function start */ - ci->FunctionStartLine = LineNumber; - } - pln->l_lnno = LineNumber - ci->FunctionStartLine + 1; - ci->CurrentSourceLine = LineNumber; /* keep track of source line for .eb .ef arrays */ - if ( ci->NeedLineNumberFixup ) { - /* need to go into symbol table and fix last NeedLineNumberFixup entries */ - for ( pEntry = (struct syment *)FindLastListObject(&ci->ListOfSymbols); - (pEntry != 0) && ( ci->NeedLineNumberFixup != 0); - pEntry = (struct syment *)FindNextLastListObject(&ci->ListOfSymbols) ) { - - /* Fix up line number entries */ - if ( (pEntry->n_sclass == C_FCN ) || ( pEntry->n_sclass == C_BLOCK ) || ( pEntry->n_sclass == C_EXT) ) { - pEntry++; - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_lnsz.x_lnno = LineNumber; - ci->NeedLineNumberFixup--; - } - } - } - - return(True); -} -/****************************************************************************************/ - -int stab_add_lbracket( struct prog_info *pi, int Level, char *pLabel, char *pFunction ){ - - int Address; - struct syment *pEntry; - union auxent *pAux; - //char *p; - //struct lineno *pln; - - if ( !get_symbol(pi, pLabel, &Address) ) { - fprintf(stderr, "\nUnable to locate label %s", pLabel ); - return( False ); - } - - /* Now create a .bb symbol table entry and aux entry too */ - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfSymbols, sizeof(struct syment) * 2 ); - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry for .bb %s", pLabel ); - return( False ); - } - /* n_name */ - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".bb" ); - - pEntry->n_value = Address * 2; /* bytes not words */ - pEntry->n_scnum = 1; /* .text */ - pEntry->n_type = 0; - pEntry->n_sclass = C_BLOCK; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_lnsz.x_lnno = 0; /* UNKNOWN - post process */ - pAux->x_sym.x_misc.x_lnsz.x_size = 0; /* UNKNOWN - post process */ - ci->NeedLineNumberFixup++; /* once for .bb block */ - return(True); -} - -/****************************************************************************************/ -int stab_add_rbracket( struct prog_info *pi, int Level, char *pLabel, char *pFunction ){ - - int Address; - struct syment *pEntry; - union auxent *pAux; - //char *p; - //struct lineno *pln; - - if ( !get_symbol(pi, pLabel, &Address) ) { - fprintf(stderr, "\nUnable to locate label %s", pLabel ); - return( False ); - } - - /* Now create a .eb symbol table entry */ - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfSymbols, sizeof(struct syment) * 2 ); - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry for .eb %s", pLabel ); - return( False ); - } - /* n_name */ - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".eb" ); - pEntry->n_sclass = C_BLOCK; - pEntry->n_value = Address * 2; /* bytes not words */ - pEntry->n_scnum = 1; /* .text */ - pEntry->n_type = 0; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_lnsz.x_lnno = ci->CurrentSourceLine; - - /* create an .ef if at level 0 */ - if ( Level == 0 ) { - - /* Now create a .ef symbol table entry */ - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfSymbols, sizeof(struct syment) * 2 ); - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry for .ef %s", pLabel ); - return( False ); - } - /* n_name */ - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".ef" ); - pEntry->n_sclass = C_FCN; - pEntry->n_value = Address * 2; /* bytes not words */ - pEntry->n_scnum = 1; /* .text */ - pEntry->n_type = 0; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_lnsz.x_lnno = ci->CurrentSourceLine; - } - return(True); -} - -/****************************************************************************************/ -int stab_add_filename( char *pName, char *pLabel ){ - - int ok, n; - struct syment *pEntry; - union auxent *pAux; - char *p; - - /* if( pLabel == "Ltext0" ) then beginning of .text, pName = cwd, next pName = file */ - - /* if( pLabel == "Letext" ) then end of .text , pName == NULL */ - - /* we only need the one not ending in Slash */ - ok = True; - n = strlen(pName); - if ( n > 0 ) { - if ( ( pName[ n - 1] == '\\') || (pName[ n - 1] == '/') ) - return(True); /* ignore */ - } else - return(True); - - - /* allocate entry in symbol table list */ - pEntry = (struct syment *)AllocateTwoListObjects( - &ci->ListOfSymbols, sizeof(struct syment) * 2 ); /* aux entry too */ - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry for global %s", pName ); - return( False ); - } - /* n_name */ - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".file" ); - /* n_value is determined after processing done UNKNOWN - post process */ - /* The value of that symbol equals the symbol table entry index of the next .file symbol or .global */ - /* post process */ - pEntry->n_scnum = N_DEBUG; - pEntry->n_sclass = C_FILE; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - - /* Add Label name to symbol table */ - if ( n <= FILNMLEN ) { - /* inline filename */ - memset( pAux->x_file.x_fname, 0, FILNMLEN ); - strncpy( pAux->x_file.x_fname, pName, n ); /* might not be zero terminated */ - } else { - pAux->x_file.x_n.x_zeroes = 0; /* symbol name is in string table */ - pAux->x_file.x_n.x_offset = ci->ListOfStrings.TotalBytes; - - /* add to string table */ - p = (char *)AllocateListObject( &ci->ListOfStrings, n + 1 ); - if ( !p ) { - fprintf(stderr, "\nOut of memory allocating string table space!"); - return( False ); - } - strcpy( p, pName ); - } - return( ok ); -} - -/****************************************************************************************/ -int stab_add_function( struct prog_info *pi, char *pName, char *pLabel ){ - - int n, Address; - unsigned short CoffType, Type; - struct syment *pEntry; - char *pType; - struct lineno *pln; - union auxent *pAux; - int SymbolIndex; - - pType = get_next_token(pName, TERM_COLON ); /* pType = symbol descriptor (character after the colon) */ - Type = atoi(pType + 1); /* skip past F, predefined variable type */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized return type found for function %s = %d", pName, Type ); - return(False); - } - /* Get Current Symbol Index, Allocate Symbol Table entry and fill it in */ - SymbolIndex = ci->ListOfSymbols.TotalItems; - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfSymbols, sizeof(struct syment) * 2 ); - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry for function %s", pName ); - return( False ); - } - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - } - if ( !get_symbol(pi, pLabel, &Address) ) { - fprintf(stderr, "\nUnable to locate function %s", pName ); - return( False ); - } - pEntry->n_value = Address * 2; /* convert words to bytes */ - pEntry->n_scnum = 2; /* .bss */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for function %s = %d", pName, Type ); - return(False); - } - pEntry->n_type = (unsigned short)(CoffType | (DT_FCN << 4)); - pEntry->n_sclass = C_EXT; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_tagndx = SymbolIndex + 1; /* point to the .bf entry index */ - // wrong! - // pAux->x_sym.x_misc.x_lnsz.x_lnno = ci->ListOfLineNumbers.TotalBytes; /* Relative Fixup point to where line numbers start */ - // pAux->x_sym.x_misc.x_lnsz.x_size = 0; /* UNKNOWN till next function called */ - pAux->x_sym.x_misc.x_fsize = 0; /* unknown till end */ - pAux->x_sym.x_fcnary.x_fcn.x_lnnoptr = ci->ListOfLineNumbers.TotalBytes; /* relative offset to line number entry */ - pAux->x_sym.x_fcnary.x_fcn.x_endndx = 0; /* index to next entry */ - - /* Now add function entry into the line number table */ - /* Allocate Symbol Table entry and fill it in */ - pln = (struct lineno *)AllocateListObject(&ci->ListOfLineNumbers, sizeof(struct lineno) ); - if ( !pln ) { - fprintf(stderr, "\nOut of memory allocating lineno table for function %s", pName ); - return( False ); - } - pln->l_lnno = 0; - pln->l_addr.l_symndx = SymbolIndex; - - /* Initialize the FunctionStartLine from the beginning of the function */ - ci->FunctionStartLine = 0; - - /* Allocate Symbol Table entry and fill it in */ - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfSymbols, sizeof(struct syment) * 2 ); - if ( !pEntry ) { - fprintf(stderr, "\nOut of memory allocating symbol table entry .bf for function %s", pName ); - return( False ); - } - memset( pEntry->n_name, 0, 8 ); - strcpy( pEntry->n_name, ".bf" ); - pEntry->n_value = Address * 2; /* bytes not words */ - pEntry->n_scnum = 1; /* .text */ - pEntry->n_type = 0; - pEntry->n_sclass = C_FCN; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_misc.x_lnsz.x_lnno = 0; /* UNKNOWN - post process */ - pAux->x_sym.x_misc.x_lnsz.x_size = 0; /* UNKNOWN - post process */ - - ci->NeedLineNumberFixup++; /* once for function C_EXT symbol */ - ci->NeedLineNumberFixup++; /* once for .bf block */ - return( True ); -} -/****************************************************************************************/ - -int stab_add_global( struct prog_info *pi, char *pName, char *pType ){ - - int n, Address, IsArray, SymbolIndex; - unsigned short CoffType, Type; - struct syment *pEntry; - char *p; - STABCOFFMAP *pMap; - - - n = strlen( pName ); /* see if it's 8 bytes or less */ - Type = atoi(pType + 1); /* skip past G, predefined variable type */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for global %s = %d", pName, Type ); - return(False); - } - pMap = (STABCOFFMAP *)GetCurrentListObject( &ci->ListOfTypes ); - - SymbolIndex = ci->ListOfSymbols.TotalItems; - /* Allocate Symbol Table entry and fill it in, Auxiliary table if its an array */ - if ( IsTypeArray( CoffType ) == True ) { - IsArray = True; - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfGlobals, sizeof(struct syment) * 2 ); - } else { - IsArray = False; - pEntry = (struct syment *)AllocateListObject( &ci->ListOfGlobals, sizeof(struct syment) ); - } - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - } - /* set value field to be address of label in bytes */ - /* add underscore to lookup label */ - if ( (p = calloc( 1, n + 2)) == 0 ) { - fprintf(stderr,"\nOut of memory adding global %s", pName ); - return(False); - } - *p = '_'; - strcpy( p + 1, pName ); - if ( !get_symbol(pi, p, &Address) ) { - fprintf(stderr, "\nUnable to locate global %s", p ); - free( p ); - return( False ); - } - free( p ); - pEntry->n_value = Address; /* already in bytes */ - if ( ci->GlobalStartAddress == -1 ) { - ci->GlobalStartAddress = Address; - } - if ( Address < ci->GlobalStartAddress ) - ci->GlobalStartAddress = Address; - if ( Address > ci->GlobalEndAddress ) - ci->GlobalEndAddress = Address; - - pEntry->n_scnum = 2; /* .bss */ - pEntry->n_type = CoffType; - pEntry->n_sclass = C_STAT; - if ( IsArray == False ) - pEntry->n_numaux = 0; - else { - pEntry->n_numaux = 1; - pEntry++; - AddArrayAuxInfo( (union auxent *)pEntry, (unsigned short)SymbolIndex, pMap ); - } - return( True ); -} - -/****************************************************************************************/ -int stab_add_local( struct prog_info *pi, char *pName, char *pType, char *pOffset ){ - - int n, Offset, IsArray; - unsigned short CoffType, Type, SymbolIndex; - struct syment *pEntry; - STABCOFFMAP *pMap; - - n = strlen( pName ); /* see if it's 8 bytes or less */ - Type = atoi(pType); /* predefined variable type */ - Offset = atoi(pOffset); /* offset in stack frame */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for local %s = %d", pName, Type ); - return(False); - } - pMap = (STABCOFFMAP *)GetCurrentListObject( &ci->ListOfTypes ); - SymbolIndex = ci->ListOfSymbols.TotalItems; - /* Allocate Symbol Table entry and fill it in, Auxiliary table if its an array */ - if ( IsTypeArray( CoffType ) == True ) { - IsArray = True; - pEntry = (struct syment *)AllocateTwoListObjects( &ci->ListOfGlobals, sizeof(struct syment) * 2 ); - } else { - IsArray = False; - pEntry = (struct syment *)AllocateListObject( &ci->ListOfSymbols, sizeof(struct syment) ); - } - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - } - pEntry->n_type = CoffType; - pEntry->n_sclass = C_AUTO; - pEntry->n_scnum = N_ABS; - pEntry->n_value = Offset + 1; /* Silly avr studio is set in its ways */ - if ( IsArray == False ) - pEntry->n_numaux = 0; - else { - pEntry->n_numaux = 1; - pEntry++; - AddArrayAuxInfo( (union auxent *)pEntry, SymbolIndex, pMap ); - } - return( True ); -} - -/****************************************************************************************/ -int stab_add_parameter_symbol( struct prog_info *pi, char *pName, char *pType, char *pOffset ){ - - int n, Offset; - unsigned short CoffType, Type; - struct syment *pEntry; - - n = strlen( pName ); /* see if it's 8 bytes or less */ - Type = atoi(pType); /* predefined variable type */ - Offset = atoi(pOffset); /* offset in stack frame */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type ); - return(False); - } - /* Allocate Symbol Table entry and fill it in */ - pEntry = (struct syment *)AllocateListObject( &ci->ListOfSymbols, sizeof(struct syment) ); - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - } - pEntry->n_type = CoffType; - pEntry->n_sclass = C_ARG; - pEntry->n_scnum = N_ABS; - pEntry->n_value = Offset; - pEntry->n_numaux = 0; - return( True ); -} -/****************************************************************************************/ -int stab_add_static_symbol( struct prog_info *pi, char *pName, char *pType, char *pLabel ){ - - int n, Address; - unsigned short CoffType, Type; - struct syment *pEntry; - - n = strlen( pName ); /* see if it's 8 bytes or less */ - Type = atoi(pType + 1); /* skip past S, predefined variable type */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type ); - return(False); - } - /* Allocate Symbol Table entry and fill it in */ - pEntry = (struct syment *)AllocateListObject( &ci->ListOfSymbols, sizeof(struct syment) ); - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - } - pEntry->n_type = CoffType; - pEntry->n_sclass = C_STAT; - pEntry->n_scnum = N_ABS; - if ( !get_symbol(pi, pLabel, &Address) ) { - fprintf(stderr, "\nUnable to locate label %s", pLabel ); - return( False ); - } - pEntry->n_value = Address * 2; /* find address of variable in bytes */ - pEntry->n_numaux = 0; - return( True ); -} -/****************************************************************************************/ - -int stab_add_local_register( struct prog_info *pi, char *pName, char *pType, char *pRegister ){ - - int n, Register, Size; - unsigned short CoffType, Type; - struct syment *pEntry; - - n = strlen( pName ); /* see if it's 8 bytes or less */ - Type = (unsigned short)atoi(pType + 1); /* skip past P, predefined variable type */ - Register = atoi(pRegister); /* offset in stack frame */ - if ( (CoffType = GetCoffType( Type )) == 0 ) { - fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type ); - return(False); - } - Size = GetCoffTypeSize( Type ); /* Silly requirement for avr studio */ - /* Allocate Symbol Table entry and fill it in */ - pEntry = (struct syment *)AllocateListObject( &ci->ListOfSymbols, sizeof(struct syment) ); - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pName ); - return(False); - } - pEntry->n_type = CoffType; - // if( (*pType == 'r') || (*pType == 'R') ) - // pEntry->n_sclass = C_REG; - // else if( (*pType == 'p') || (*pType == 'P') ) - pEntry->n_sclass = C_REGPARM; /* Silly avr studio only accepts this for registers */ - // else{ - // fprintf(stderr,"\nUnknown register type -> %s", pType ); - // return(False); - // } - pEntry->n_scnum = N_ABS; - pEntry->n_numaux = 0; - if ( Size == 1 ) - pEntry->n_value = 0xffffff00 | Register; /* Silly requirement for avr studio */ - else if ( Size == 2 ) - pEntry->n_value = 0xffff0000 | ((Register + 1) << 8) | Register; /* Silly requirement for avr studio */ - else if ( Size == 4 ) - pEntry->n_value = ((Register + 3) << 24) | ((Register + 3) << 16) | ((Register + 1) << 8) | Register; /* Silly requirement for avr studio */ - else { - fprintf(stderr,"\nUnknown register size (%d) and coff type (%d)", Size, CoffType ); - return(False); - } - return( True ); -} - -/****************************************************************************************/ - -int stab_add_local_type( char *pName, char *pType ){ - - char *p; - unsigned short StabType; - - /* .stabs "int:t1=r1;-128;127;",128,0,0,0 */ - /* .stabs ":t20=ar1;0;1;21=ar1;0;1;2",128,0,0,0 */ - /* pType-----^ */ - /* Stab Type - convert to Coff type at end (after inline assignments */ - if ( GetStabType( pType, &StabType, &p ) != True ) { - fprintf(stderr,"\nInvalid tag type found in structure item -> %s", p); - return(False); - } - - return(True); -} - -/****************************************************************************************/ - -int GetStructUnionTagItem( char *p, char **pEnd, char **pName, unsigned short *pType, unsigned short *pBitOffset, unsigned short *pBitSize) { - - unsigned short StabType; - /* Structure or Union Tag Item consists of -> name:type,bitoffset,bitsize; */ - - /* name */ - *pName = p; - while ( *p && (*p != ':') ) p++; // locate colon - if ( *p != ':' ) { - fprintf(stderr,"\nNo colon found in structure item -> %s", *pName); - return(False); - } - *p++ = 0; // Asciiz - - /* Stab Type - convert to Coff type at end (after inline assignments */ - if ( GetStabType( p, &StabType, &p ) != True ) { - fprintf(stderr,"\nInvalid tag type found in structure item -> %s", p); - return(False); - } - - /* BitSize */ - if ( *p != ',' ) { - fprintf(stderr,"\nNo Bit size found in structure item -> %s", p ); - return(False); - } - *pBitOffset = (unsigned short)atoi( ++p ); - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - - /* BitOffset */ - if ( *p != ',' ) { - fprintf(stderr,"\nNo Bit offset found in structure item -> %s", p ); - return(False); - } - *pBitSize = (unsigned short)atoi( ++p ); - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - - /* Now convert stab type to COFF */ - if ( (*pType = GetCoffType( (unsigned short)StabType)) == 0 ) { - fprintf(stderr,"\nNo COFF type found for stab type %d", StabType ); - return( False); - } - if ( *++p == ';' ) /* Now eat last semicolon(s) */ - p++; - *pEnd = p; - - return( True ); -} -/****************************************************************************************/ - -int GetEnumTagItem( char *p, char **pEnd, char **pEnumName, int *pEnumValue ) { - - /* Enum Tag Item consists of -> member1:value,member2:value2,; */ - *pEnumName = p; - while ( *p && (*p != ':') ) p++; // locate colon - if ( *p != ':' ) { - fprintf(stderr,"\nNo colon found in enum item -> %s", *pEnumName); - return(False); - } - *p++ = 0; // Asciiz - *pEnumValue = atoi(p); - - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - if ( *p != ',' ) { - fprintf(stderr,"\nNo comma found after enum value -> %s", p ); - return(False); - } - if ( *++p ==';' ) - p++; /* eat last semicolon */ - *pEnd = p; - return( True ); -} - -/****************************************************************************************/ -int GetArrayType( char *p, char **pEnd, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels ){ - - int MinIndex, MaxIndex, Result, Size, i; - char *pMinIndex, *pMaxIndex, *pType; - unsigned short Type; - - Result = True; - - pMinIndex = pMaxIndex = pType = 0; - while ( *p && (*p != ';') ) p++; /* find min index */ - pMinIndex = ++p; - while ( *p && (*p != ';') ) p++; /* find max index */ - pMaxIndex = ++p; - while ( *p && (*p != ';') ) p++; /* find type index */ - pType = ++p; - - /* bump the pointers to the digits */ - if ( !isdigit(*pMinIndex) ) - Result = False; - if ( !isdigit(*pMaxIndex) ) - Result = False; - if ( !isdigit(*pType) ) - Result = False; - /* Is syntax ok ? */ - if ( Result != True ) { - fprintf(stderr,"\nSyntax error on array parameters %s%s%s", pMinIndex, pMaxIndex, pType ); - return(False); - } - MinIndex = atoi(pMinIndex); - MaxIndex = atoi(pMaxIndex); - - if ( GetStabType( p, &Type, &p ) != True ) - return(False); - - if ( !SetupDefinedType( Type, pMap, DerivedBits, ExtraLevels ) ) - return( False ); - - /* Now update the size based on the indicies */ - Size = (MaxIndex - MinIndex) + 1; - pMap->ByteSize *= Size; - pMap->Line = ci->CurrentSourceLine; - /* add the dimension information */ - for ( i = 5; i >= 0; i-- ) { - if ( pMap->Dimensions[i] != 0 ) { - i++; - pMap->Dimensions[i] = Size; - break; - } - } - - *pEnd = p; - return(True); -} - -/****************************************************************************************/ -int GetStabType( char *p, unsigned short *pType, char **pEnd ) { - - STABCOFFMAP *pMap; - int extra, ok; - unsigned short derivedbits[6]; - unsigned short LStabType, RStabType; - char *pHigh, *pLow; - - - LStabType = atoi( p ); - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - - *pType = LStabType; - - if ( GetCoffType( LStabType ) != 0 ) { - *pEnd = p; - return(True); - } - if ( *p != '=' ) { - fprintf(stderr, "\nSyntax error in type assignment -> %s", p ); - return(False); - } - p++; - - /* Allocate space for new internal type */ - if ( !(pMap = (STABCOFFMAP *)AllocateListObject(&ci->ListOfTypes, sizeof(STABCOFFMAP)) ) ) { - fprintf(stderr, "\nOut of memory allocating type info!"); - return(False); - } - pMap->StabType = LStabType; - - /* process items to right of equals */ - for ( extra = 0; extra < 6; extra++ ) { - - if ( isdigit( *p ) ) { - /* Finally found base type, try to terminate loop */ - GetStabType( p, &RStabType, &p ); - // RStabType = atoi( p ); - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - if ( SetupDefinedType( RStabType, pMap, &derivedbits[0], extra ) != True ) - return( False ); - break; - } else if ( *p == 'a' ) { - derivedbits[extra] = DT_ARY; - p++; - /* Calculate size */ - /* Since type assignment will be made we need to set extra bits here */ - extra++; - /* =ar1;MinIndex;MaxIndex;BaseType */ - if ( GetArrayType( p, &p, pMap, &derivedbits[0], extra ) != True ) - return(False); - break; - - } else if ( *p == 'f' ) { - derivedbits[extra] = DT_FCN; - p++; - } else if ( *p == '*' ) { - derivedbits[extra] = DT_PTR; - p++; - } else if ( *p == 'r' ) { - // if( LStabType < 15 ) - // ok = GetInternalType( pString, pMap ); /* internal types not yet installed */ - // else - while ( *p && (*p != ';' ) ) p++; - pLow = p++; - while ( *p && (*p != ';' ) ) p++; - pHigh = p++; - ok = GetSubRangeType( LStabType, pMap, pLow, pHigh ); - if ( ok != True ) - return(False); - while ( *p && (*p != ';' ) ) p++; /* find end of range */ - p++; - break; - } else { - fprintf(stderr, "\nUnrecognized Type modifier %c!", *p ); - return(False); - } - } - *pEnd = p; /* Update return pointer */ - - return(True); -} - - -/****************************************************************************************/ -int stab_add_tag_type( char *pName, char *pString ){ - - int SymbolIndex, StabType, TotalSize, n, EnumValue; - unsigned short TagType, ItemType, BitOffset, BitSize; - char *p; - struct syment* pEntry; - union auxent *pAux; - STABCOFFMAP *pMap; - - /* We arrived here due to :T defining either a structure, union or enumeration */ - /* store the basic type as for internals and emit coff structures for debugging */ - /* .stabs "stag:T17=s2i:1,0,8;c:2,8,8;;",128,0,0,0 */ - /* .stabs "2:T18=u2a:2,0,8;b:1,0,8;c:6,0,16;;",128,0,0,0 */ - /* .stabs "1:T19=eenum1:1,enum2:2,enum3:3,;",128,0,0,0 */ - /* we don't care about the name */ - - - /* check for bogus errors */ - if ( !pName || !pString ) { - fprintf(stderr,"\nInvalid .stabs type format - no information!"); - return(False); - } - - p = pString; - /* Stab Type - convert to Coff type at end (after inline assignments */ - if ( (StabType = (unsigned short)atoi(p)) == 0 ) { - fprintf(stderr,"\nInvalid .stabs type format - no information! - > %s", p ); - return(False); - } - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - if ( *p != '=' ) { - fprintf(stderr,"\nInvalid .stabs type format - no equals - > %s", p ); - return(False); - } - SymbolIndex = ci->ListOfSymbols.TotalItems; - if ( ( pEntry = (struct syment*)AllocateTwoListObjects( &ci->ListOfGlobals, sizeof(struct syment) * 2 ) ) == 0 ) { - fprintf(stderr, "\nOut of memory allocating symbol tag entries"); - return(False); - } - /* Prepare Tag Header */ - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pString ); - return(False); - } - if ( !(pMap = (STABCOFFMAP *)AllocateListObject(&ci->ListOfTypes, sizeof(STABCOFFMAP)) ) ) { - fprintf(stderr, "\nOut of memory allocating type info!"); - return(False); - } - pMap->StabType = StabType; - pEntry->n_value = 0; - pEntry->n_scnum = N_DEBUG; - pEntry->n_numaux = 1; - if ( *++p == 's' ) { - TagType = pEntry->n_type = pMap->CoffType = T_STRUCT; - pEntry->n_sclass = C_STRTAG; - TotalSize = (unsigned short)atoi(++p); - } else if ( *p == 'u' ) { - TagType = pEntry->n_type = pMap->CoffType = T_UNION; - pEntry->n_sclass = C_UNTAG; - TotalSize = (unsigned short)atoi(++p); - } else if ( *p == 'e' ) { - TagType = pEntry->n_type = pMap->CoffType = T_ENUM; - pEntry->n_sclass = C_ENTAG; - TotalSize = FundamentalTypes[T_INT].Size; /* use size of int for enums */ - } else { - fprintf(stderr,"\nUnknown tag type -> %s", p ); - return(False); - } - while ( *p && (*p >= '0') && (*p <= '9') ) p++; // locate end of digits - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_tagndx = SymbolIndex; - pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; - - /* update our local knowledge of tag type */ - pMap->CoffType = TagType; - pMap->ByteSize = TotalSize; - pMap->Line = ci->CurrentSourceLine; - - /* Process the items until the end of the line */ - while ( *pName ) { - - if ( ( pEntry = (struct syment*)AllocateTwoListObjects( &ci->ListOfGlobals, sizeof(struct syment) * 2 ) ) == 0 ) { - fprintf(stderr, "\nOut of memory allocating symbol tag member entries"); - return(False); - } - - if ( TagType == T_STRUCT ) { - if ( GetStructUnionTagItem( p, &p, &pName, &ItemType, &BitOffset, &BitSize) != True ) { - return(False); - } - pEntry->n_value = BitOffset/8; - pEntry->n_type = ItemType; - pEntry->n_sclass = C_MOS; - } else if ( TagType == T_UNION ) { - if ( GetStructUnionTagItem( p, &p, &pName, &ItemType, &BitOffset, &BitSize) != True ) { - return(False); - } - pEntry->n_value = BitOffset/8; - pEntry->n_type = ItemType; - pEntry->n_sclass = C_MOU; - } else { /* T_ENUM */ - if ( GetEnumTagItem( p, &p, &pName, &EnumValue ) != True ) { - return(False); - } - pEntry->n_value = EnumValue; - pEntry->n_type = TotalSize; - pEntry->n_sclass = C_MOE; - } - - /* Prepare Common Tag Header items */ - if ( (n = AddNameToEntry( pName, pEntry )) == 0 ) { - fprintf(stderr,"\nOut of memory adding local %s to string table", pString ); - return(False); - } - pEntry->n_scnum = N_ABS; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_tagndx = SymbolIndex; - pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; - pName = p; - } - - /* End of Structures/Unions/Enumberations */ - if ( ( pEntry = (struct syment*)AllocateTwoListObjects( &ci->ListOfGlobals, sizeof(struct syment) * 2 ) ) == 0 ) { - fprintf(stderr, "\nOut of memory allocating special headers for structure!"); - return(False); - } - strcpy( pEntry->n_name, ".eos" ); - pEntry->n_value = TotalSize; - pEntry->n_scnum = N_ABS; - pEntry->n_type = 0; - pEntry->n_sclass = C_EOS; - pEntry->n_numaux = 1; - pEntry++; /* point to aux entry */ - pAux = (union auxent *)pEntry; - pAux->x_sym.x_tagndx = SymbolIndex; /* point to the .bf entry index */ - pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; - - return(True); -} - -/****************************************************************************************/ -int SetupDefinedType( unsigned short Type, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels ){ - - int i, Dlimit, Dstart; - unsigned short StabType; - - StabType = pMap->StabType; /* save the new type we found earlier */ - if ( CopyStabCoffMap( Type, pMap ) != True ) { - fprintf(stderr, "\nCould not find defined type %d", Type ); - return(False); - } - pMap->StabType = StabType; /* save the new type we found earlier */ - - /* Determine existing derived types for base class */ - for ( i = 0; i < 6; i++ ) { - if ( (pMap->CoffType & ( 3 << (4 + i + i))) == 0 ) - break; - } - Dstart = i; - Dlimit = i + ExtraLevels; - if ( (Dlimit) >= 6 ) { - fprintf(stderr, "\nStab Type %d has too many derived (%d) types!", pMap->StabType, Dlimit ); - return(False); - } - /* Add the new derived levels */ - for ( ; i < Dlimit; i++ ) { - pMap->CoffType |= ( ( DerivedBits[i - Dstart] & 3) << (4 + i + i) ); /* add in the derived bits */ - } - return(True); -} - -/****************************************************************************************/ -int GetArrayDefinitions( STABCOFFMAP *pMap , char *pMinIndex, char *pMaxIndex, char *pType, unsigned short *DerivedBits, int ExtraLevels ){ - - int MinIndex, MaxIndex, Result, Size, i; - unsigned short Type; - - Result = True; - if ( (*pMinIndex != ';') || (*pMaxIndex != ';') || (*pType != ';') ) - Result = False; - /* bump the pointers to the digits */ - pMinIndex++; - if ( !isdigit(*pMinIndex) ) - Result = False; - pMaxIndex++; - if ( !isdigit(*pMaxIndex) ) - Result = False; - pType++; - if ( !isdigit(*pType) ) - Result = False; - /* Is syntax ok ? */ - if ( Result != True ) { - fprintf(stderr,"\nSyntax error on array parameters %s%s%s", pMinIndex, pMaxIndex, pType ); - return(False); - } - MinIndex = atoi(pMinIndex); - MaxIndex = atoi(pMaxIndex); - Type = (unsigned short)atoi(pType); - if ( SetupDefinedType( Type, pMap, DerivedBits, ExtraLevels ) != True ) - return( False ); - /* Now update the size based on the indicies */ - Size = (MaxIndex - MinIndex) + 1; - pMap->ByteSize *= Size; - pMap->Line = ci->CurrentSourceLine; - /* add the dimension information */ - for ( i = 5; i >= 0; i-- ) { - if ( pMap->Dimensions[i] != 0 ) { - i++; - pMap->Dimensions[i] = Size; - break; - } - } - return(True); -} - -/****************************************************************************************/ - -int GetInternalType( char *pName, STABCOFFMAP *pMap ){ - - int n, found, i; - - if ( !pName ) { - return(False); - } - - found = False; - n = strlen(pName); - /* Find out if it is a local type */ - for (i = 0; FundamentalTypes[i].pString != 0; i++) { - if ( !strncmp(pName, FundamentalTypes[i].pString, n) ) { - /* found an internal type */ - pMap->CoffType = FundamentalTypes[i].Type; - pMap->ByteSize = FundamentalTypes[i].Size; - found = True; - } - } - return(found); -} - -/****************************************************************************************/ -int GetSubRangeType( unsigned short Type, STABCOFFMAP *pMap , char *pLow, char *pHigh ){ - - int Result, i; - long High, Low; - unsigned long Test; - - Result = True; - if ( (*pLow != ';') || (*pHigh != ';') || (Type <= 0) ) - Result = False; - - /* Is syntax ok ? */ - if ( Result != True ) { - fprintf(stderr,"\nSyntax error on sub range parameters!" ); - return(False); - } - Low = atol(++pLow); - High = atol(++pHigh); - - /* Special handling of type void */ - if ( (Low == 0) && (High == 0) ) { - /* Declare type void */ - pMap->ByteSize =0; - pMap->CoffType = T_VOID; - pMap->Line = ci->CurrentSourceLine; - return(True); - } - - if ( (pMap->CoffType = GetCoffType( Type )) != 0 ) { - pMap->ByteSize = GetCoffTypeSize( Type ); - } else { - /* Try to base everything off integer */ - pMap->ByteSize = FundamentalTypes[T_INT].Size; - } - - /* Now calculate the byte size */ - if ( High == 0 ) { - pMap->ByteSize = (unsigned short)Low; /* floating point */ - } else { - if ( Low == 0 ) { - /* Unsigned */ - Test = (unsigned long)High; - } else if ( Low < 0 ) { - /* signed */ - Test = (unsigned long)High << 1; - } else { - if ( Low <= High ) - Test = (unsigned long)High; - else - Test = (unsigned long)Low; - } - if ( pMap->ByteSize == 0 ) { - fprintf(stderr,"\nType Range Error 1, need previous type %d size!", pMap->CoffType ); - return(False); - } - for ( i = 0; i < sizeof(unsigned long); i++ ) { - if ( !(Test & (0xff << (i * 8))) ) - break; - } - pMap->ByteSize = i; - } - /* Now determine the best fit based on byte size, compare against IAR Compiler */ - if ( pMap->ByteSize == 1 ) { - if ( Low < 0 ) - pMap->CoffType = T_CHAR; - else - pMap->CoffType = T_UCHAR; - } else if ( pMap->ByteSize == 2 ) { - if ( Low < 0 ) - pMap->CoffType = T_INT; - else - pMap->CoffType = T_UINT; - } else if ( pMap->ByteSize == 4 ) { - if ( Low == 0 ) - pMap->CoffType = T_FLOAT; - if ( Low < 0 ) - pMap->CoffType = T_LONG; - else - pMap->CoffType = T_ULONG; - } else { - fprintf(stderr,"\nGetSubRangeType failure - byte size %d", pMap->ByteSize ); - return(False); - } - return(True); -} - -/****************************************************************************************/ -int CopyStabCoffMap( unsigned short StabType, STABCOFFMAP *pMap ){ - - STABCOFFMAP *p; - - for ( p = FindFirstListObject( &ci->ListOfTypes ); p != 0; p = FindNextListObject( &ci->ListOfTypes) ) { - if ( p->StabType == StabType ) { - memcpy( pMap, p, sizeof(STABCOFFMAP) ); - return(True); - } - } - return( False ); /* Nothing found */ -} - -/****************************************************************************************/ -unsigned short GetCoffType( unsigned short StabType ){ - - STABCOFFMAP *p; - - for ( p = FindFirstListObject( &ci->ListOfTypes ); p != 0; p = FindNextListObject( &ci->ListOfTypes) ) { - if ( p->StabType == StabType ) - return( p->CoffType ); - } - return( 0 ); /* Nothing found */ -} - -/****************************************************************************************/ -unsigned short GetCoffTypeSize( unsigned short StabType ){ - - STABCOFFMAP *p; - - for ( p = FindFirstListObject( &ci->ListOfTypes ); p != 0; p = FindNextListObject( &ci->ListOfTypes) ) { - if ( p->StabType == StabType ) - return( p->ByteSize ); - } - return( 0 ); /* Nothing found */ -} - - -/****************************************************************************************/ -int GetDigitLength( char *p ){ - - int i; - - if ( p == 0 ) - return(0); - - for ( i = 0; (*p != 0) && ( *p >= '0' ) && ( *p <= '9' ); i++ ); - - return( i ); - -} - -/****************************************************************************************/ -int GetStringDelimiters( char *pString, char **pTokens, int MaxTokens ){ - - int i; - char *p; - - p = pString; - - if ( !p ) - return( 0 ); - - for ( i = 0; i < MaxTokens; i++ ) { - while ( True ) { - if ( (*p == ':') || (*p == ';') || (*p == '=') || (*p == ',') || (*p == '"') || (*p == 0 ) ) { - *(pTokens + i) = p; /* Remember this location */ - p++; - if ( *p == 0 ) - return( i ); - break; - } - p++; - } - } - return( i ); -} - -/****************************************************************************************/ -int IsTypeArray( unsigned short CoffType ){ - - int Result; - - Result = False; - - if ( (CoffType & (DT_ARY << 4 )) == (DT_ARY << 4 ) ) - Result = True; - if ( (CoffType & (DT_ARY << 6 )) == (DT_ARY << 6 ) ) - Result = True; - if ( (CoffType & (DT_ARY << 8 )) == (DT_ARY << 8 ) ) - Result = True; - if ( (CoffType & (DT_ARY << 10 )) == (DT_ARY << 10 ) ) - Result = True; - if ( (CoffType & (DT_ARY << 12 )) == (DT_ARY << 12 ) ) - Result = True; - if ( (CoffType & (DT_ARY << 14 )) == (DT_ARY << 14 ) ) - Result = True; - - return(Result); -} - -/****************************************************************************************/ -void AddArrayAuxInfo( union auxent *pAux, unsigned short SymbolIndex, STABCOFFMAP *pMap ){ - - int i; - - pAux->x_sym.x_tagndx = SymbolIndex; /* point to the .bf entry index */ - pAux->x_sym.x_misc.x_lnsz.x_lnno = pMap->Line; - pAux->x_sym.x_misc.x_lnsz.x_size = pMap->ByteSize; - for ( i = 0; i < 4; i++ ) - pAux->x_sym.x_fcnary.x_ary.x_dimen[i] = pMap->Dimensions[i]; -} - -/****************************************************************************************/ -int AddNameToEntry( char *pName, struct syment *pEntry ) { - - int n; - char *p; - - n = strlen( pName ); /* see if it's 8 bytes or less */ - if ( n <= 8 ) { - strncpy( pEntry->n_name, pName, 8 ); - } else { - /* point to current offset in string table */ - pEntry->n_offset = ci->ListOfStrings.TotalBytes; - /* Allocate string table entry */ - if ( (p = (char *)AllocateListObject( &ci->ListOfStrings, n + 1 )) == 0 ) { - return(0); - } - strcpy( p, pName ); - } - return(n); /* return size of string */ -} - -/****************************************************************************************/ - -char *SkipPastDigits( char *p ){ - - if ( !p ) - return(p); -/* if ( *p == 0 ); */ /* JEG 5-01-03 */ - if ( *p == 0 ) - return(p); /* This line s/b indented JEG */ - for ( p--; (*p >= '0') && (*p <= '9') && (*p != 0); p-- ); - return(p); -} - -/****************************************************************************************/ - -/****************************************************************************************/ -/****************************************************************************************/ -/* List management routines */ -/****************************************************************************************/ -/****************************************************************************************/ - -/****************************************************************************************/ - -/****************************************************************************************/ -void InitializeList( LISTNODEHEAD *pHead ){ - - pHead->Node.Next = &pHead->Node; - pHead->Node.Last = &pHead->Node; - pHead->TotalBytes = 0; - pHead->TotalItems = 0; - pHead->current = &pHead->Node; - return; -} - -/****************************************************************************************/ - -void *AllocateTwoListObjects( LISTNODEHEAD *pHead, int size ){ - - void *p; - - if ( (p = AllocateListObject( pHead, size ) ) ) - pHead->TotalItems++; /* already incremented once in addtolist */ - return( p ); -} - -/****************************************************************************************/ -void *AllocateListObject( LISTNODEHEAD *pHead, int size ){ - - void *pObject; - - LISTNODE *pNode; - - if ( (pObject = calloc( 1, size )) != 0 ) { - if ( !(pNode = AddListObject( pHead, pObject, size )) ) { - free( pObject ); - pObject = 0; - } - } - return( pObject ); -} - -/****************************************************************************************/ -LISTNODE *AddListObject(LISTNODEHEAD *pHead, void *pObject, int size ){ - - LISTNODE *pNode; - - if ( (pNode = calloc( 1, sizeof(LISTNODE) )) != 0 ) { - pNode->pObject = pObject; - pNode->Size = size; - pNode->FileNumber = ci->CurrentFileNumber; - AddNodeToList( pHead, pNode ); - } - return( pNode ); -} - -/****************************************************************************************/ -LISTNODE *AllocateListNode( void *pObject, int size ){ - - LISTNODE *pNew; - - if ( (pNew = calloc( 1, sizeof( LISTNODE ) ) ) != 0 ) { - /* Then we initialize the node */ - pNew->pObject = pObject; - pNew->Size = size; - pNew->FileNumber = ci->CurrentFileNumber; - } - return(pNew); -} - -/****************************************************************************************/ -void AddNodeToList( LISTNODEHEAD *pHead, LISTNODE *pNode ){ - - LISTNODE *p; - - p = &pHead->Node; - - pNode->Next = p->Last->Next; - p->Last->Next = pNode; - pNode->Last = p->Last; - p->Last = pNode; - - /* and update current size of data contained in the list */ - pHead->TotalBytes += pNode->Size; - pHead->TotalItems++; -} - -/****************************************************************************************/ -void RemoveNodeFromList( LISTNODEHEAD *pHead, LISTNODE *pNode ){ - - pNode->Last->Next = pNode->Next; - pNode->Next->Last = pNode->Last; - - pHead->TotalBytes -= pNode->Size; - pHead->TotalItems--; -} - - -/****************************************************************************************/ -void *FindFirstListObject( LISTNODEHEAD *pHead ){ - - if ( pHead->Node.Next == &pHead->Node ) - return(0); /* Nothing in list */ - - pHead->current = pHead->Node.Next; - return( pHead->current->pObject ); -} -/****************************************************************************************/ -void *FindNextListObject( LISTNODEHEAD *pHead ){ - - if ( pHead->current->Next == &pHead->Node ) - return( 0 ); - - pHead->current = pHead->current->Next; - - return( pHead->current->pObject ); -} -/****************************************************************************************/ - -LISTNODE *GetCurrentNode( LISTNODEHEAD *pHead ){ - - return( pHead->current ); -} - -/****************************************************************************************/ -void *GetCurrentListObject( LISTNODEHEAD *pHead ){ - - return( pHead->current->pObject ); -} - - -/****************************************************************************************/ -void *FindLastListObject( LISTNODEHEAD *pHead ){ - - if ( pHead->Node.Last == &pHead->Node ) - return(0); /* Nothing in list */ - - pHead->current = pHead->Node.Last; - return( pHead->current->pObject ); -} -/****************************************************************************************/ -void *FindNextLastListObject( LISTNODEHEAD *pHead ){ - - if ( pHead->current->Last == &pHead->Node ) - return( 0 ); - - pHead->current = pHead->current->Last; - - return( pHead->current->pObject ); -} - -/****************************************************************************************/ - -void FreeList( LISTNODEHEAD *pHead ){ - - LISTNODE *pNode; - - for ( pNode = pHead->Node.Last; pNode->Next != &pHead->Node; pNode = pHead->Node.Last ) { - - RemoveNodeFromList( pHead, pNode ); - free( pNode->pObject ); - free( pNode ); - } - pHead->TotalBytes = 0; - pHead->TotalItems = 0; - pHead->current = &pHead->Node; +FILE * +open_coff_file(struct prog_info *pi, char *filename) +{ + + int ok; + FILE *fp; + char *p; + + + ci = calloc(1, sizeof(struct coff_info)); + if (!ci) + return (0); + + ok = True; + /* default values */ + ci->CurrentFileNumber = 0; + ci->pRomMemory = 0; + ci->pEEPRomMemory = 0; + ci->MaxRomAddress = 0; + ci->MaxEepromAddress = 0; + ci->NeedLineNumberFixup = 0; + ci->GlobalStartAddress = -1; + ci->GlobalEndAddress = 0; + + /* Linked lists start out at zero */ + InitializeList(&ci->ListOfSectionHeaders); + InitializeList(&ci->ListOfRawData); + InitializeList(&ci->ListOfRelocations); + InitializeList(&ci->ListOfLineNumbers); + InitializeList(&ci->ListOfSymbols); + InitializeList(&ci->ListOfGlobals); + InitializeList(&ci->ListOfSpecials); + InitializeList(&ci->ListOfUndefined); + InitializeList(&ci->ListOfStrings); + InitializeList(&ci->ListOfTypes); + InitializeList(&ci->ListOfSplitLines); + + /* add two default sections to SectionHeaders */ + if (!AllocateListObject(&ci->ListOfSectionHeaders, sizeof(struct external_scnhdr)) || + !AllocateListObject(&ci->ListOfSectionHeaders, sizeof(struct external_scnhdr))) { + + fprintf(stderr, "\nOut of memory allocating section headers!"); + return (0); + } + + /* add to string table */ + p = (char *)AllocateListObject(&ci->ListOfStrings, 4); + if (!p) { + fprintf(stderr, "\nOut of memory allocating string table space!"); + return (0); + } + + /* Allocate space for binary output into ROM, and EEPROM memory buffers for COFF output */ + /* ASSUMES ci->device is accurate */ + if ((ci->pRomMemory = AllocateListObject(&ci->ListOfRawData, pi->device->flash_size * 2)) != 0) { + if ((ci->pEEPRomMemory = AllocateListObject(&ci->ListOfRawData, pi->device->eeprom_size)) != 0) { + ok = True; /* only true if both buffers are properly allocated */ + /* now fill them with 0xff's to simulate flash erasure */ + memset((void *)ci->pRomMemory, 0xff, pi->device->flash_size * 2); + memset((void *)ci->pEEPRomMemory, 0xff, pi->device->eeprom_size); + } + } + if (ok != True) + return (0); + + fp = fopen(filename,"wb"); + if (fp == NULL) { + fprintf(stderr,"Error: cannot write coff file\n"); + return (fp); + } + /* simulate void type .stabs void:t15=r1;*/ + stab_add_local_type("void", "15=r1;0;0;"); + + return (fp); +} + +void +write_coff_file(struct prog_info *pi) +{ + + char *p; + struct external_scnhdr *pSectionHdr; + struct syment *pEntry; + union auxent *pAux; + unsigned long *plong; + int NumberOfSymbols, SymbolIndex, LastFileIndex, LastFunctionIndex, LastFunctionAddress; + LISTNODE *pNode; + int LinesOffset, SymbolsOffset, RawOffset; + struct lineno *pLine; + + /* add two special sections */ + /* one for .text */ + if ((pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSpecials, sizeof(struct syment) * 2)) == 0) { + fprintf(stderr, "\nOut of memory allocating special headers for .text!"); + return; + } + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".text"); + pEntry->n_value = 0; + pEntry->n_scnum = 1; + pEntry->n_type = 0; + pEntry->n_sclass = C_STAT; + pEntry->n_numaux = 1; + pEntry++; + pAux = (union auxent *)pEntry; + pAux->x_scn.x_scnlen = ci->MaxRomAddress + 2; + pAux->x_scn.x_nreloc = 0; + pAux->x_scn.x_nlinno = ci->ListOfLineNumbers.TotalItems; + /* one for .bss */ + if ((pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSpecials, sizeof(struct syment) * 2)) == 0) { + fprintf(stderr, "\nOut of memory allocating special header for .bss!"); + return; + } + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".bss"); + if (ci->GlobalStartAddress == -1) { + ci->GlobalEndAddress = ci->GlobalStartAddress = 0x60; + } + pEntry->n_value = ci->GlobalStartAddress; + pEntry->n_scnum = 2; + pEntry->n_type = 0; + pEntry->n_sclass = C_STAT; + pEntry->n_numaux = 1; + pEntry++; + pAux = (union auxent *)pEntry; + pAux->x_scn.x_scnlen = 0; /* we don't store any data here */ + pAux->x_scn.x_nreloc = 0; + pAux->x_scn.x_nlinno = 0; + + /* one more for .data - eeprom ??? */ + + /* Calculate common offsets into the file */ + RawOffset = sizeof(struct external_filehdr) + ci->ListOfSectionHeaders.TotalBytes; + LinesOffset = RawOffset + ci->MaxRomAddress + 2; /* ignore eeprom for now */ + SymbolsOffset = LinesOffset + ci->ListOfLineNumbers.TotalBytes; + + /* Clean up loose ends in string table */ + if (!(plong = (unsigned long *)FindFirstListObject(&ci->ListOfStrings))) { + fprintf(stderr,"\nInternal error in string table!"); + return; + } + *plong = ci->ListOfStrings.TotalBytes; /* Size of string table */ + + /* Clean up loose ends in symbol table */ + + /* symbol table - Filename value - index to next .file or global symbol */ + /* The value of that symbol equals the symbol table entry index of the next .file symbol or .global */ + LastFunctionAddress = ci->MaxRomAddress; + NumberOfSymbols = ci->ListOfSymbols.TotalItems + ci->ListOfSpecials.TotalItems + ci->ListOfGlobals.TotalItems; + SymbolIndex = LastFileIndex = NumberOfSymbols; + LastFunctionIndex = 0; /* set to zero on last function */ + for (pEntry = (struct syment *)FindLastListObject(&ci->ListOfSymbols); + pEntry != 0; + pEntry = (struct syment *)FindNextLastListObject(&ci->ListOfSymbols)) { + + /* Search for .file entries designated by C_FILE */ + if (pEntry->n_sclass == C_FILE) { + pEntry->n_value = LastFileIndex; + LastFileIndex = SymbolIndex; /* save current index */ + } + /* Search for Function entries C_EXT */ + else if (pEntry->n_sclass == C_EXT) { + pEntry++; + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_fsize = LastFunctionAddress - pEntry->n_value; /* function updated size */ + pAux->x_sym.x_fcnary.x_fcn.x_lnnoptr += LinesOffset; + LastFunctionAddress = pEntry->n_value; + pAux->x_sym.x_fcnary.x_fcn.x_endndx = LastFunctionIndex; /* point to next function index */ + pAux->x_sym.x_tvndx = 0; /* ??? */ + LastFunctionIndex = SymbolIndex; + } else if ((pEntry->n_sclass == C_FCN) || (pEntry->n_sclass == C_BLOCK)) { + if (pEntry->n_name[1] == 'b') { + /* .bf and .bb */ + pEntry++; + pAux = (union auxent *)pEntry; + pAux->x_sym.x_fcnary.x_fcn.x_endndx = LastFunctionIndex; + } + } + /* else do nothing */ + + /* update current symbol index */ + pNode = GetCurrentNode(&ci->ListOfSymbols); + SymbolIndex -= (pNode->Size / sizeof(struct syment)); + } + + /* File Header */ + ci->FileHeader.f_magic = MAGIC_NUMBER_AVR; + ci->FileHeader.f_nscns = 2; + ci->FileHeader.f_timdat = pi->time; + ci->FileHeader.f_symptr = SymbolsOffset; + ci->FileHeader.f_nsyms = NumberOfSymbols; + ci->FileHeader.f_opthdr = 0; + ci->FileHeader.f_flags = 0xff; /*F_RELFLG;*/ /* No relocation information available */ + + /* write it out */ + if (fwrite(&ci->FileHeader, 1, sizeof(struct external_filehdr), pi->coff_file) != sizeof(struct external_filehdr)) { + fprintf(stderr,"\nFile error writing header ...(disk full?)"); + return; + } + + /* Optional Information */ + + /* Section 1 Header */ + pSectionHdr = (struct external_scnhdr *)FindFirstListObject(&ci->ListOfSectionHeaders); + if (!pSectionHdr) { + fprintf(stderr, "\nInternal Coff error - cannot find section header .text!"); + return; + } + memset(&pSectionHdr->s_name[0], 0, sizeof(struct external_scnhdr)); + strcpy(&pSectionHdr->s_name[0], ".text"); + pSectionHdr->s_paddr = 0; + pSectionHdr->s_vaddr = 0; + pSectionHdr->s_size = ci->MaxRomAddress + 2; /* remember the last instruction */ + pSectionHdr->s_scnptr = RawOffset; + pSectionHdr->s_relptr = 0; + pSectionHdr->s_lnnoptr = LinesOffset; + pSectionHdr->s_nreloc = 0; + pSectionHdr->s_nlnno = ci->ListOfLineNumbers.TotalBytes/sizeof(struct lineno); + pSectionHdr->s_flags = STYP_TEXT; + + /* write it out */ + if (fwrite(&pSectionHdr->s_name[0], 1, sizeof(struct external_scnhdr), pi->coff_file) != sizeof(struct external_scnhdr)) { + fprintf(stderr,"\nFile error writing section header ...(disk full?)"); + return; + } + + /* Section 2 Header */ + pSectionHdr = (struct external_scnhdr *)FindNextListObject(&ci->ListOfSectionHeaders); + if (!pSectionHdr) { + fprintf(stderr, "\nInternal Coff error - cannot find section header .bss!"); + return; + } + memset(&pSectionHdr->s_name[0], 0, sizeof(struct external_scnhdr)); + strcpy(&pSectionHdr->s_name[0], ".bss"); + /* later expansion */ + pSectionHdr->s_paddr = ci->GlobalStartAddress; + pSectionHdr->s_vaddr = ci->GlobalStartAddress; + pSectionHdr->s_flags = STYP_DATA; /* seems it should be STYP_BSS */ + + /* write it out */ + if (fwrite(&pSectionHdr->s_name[0], 1, sizeof(struct external_scnhdr), pi->coff_file) != sizeof(struct external_scnhdr)) { + fprintf(stderr,"\nFile error writing section header ...(disk full?)"); + return; + } + + /* Section N Header - .data or eeprom */ + + /* Raw Data for Section 1 */ + if ((p = FindFirstListObject(&ci->ListOfRawData)) == 0) { + fprintf(stderr,"\nInternal error - unable to find binary data!"); + return; + } + + /* write it out */ + if (fwrite(p, 1, ci->MaxRomAddress + 2, pi->coff_file) != (size_t)(ci->MaxRomAddress + 2)) { + fprintf(stderr,"\nFile error writing raw .text data ...(disk full?)"); + return; + } + /* Raw data for section n */ + + /* Relocation Info for section 1 */ + + /* Relocation info for section n */ + + /* Line numbers for section 1 */ + for (pLine = (struct lineno *)FindFirstListObject(&ci->ListOfLineNumbers); + pLine != 0; + pLine = (struct lineno *)FindNextListObject(&ci->ListOfLineNumbers)) { + + pNode = GetCurrentNode(&ci->ListOfLineNumbers); + + /* write it out */ + if (fwrite(pLine, 1, pNode->Size, pi->coff_file) != pNode->Size) { + fprintf(stderr,"\nFile error writing line numbers ...(disk full?)"); + return; + } + } + + + /* Line numbers for section n */ + + /* Symbol table */ + for (pEntry = (struct syment *)FindFirstListObject(&ci->ListOfSymbols); + pEntry != 0; + pEntry = (struct syment *)FindNextListObject(&ci->ListOfSymbols)) { + + pNode = GetCurrentNode(&ci->ListOfSymbols); + + /* write it out */ + if (fwrite(pEntry, 1, pNode->Size, pi->coff_file) != pNode->Size) { + fprintf(stderr,"\nFile error writing symbol table ...(disk full?)"); + return; + } + } + + /* Symbol table of Globals */ + for (pEntry = (struct syment *)FindFirstListObject(&ci->ListOfGlobals); + pEntry != 0; + pEntry = (struct syment *)FindNextListObject(&ci->ListOfGlobals)) { + + pNode = GetCurrentNode(&ci->ListOfGlobals); + + /* write it out */ + if (fwrite(pEntry, 1, pNode->Size, pi->coff_file) != pNode->Size) { + fprintf(stderr,"\nFile error writing global symbols ...(disk full?)"); + return; + } + } + + /* Specials .text, .bss, .data */ + + for (pEntry = (struct syment *)FindFirstListObject(&ci->ListOfSpecials); + pEntry != 0; + pEntry = (struct syment *)FindNextListObject(&ci->ListOfSpecials)) { + + pNode = GetCurrentNode(&ci->ListOfSpecials); + + /* write it out */ + if (fwrite(pEntry, 1, pNode->Size, pi->coff_file) != pNode->Size) { + fprintf(stderr,"\nFile error writing special symbols ...(disk full?)"); + return; + } + } + + /* String Table */ + for (p = (char *)FindFirstListObject(&ci->ListOfStrings); + p != 0; + p = (char *)FindNextListObject(&ci->ListOfStrings)) { + + pNode = GetCurrentNode(&ci->ListOfStrings); + + /* write it out */ + if (fwrite(p, 1, pNode->Size, pi->coff_file) != pNode->Size) { + fprintf(stderr,"\nFile error writing strings data ...(disk full?)"); + return; + } + } + + return; +} + +void +write_coff_eeprom(struct prog_info *pi, int address, unsigned char data) +{ + + /* Coff output keeps track of binary data in memory buffers */ + if (ci->pEEPRomMemory) { + if (address <= pi->device->eeprom_size) { + *(ci->pEEPRomMemory + address) = data; + if (address >= ci->MaxEepromAddress) + ci->MaxEepromAddress = address; /* keep high water mark */ + } else { + pi->error_count++; + fprintf(stderr, "Error: EEPROM address %d exceeds max range %ld", address, pi->device->eeprom_size); + } + } +} + +void +write_coff_program(struct prog_info *pi, int address, unsigned int data) +{ + + unsigned char *pByte; + + /* Coff output keeps track of binary data in memory buffers, address is in bytes not words */ + if (ci->pRomMemory) { + /* JEG if ( address <= pi->device->flash_size ) { */ /* JEG 4-23-03 */ + if (address <= pi->device->flash_size*2) { + pByte = (unsigned char *)(ci->pRomMemory + address); /* point to low byte in memory */ + *pByte++ = (data & 0xff); /* low byte */ + *pByte = ((data >> 8) & 0xff); /* high byte */ + + if (address >= ci->MaxRomAddress) + ci->MaxRomAddress = address; /* keep high water mark */ + } else { + pi->error_count++; + /* JEG fprintf(stderr, "Error: FLASH address %d exceeds max range %d", address, pi->device->flash_size ); */ + fprintf(stderr, "Error: FLASH address %d exceeds max range %ld", address, pi->device->flash_size*2); + } + } +} + +void +close_coff_file(struct prog_info *pi, FILE *fp) +{ + + /* close the output file */ + fclose(fp); + pi->coff_file = 0; + + /* free all the internal memory buffers used by ci */ + + FreeList(&ci->ListOfSectionHeaders); + FreeList(&ci->ListOfRawData); + FreeList(&ci->ListOfRelocations); + FreeList(&ci->ListOfLineNumbers); + FreeList(&ci->ListOfSymbols); + FreeList(&ci->ListOfGlobals); + FreeList(&ci->ListOfUndefined); + FreeList(&ci->ListOfStrings); + FreeList(&ci->ListOfTypes); + FreeList(&ci->ListOfSplitLines); + + /* now free ci */ + free(ci); + ci = 0; +} + +int +parse_stabs(struct prog_info *pi, char *p) +{ + + int ok = True; + int TypeCode, n; + char *pString, *p2, *p3, *p4, *p5, *pType, *pp, *pJoined; + + + if (!GET_ARG_I(pi->args, ARG_COFF) || (pi->pass == PASS_1)) + return (True); + + /* stabs debugging information is in the form: + .stabs "symbolic info string", HexorDecimalTypecode, parm3, parm4, parm5 + parm1, parm2, parm3 depend on typecode + + N_LSYM 0x80 local sym: name,,0,type,offset + N_OPT 0x3c compiler options + N_SO 0x64 source file name: name,,0,0,address + N_SOL 0x84 #included file name: name,,0,0,address + N_FUN 0x24 procedure: name,,0,linenumber,address + N_GSYM 0x20 global symbol: name,,0,type,0 + N_LCSYM 0x28 .lcomm symbol: name,,0,type,address + N_STSYM 0x26 static symbol: name,,0,type,address + N_RSYM 0x40 register sym: name,,0,type,register + N_PSYM 0xa0 parameter: name,,0,type,offset + + */ + + /* Look for multiple commands per line */ + + /* .stabs "linktag:T19=s46next:20=*19,0,16;last:20,16,16;a:21=ar1;0;2;22=ar1;0;3;1,32,96;\\",128,0,0,0 */ + /* .stabs "b:23=ar1;0;4;24=ar1;0;5;2,128,240;;",128,0,0,0 */ + + + /* Look for continuation lines per line */ + + /* Get String information as a token */ + /* Parse the tokens in the stabn line buffer */ + pString = get_next_token(p, TERM_DOUBLEQUOTE); /* zap first doublequote */ + p2 = get_next_token(pString, TERM_DOUBLEQUOTE); /* zap last doublequote */ + p2 = get_next_token(p2, TERM_COMMA); /* zap comma */ + p3 = get_next_token(p2, TERM_COMMA); + p4 = get_next_token(p3, TERM_COMMA); + p5 = get_next_token(p4, TERM_COMMA); + get_next_token(p5, TERM_END); /* zap CR LF, make ASCIIZ */ + + if (!pString || !p2 || !p3 || !p4 || !p5) + return (False); + + /* Check for split lines */ + n = strlen(pString); + if ((pString[n - 1] == '\\') && (pString[n - 2] == '\\')) { + /* We have a continuation string here */ + pString[n - 2] = 0; + n -= 2; + if (!(pp = (char *)AllocateListObject(&ci->ListOfSplitLines, n + 1))) { + fprintf(stderr, "\nOut of memory allocating continuation line!"); + return (False); + } + strcpy(pp, pString); /* loose the continuation characters */ + return (True); + } + if (ci->ListOfSplitLines.TotalItems > 0) { + /* Join lines together and process */ + if (!(pJoined = calloc(1, n + ci->ListOfSplitLines.TotalBytes))) { + fprintf(stderr, "\nOut of memory joining continuation lines!"); + return (False); + } + for (pp = (char *)FindFirstListObject(&ci->ListOfSplitLines); + pp != 0; + pp = (char *)FindNextListObject(&ci->ListOfSplitLines)) { + + strcat(pJoined, pp); /* connect the lines */ + } + strcat(pJoined, pString); + FreeList(&ci->ListOfSplitLines); + if (!AddListObject(&ci->ListOfSplitLines, pJoined, n + ci->ListOfSplitLines.TotalBytes)) { + fprintf(stderr, "\nUnable to add joined continuation line"); + return (False); + } + pString = pJoined; + } + + + if (*p2 == '0') + TypeCode = atox(p2); /* presume to be hex 0x */ + else + TypeCode = atoi(p2); + + switch (TypeCode) { + + case N_OPT: /* compiler options */ + break; /* nothing used here */ + + case N_SO: /* source file name: name,,0,0,address */ + ok = stab_add_filename(pString, p5); + break; + + case N_GSYM: /* global symbol: name,,0,type,0 */ + pType = get_next_token(pString, TERM_COLON); /* separate at colon */ + ok = stab_add_global(pi, pString, pType); + break; + + case N_FUN: /* procedure: name,,0,linenumber,address */ + ok = stab_add_function(pi, pString, p5); + break; + + case N_LSYM: /* local sym: name,,0,type,offset */ + /* pString, p2 = TypeCode, p3 = 0, p4 = 0, p5 = offset */ + pType = get_next_token(pString, TERM_COLON); /* pType = symbol descriptor (character after the colon) */ + if (*pType == 't') + ok = stab_add_local_type(pString, ++pType); + else if (*pType == 'T') + ok = stab_add_tag_type(pString, ++pType); + else + ok = stab_add_local(pi, pString, pType, p5); + break; + + case N_RSYM: /* Symbol:[P|r]type,0,size,register */ + pType = get_next_token(pString, TERM_COLON); /* separate at colon */ + ok = stab_add_local_register(pi, pString, pType, p5); + break; + + case N_LCSYM: /* .lcomm symbol: name,,0,type,address */ + ok = True; + break; /* ignore constants */ + + case N_STSYM: /* static symbol: name,,0,type,address */ + pType = get_next_token(pString, TERM_COLON); /* separate at colon */ + ok = stab_add_static_symbol(pi, pString, pType, p5); + break; + + case N_PSYM: /* parameter: name,,0,type,offset */ + pType = get_next_token(pString, TERM_COLON); /* separate at colon */ + ok = stab_add_parameter_symbol(pi, pString, pType, p5); + break; + + case N_SOL: /* #included file name: name,,0,0,address */ + ok = True; + break; /* ignore include files */ + + default: + ok = False; + } + + if (ci->ListOfSplitLines.TotalItems > 0) + FreeList(&ci->ListOfSplitLines); + + return (ok); +} + +int +parse_stabn(struct prog_info *pi, char *p) +{ + + int ok = True; + int TypeCode, Level; + char *p1, *p2, *p3, *p4, *pLabel, *pFunction; + + /* stabn debugging information is in the form: + .stabn TypeCode, 0, parm1, parm2 + parm1 is level + parm2 is Label-Function + + compiler currently produces the following TypeCodes: + N_LBRAC 0xc0 left bracket: 0,,0,nesting level,address + N_RBRAC 0xe0 right bracket: 0,,0,nesting level,address + N_SLINE 0x44 src line: 0,,0,linenumber,address + */ + + if (!GET_ARG_I(pi->args, ARG_COFF) || (pi->pass == PASS_1)) + return (True); + + /* Parse the tokens in the stabn line buffer */ + p1 = get_next_token(p, TERM_SPACE); + p2 = get_next_token(p1, TERM_COMMA); + p3 = get_next_token(p2, TERM_COMMA); + p4 = get_next_token(p3, TERM_COMMA); + get_next_token(p4, TERM_END); /* zap CR LF, make ASCIIZ */ + + if (!p1 || !p2 || !p3 || !p4) + return (False); + + /* first convert TypeCode to binary */ + if (*p1 == '0') + TypeCode = atox(p1); /* presume to be hex 0x */ + else + TypeCode = atoi(p1); + + Level = atoi(p3); /* line number or level */ + pLabel = p4; /* Assembly label */ + pFunction = get_next_token(pLabel, TERM_DASH); /* Function */ + + switch (TypeCode) { + case N_SLINE: /* src line: 0,,0,linenumber,address */ + ok = stab_add_lineno(pi, Level, pLabel, pFunction); + break; + + case N_LBRAC: /* left bracket: 0,,0,nesting level,address */ + ok = stab_add_lbracket(pi, Level, pLabel, pFunction); + break; + + case N_RBRAC: /* right bracket: 0,,0,nesting level,address */ + ok = stab_add_rbracket(pi, Level, pLabel, pFunction); + break; + + default: + fprintf(stderr, "\nUnknown .stabn TypeCode = 0x%x", TypeCode); + ok = False; + } + return (ok); +} + +int +stab_add_lineno(struct prog_info *pi, int LineNumber, char *pLabel, char *pFunction) +{ + + int Address; + struct lineno *pln; + struct syment *pEntry; + union auxent *pAux; + + /* Allocate LineNumber Table entry and fill it in */ + pln = (struct lineno *)AllocateListObject(&ci->ListOfLineNumbers, sizeof(struct lineno)); + if (!pln) { + fprintf(stderr, "\nOut of memory allocating lineno table for function %s", pFunction); + return (False); + } + /* set value field to be address of label in bytes */ + if (!get_symbol(pi, pLabel, &Address)) { + fprintf(stderr, "\nUnable to locate label %s", pLabel); + return (False); + } + pln->l_addr.l_paddr = Address * 2; /* need byte quanities */ + + /* Line number is relative to beginning of function, starts at 1 */ + if (ci->FunctionStartLine == 0) { + /* This line number is that same as the function start */ + ci->FunctionStartLine = LineNumber; + } + pln->l_lnno = LineNumber - ci->FunctionStartLine + 1; + ci->CurrentSourceLine = LineNumber; /* keep track of source line for .eb .ef arrays */ + if (ci->NeedLineNumberFixup) { + /* need to go into symbol table and fix last NeedLineNumberFixup entries */ + for (pEntry = (struct syment *)FindLastListObject(&ci->ListOfSymbols); + (pEntry != 0) && (ci->NeedLineNumberFixup != 0); + pEntry = (struct syment *)FindNextLastListObject(&ci->ListOfSymbols)) { + + /* Fix up line number entries */ + if ((pEntry->n_sclass == C_FCN) || (pEntry->n_sclass == C_BLOCK) || (pEntry->n_sclass == C_EXT)) { + pEntry++; + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_lnsz.x_lnno = LineNumber; + ci->NeedLineNumberFixup--; + } + } + } + + return (True); +} + +int +stab_add_lbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction) +{ + + int Address; + struct syment *pEntry; + union auxent *pAux; + + if (!get_symbol(pi, pLabel, &Address)) { + fprintf(stderr, "\nUnable to locate label %s", pLabel); + return (False); + } + + /* Now create a .bb symbol table entry and aux entry too */ + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSymbols, sizeof(struct syment) * 2); + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry for .bb %s", pLabel); + return (False); + } + /* n_name */ + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".bb"); + + pEntry->n_value = Address * 2; /* bytes not words */ + pEntry->n_scnum = 1; /* .text */ + pEntry->n_type = 0; + pEntry->n_sclass = C_BLOCK; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_lnsz.x_lnno = 0; /* UNKNOWN - post process */ + pAux->x_sym.x_misc.x_lnsz.x_size = 0; /* UNKNOWN - post process */ + ci->NeedLineNumberFixup++; /* once for .bb block */ + return (True); +} + +int +stab_add_rbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction) +{ + + int Address; + struct syment *pEntry; + union auxent *pAux; + + if (!get_symbol(pi, pLabel, &Address)) { + fprintf(stderr, "\nUnable to locate label %s", pLabel); + return (False); + } + + /* Now create a .eb symbol table entry */ + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSymbols, sizeof(struct syment) * 2); + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry for .eb %s", pLabel); + return (False); + } + /* n_name */ + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".eb"); + pEntry->n_sclass = C_BLOCK; + pEntry->n_value = Address * 2; /* bytes not words */ + pEntry->n_scnum = 1; /* .text */ + pEntry->n_type = 0; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_lnsz.x_lnno = ci->CurrentSourceLine; + + /* create an .ef if at level 0 */ + if (Level == 0) { + + /* Now create a .ef symbol table entry */ + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSymbols, sizeof(struct syment) * 2); + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry for .ef %s", pLabel); + return (False); + } + /* n_name */ + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".ef"); + pEntry->n_sclass = C_FCN; + pEntry->n_value = Address * 2; /* bytes not words */ + pEntry->n_scnum = 1; /* .text */ + pEntry->n_type = 0; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_lnsz.x_lnno = ci->CurrentSourceLine; + } + return (True); +} + +int +stab_add_filename(char *pName, char *pLabel) +{ + + int ok, n; + struct syment *pEntry; + union auxent *pAux; + char *p; + + /* if( pLabel == "Ltext0" ) then beginning of .text, pName = cwd, next pName = file */ + + /* if( pLabel == "Letext" ) then end of .text , pName == NULL */ + + /* we only need the one not ending in Slash */ + ok = True; + n = strlen(pName); + if (n > 0) { + if ((pName[ n - 1] == '\\') || (pName[ n - 1] == '/')) + return (True); /* ignore */ + } else + return (True); + + + /* allocate entry in symbol table list */ + pEntry = (struct syment *)AllocateTwoListObjects( + &ci->ListOfSymbols, sizeof(struct syment) * 2); /* aux entry too */ + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry for global %s", pName); + return (False); + } + /* n_name */ + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".file"); + /* n_value is determined after processing done UNKNOWN - post process */ + /* The value of that symbol equals the symbol table entry index of the next .file symbol or .global */ + /* post process */ + pEntry->n_scnum = N_DEBUG; + pEntry->n_sclass = C_FILE; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + + /* Add Label name to symbol table */ + if (n <= FILNMLEN) { + /* inline filename */ + memset(pAux->x_file.x_fname, 0, FILNMLEN); + strncpy(pAux->x_file.x_fname, pName, n); /* might not be zero terminated */ + } else { + pAux->x_file.x_n.x_zeroes = 0; /* symbol name is in string table */ + pAux->x_file.x_n.x_offset = ci->ListOfStrings.TotalBytes; + + /* add to string table */ + p = (char *)AllocateListObject(&ci->ListOfStrings, n + 1); + if (!p) { + fprintf(stderr, "\nOut of memory allocating string table space!"); + return (False); + } + strcpy(p, pName); + } + return (ok); +} + +int +stab_add_function(struct prog_info *pi, char *pName, char *pLabel) +{ + + int n, Address; + unsigned short CoffType, Type; + struct syment *pEntry; + char *pType; + struct lineno *pln; + union auxent *pAux; + int SymbolIndex; + + pType = get_next_token(pName, TERM_COLON); /* pType = symbol descriptor (character after the colon) */ + Type = atoi(pType + 1); /* skip past F, predefined variable type */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized return type found for function %s = %d", pName, Type); + return (False); + } + /* Get Current Symbol Index, Allocate Symbol Table entry and fill it in */ + SymbolIndex = ci->ListOfSymbols.TotalItems; + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSymbols, sizeof(struct syment) * 2); + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry for function %s", pName); + return (False); + } + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + } + if (!get_symbol(pi, pLabel, &Address)) { + fprintf(stderr, "\nUnable to locate function %s", pName); + return (False); + } + pEntry->n_value = Address * 2; /* convert words to bytes */ + pEntry->n_scnum = 2; /* .bss */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for function %s = %d", pName, Type); + return (False); + } + pEntry->n_type = (unsigned short)(CoffType | (DT_FCN << 4)); + pEntry->n_sclass = C_EXT; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_tagndx = SymbolIndex + 1; /* point to the .bf entry index */ + pAux->x_sym.x_misc.x_fsize = 0; /* unknown till end */ + pAux->x_sym.x_fcnary.x_fcn.x_lnnoptr = ci->ListOfLineNumbers.TotalBytes; /* relative offset to line number entry */ + pAux->x_sym.x_fcnary.x_fcn.x_endndx = 0; /* index to next entry */ + + /* Now add function entry into the line number table */ + /* Allocate Symbol Table entry and fill it in */ + pln = (struct lineno *)AllocateListObject(&ci->ListOfLineNumbers, sizeof(struct lineno)); + if (!pln) { + fprintf(stderr, "\nOut of memory allocating lineno table for function %s", pName); + return (False); + } + pln->l_lnno = 0; + pln->l_addr.l_symndx = SymbolIndex; + + /* Initialize the FunctionStartLine from the beginning of the function */ + ci->FunctionStartLine = 0; + + /* Allocate Symbol Table entry and fill it in */ + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfSymbols, sizeof(struct syment) * 2); + if (!pEntry) { + fprintf(stderr, "\nOut of memory allocating symbol table entry .bf for function %s", pName); + return (False); + } + memset(pEntry->n_name, 0, 8); + strcpy(pEntry->n_name, ".bf"); + pEntry->n_value = Address * 2; /* bytes not words */ + pEntry->n_scnum = 1; /* .text */ + pEntry->n_type = 0; + pEntry->n_sclass = C_FCN; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_misc.x_lnsz.x_lnno = 0; /* UNKNOWN - post process */ + pAux->x_sym.x_misc.x_lnsz.x_size = 0; /* UNKNOWN - post process */ + + ci->NeedLineNumberFixup++; /* once for function C_EXT symbol */ + ci->NeedLineNumberFixup++; /* once for .bf block */ + return (True); +} + +int +stab_add_global(struct prog_info *pi, char *pName, char *pType) +{ + + int n, Address, IsArray, SymbolIndex; + unsigned short CoffType, Type; + struct syment *pEntry; + char *p; + STABCOFFMAP *pMap; + + + n = strlen(pName); /* see if it's 8 bytes or less */ + Type = atoi(pType + 1); /* skip past G, predefined variable type */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for global %s = %d", pName, Type); + return (False); + } + pMap = (STABCOFFMAP *)GetCurrentListObject(&ci->ListOfTypes); + + SymbolIndex = ci->ListOfSymbols.TotalItems; + /* Allocate Symbol Table entry and fill it in, Auxiliary table if its an array */ + if (IsTypeArray(CoffType) == True) { + IsArray = True; + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfGlobals, sizeof(struct syment) * 2); + } else { + IsArray = False; + pEntry = (struct syment *)AllocateListObject(&ci->ListOfGlobals, sizeof(struct syment)); + } + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + } + /* set value field to be address of label in bytes */ + /* add underscore to lookup label */ + if ((p = calloc(1, n + 2)) == 0) { + fprintf(stderr,"\nOut of memory adding global %s", pName); + return (False); + } + *p = '_'; + strcpy(p + 1, pName); + if (!get_symbol(pi, p, &Address)) { + fprintf(stderr, "\nUnable to locate global %s", p); + free(p); + return (False); + } + free(p); + pEntry->n_value = Address; /* already in bytes */ + if (ci->GlobalStartAddress == -1) { + ci->GlobalStartAddress = Address; + } + if (Address < ci->GlobalStartAddress) + ci->GlobalStartAddress = Address; + if (Address > ci->GlobalEndAddress) + ci->GlobalEndAddress = Address; + + pEntry->n_scnum = 2; /* .bss */ + pEntry->n_type = CoffType; + pEntry->n_sclass = C_STAT; + if (IsArray == False) + pEntry->n_numaux = 0; + else { + pEntry->n_numaux = 1; + pEntry++; + AddArrayAuxInfo((union auxent *)pEntry, (unsigned short)SymbolIndex, pMap); + } + return (True); +} + +int +stab_add_local(struct prog_info *pi, char *pName, char *pType, char *pOffset) +{ + + int n, Offset, IsArray; + unsigned short CoffType, Type, SymbolIndex; + struct syment *pEntry; + STABCOFFMAP *pMap; + + n = strlen(pName); /* see if it's 8 bytes or less */ + Type = atoi(pType); /* predefined variable type */ + Offset = atoi(pOffset); /* offset in stack frame */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for local %s = %d", pName, Type); + return (False); + } + pMap = (STABCOFFMAP *)GetCurrentListObject(&ci->ListOfTypes); + SymbolIndex = ci->ListOfSymbols.TotalItems; + /* Allocate Symbol Table entry and fill it in, Auxiliary table if its an array */ + if (IsTypeArray(CoffType) == True) { + IsArray = True; + pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfGlobals, sizeof(struct syment) * 2); + } else { + IsArray = False; + pEntry = (struct syment *)AllocateListObject(&ci->ListOfSymbols, sizeof(struct syment)); + } + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + } + pEntry->n_type = CoffType; + pEntry->n_sclass = C_AUTO; + pEntry->n_scnum = N_ABS; + pEntry->n_value = Offset + 1; /* Silly avr studio is set in its ways */ + if (IsArray == False) + pEntry->n_numaux = 0; + else { + pEntry->n_numaux = 1; + pEntry++; + AddArrayAuxInfo((union auxent *)pEntry, SymbolIndex, pMap); + } + return (True); +} + +int +stab_add_parameter_symbol(struct prog_info *pi, char *pName, char *pType, char *pOffset) +{ + + int n, Offset; + unsigned short CoffType, Type; + struct syment *pEntry; + + n = strlen(pName); /* see if it's 8 bytes or less */ + Type = atoi(pType); /* predefined variable type */ + Offset = atoi(pOffset); /* offset in stack frame */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type); + return (False); + } + /* Allocate Symbol Table entry and fill it in */ + pEntry = (struct syment *)AllocateListObject(&ci->ListOfSymbols, sizeof(struct syment)); + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + } + pEntry->n_type = CoffType; + pEntry->n_sclass = C_ARG; + pEntry->n_scnum = N_ABS; + pEntry->n_value = Offset; + pEntry->n_numaux = 0; + return (True); +} + +int +stab_add_static_symbol(struct prog_info *pi, char *pName, char *pType, char *pLabel) +{ + + int n, Address; + unsigned short CoffType, Type; + struct syment *pEntry; + + n = strlen(pName); /* see if it's 8 bytes or less */ + Type = atoi(pType + 1); /* skip past S, predefined variable type */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type); + return (False); + } + /* Allocate Symbol Table entry and fill it in */ + pEntry = (struct syment *)AllocateListObject(&ci->ListOfSymbols, sizeof(struct syment)); + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + } + pEntry->n_type = CoffType; + pEntry->n_sclass = C_STAT; + pEntry->n_scnum = N_ABS; + if (!get_symbol(pi, pLabel, &Address)) { + fprintf(stderr, "\nUnable to locate label %s", pLabel); + return (False); + } + pEntry->n_value = Address * 2; /* find address of variable in bytes */ + pEntry->n_numaux = 0; + return (True); +} + +int +stab_add_local_register(struct prog_info *pi, char *pName, char *pType, char *pRegister) +{ + + int n, Register, Size; + unsigned short CoffType, Type; + struct syment *pEntry; + + n = strlen(pName); /* see if it's 8 bytes or less */ + Type = (unsigned short)atoi(pType + 1); /* skip past P, predefined variable type */ + Register = atoi(pRegister); /* offset in stack frame */ + if ((CoffType = GetCoffType(Type)) == 0) { + fprintf(stderr, "\nUnrecognized type found for %s = %d", pName, Type); + return (False); + } + Size = GetCoffTypeSize(Type); /* Silly requirement for avr studio */ + /* Allocate Symbol Table entry and fill it in */ + pEntry = (struct syment *)AllocateListObject(&ci->ListOfSymbols, sizeof(struct syment)); + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pName); + return (False); + } + pEntry->n_type = CoffType; + pEntry->n_sclass = C_REGPARM; /* Silly avr studio only accepts this for registers */ + pEntry->n_scnum = N_ABS; + pEntry->n_numaux = 0; + if (Size == 1) + pEntry->n_value = 0xffffff00 | Register; /* Silly requirement for avr studio */ + else if (Size == 2) + pEntry->n_value = 0xffff0000 | ((Register + 1) << 8) | Register; /* Silly requirement for avr studio */ + else if (Size == 4) + pEntry->n_value = ((Register + 3) << 24) | ((Register + 3) << 16) | ((Register + 1) << 8) | Register; /* Silly requirement for avr studio */ + else { + fprintf(stderr,"\nUnknown register size (%d) and coff type (%d)", Size, CoffType); + return (False); + } + return (True); +} + +int +stab_add_local_type(char *pName, char *pType) +{ + + char *p; + unsigned short StabType; + + /* .stabs "int:t1=r1;-128;127;",128,0,0,0 */ + /* .stabs ":t20=ar1;0;1;21=ar1;0;1;2",128,0,0,0 */ + /* pType-----^ */ + /* Stab Type - convert to Coff type at end (after inline assignments */ + if (GetStabType(pType, &StabType, &p) != True) { + fprintf(stderr,"\nInvalid tag type found in structure item -> %s", p); + return (False); + } + + return (True); +} + +int +GetStructUnionTagItem(char *p, char **pEnd, char **pName, unsigned short *pType, unsigned short *pBitOffset, unsigned short *pBitSize) +{ + + unsigned short StabType; + /* Structure or Union Tag Item consists of -> name:type,bitoffset,bitsize; */ + + /* name */ + *pName = p; + while (*p && (*p != ':')) p++; /* locate colon */ + if (*p != ':') { + fprintf(stderr,"\nNo colon found in structure item -> %s", *pName); + return (False); + } + *p++ = 0; /* Asciiz */ + + /* Stab Type - convert to Coff type at end (after inline assignments */ + if (GetStabType(p, &StabType, &p) != True) { + fprintf(stderr,"\nInvalid tag type found in structure item -> %s", p); + return (False); + } + + /* BitSize */ + if (*p != ',') { + fprintf(stderr,"\nNo Bit size found in structure item -> %s", p); + return (False); + } + *pBitOffset = (unsigned short)atoi(++p); + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + + /* BitOffset */ + if (*p != ',') { + fprintf(stderr,"\nNo Bit offset found in structure item -> %s", p); + return (False); + } + *pBitSize = (unsigned short)atoi(++p); + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + + /* Now convert stab type to COFF */ + if ((*pType = GetCoffType((unsigned short)StabType)) == 0) { + fprintf(stderr,"\nNo COFF type found for stab type %d", StabType); + return (False); + } + if (*++p == ';') /* Now eat last semicolon(s) */ + p++; + *pEnd = p; + + return (True); +} + +int +GetEnumTagItem(char *p, char **pEnd, char **pEnumName, int *pEnumValue) +{ + + /* Enum Tag Item consists of -> member1:value,member2:value2,; */ + *pEnumName = p; + while (*p && (*p != ':')) p++; /* locate colon */ + if (*p != ':') { + fprintf(stderr,"\nNo colon found in enum item -> %s", *pEnumName); + return (False); + } + *p++ = 0; /* Asciiz */ + *pEnumValue = atoi(p); + + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + if (*p != ',') { + fprintf(stderr,"\nNo comma found after enum value -> %s", p); + return (False); + } + if (*++p ==';') + p++; /* eat last semicolon */ + *pEnd = p; + return (True); +} + +int +GetArrayType(char *p, char **pEnd, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels) +{ + + int MinIndex, MaxIndex, Result, Size, i; + char *pMinIndex, *pMaxIndex, *pType; + unsigned short Type; + + Result = True; + + pMinIndex = pMaxIndex = pType = 0; + while (*p && (*p != ';')) p++; /* find min index */ + pMinIndex = ++p; + while (*p && (*p != ';')) p++; /* find max index */ + pMaxIndex = ++p; + while (*p && (*p != ';')) p++; /* find type index */ + pType = ++p; + + /* bump the pointers to the digits */ + if (!isdigit(*pMinIndex)) + Result = False; + if (!isdigit(*pMaxIndex)) + Result = False; + if (!isdigit(*pType)) + Result = False; + /* Is syntax ok ? */ + if (Result != True) { + fprintf(stderr,"\nSyntax error on array parameters %s%s%s", pMinIndex, pMaxIndex, pType); + return (False); + } + MinIndex = atoi(pMinIndex); + MaxIndex = atoi(pMaxIndex); + + if (GetStabType(p, &Type, &p) != True) + return (False); + + if (!SetupDefinedType(Type, pMap, DerivedBits, ExtraLevels)) + return (False); + + /* Now update the size based on the indicies */ + Size = (MaxIndex - MinIndex) + 1; + pMap->ByteSize *= Size; + pMap->Line = ci->CurrentSourceLine; + /* add the dimension information */ + for (i = 5; i >= 0; i--) { + if (pMap->Dimensions[i] != 0) { + i++; + pMap->Dimensions[i] = Size; + break; + } + } + + *pEnd = p; + return (True); +} + +int +GetStabType(char *p, unsigned short *pType, char **pEnd) +{ + + STABCOFFMAP *pMap; + int extra, ok; + unsigned short derivedbits[6]; + unsigned short LStabType, RStabType; + char *pHigh, *pLow; + + + LStabType = atoi(p); + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + + *pType = LStabType; + + if (GetCoffType(LStabType) != 0) { + *pEnd = p; + return (True); + } + if (*p != '=') { + fprintf(stderr, "\nSyntax error in type assignment -> %s", p); + return (False); + } + p++; + + /* Allocate space for new internal type */ + if (!(pMap = (STABCOFFMAP *)AllocateListObject(&ci->ListOfTypes, sizeof(STABCOFFMAP)))) { + fprintf(stderr, "\nOut of memory allocating type info!"); + return (False); + } + pMap->StabType = LStabType; + + /* process items to right of equals */ + for (extra = 0; extra < 6; extra++) { + + if (isdigit(*p)) { + /* Finally found base type, try to terminate loop */ + GetStabType(p, &RStabType, &p); + /* RStabType = atoi( p ); */ + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + if (SetupDefinedType(RStabType, pMap, &derivedbits[0], extra) != True) + return (False); + break; + } else if (*p == 'a') { + derivedbits[extra] = DT_ARY; + p++; + /* Calculate size */ + /* Since type assignment will be made we need to set extra bits here */ + extra++; + /* =ar1;MinIndex;MaxIndex;BaseType */ + if (GetArrayType(p, &p, pMap, &derivedbits[0], extra) != True) + return (False); + break; + + } else if (*p == 'f') { + derivedbits[extra] = DT_FCN; + p++; + } else if (*p == '*') { + derivedbits[extra] = DT_PTR; + p++; + } else if (*p == 'r') { + while (*p && (*p != ';')) p++; + pLow = p++; + while (*p && (*p != ';')) p++; + pHigh = p++; + ok = GetSubRangeType(LStabType, pMap, pLow, pHigh); + if (ok != True) + return (False); + while (*p && (*p != ';')) p++; /* find end of range */ + p++; + break; + } else { + fprintf(stderr, "\nUnrecognized Type modifier %c!", *p); + return (False); + } + } + *pEnd = p; /* Update return pointer */ + + return (True); +} + +int +stab_add_tag_type(char *pName, char *pString) +{ + + int SymbolIndex, StabType, TotalSize, n, EnumValue; + unsigned short TagType, ItemType, BitOffset, BitSize; + char *p; + struct syment *pEntry; + union auxent *pAux; + STABCOFFMAP *pMap; + + /* We arrived here due to :T defining either a structure, union or enumeration */ + /* store the basic type as for internals and emit coff structures for debugging */ + /* .stabs "stag:T17=s2i:1,0,8;c:2,8,8;;",128,0,0,0 */ + /* .stabs "2:T18=u2a:2,0,8;b:1,0,8;c:6,0,16;;",128,0,0,0 */ + /* .stabs "1:T19=eenum1:1,enum2:2,enum3:3,;",128,0,0,0 */ + /* we don't care about the name */ + + + /* check for bogus errors */ + if (!pName || !pString) { + fprintf(stderr,"\nInvalid .stabs type format - no information!"); + return (False); + } + + p = pString; + /* Stab Type - convert to Coff type at end (after inline assignments */ + if ((StabType = (unsigned short)atoi(p)) == 0) { + fprintf(stderr,"\nInvalid .stabs type format - no information! - > %s", p); + return (False); + } + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + if (*p != '=') { + fprintf(stderr,"\nInvalid .stabs type format - no equals - > %s", p); + return (False); + } + SymbolIndex = ci->ListOfSymbols.TotalItems; + if ((pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfGlobals, sizeof(struct syment) * 2)) == 0) { + fprintf(stderr, "\nOut of memory allocating symbol tag entries"); + return (False); + } + /* Prepare Tag Header */ + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pString); + return (False); + } + if (!(pMap = (STABCOFFMAP *)AllocateListObject(&ci->ListOfTypes, sizeof(STABCOFFMAP)))) { + fprintf(stderr, "\nOut of memory allocating type info!"); + return (False); + } + pMap->StabType = StabType; + pEntry->n_value = 0; + pEntry->n_scnum = N_DEBUG; + pEntry->n_numaux = 1; + if (*++p == 's') { + TagType = pEntry->n_type = pMap->CoffType = T_STRUCT; + pEntry->n_sclass = C_STRTAG; + TotalSize = (unsigned short)atoi(++p); + } else if (*p == 'u') { + TagType = pEntry->n_type = pMap->CoffType = T_UNION; + pEntry->n_sclass = C_UNTAG; + TotalSize = (unsigned short)atoi(++p); + } else if (*p == 'e') { + TagType = pEntry->n_type = pMap->CoffType = T_ENUM; + pEntry->n_sclass = C_ENTAG; + TotalSize = FundamentalTypes[T_INT].Size; /* use size of int for enums */ + } else { + fprintf(stderr,"\nUnknown tag type -> %s", p); + return (False); + } + while (*p && (*p >= '0') && (*p <= '9')) p++; /* locate end of digits */ + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_tagndx = SymbolIndex; + pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; + + /* update our local knowledge of tag type */ + pMap->CoffType = TagType; + pMap->ByteSize = TotalSize; + pMap->Line = ci->CurrentSourceLine; + + /* Process the items until the end of the line */ + while (*pName) { + + if ((pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfGlobals, sizeof(struct syment) * 2)) == 0) { + fprintf(stderr, "\nOut of memory allocating symbol tag member entries"); + return (False); + } + + if (TagType == T_STRUCT) { + if (GetStructUnionTagItem(p, &p, &pName, &ItemType, &BitOffset, &BitSize) != True) { + return (False); + } + pEntry->n_value = BitOffset/8; + pEntry->n_type = ItemType; + pEntry->n_sclass = C_MOS; + } else if (TagType == T_UNION) { + if (GetStructUnionTagItem(p, &p, &pName, &ItemType, &BitOffset, &BitSize) != True) { + return (False); + } + pEntry->n_value = BitOffset/8; + pEntry->n_type = ItemType; + pEntry->n_sclass = C_MOU; + } else { /* T_ENUM */ + if (GetEnumTagItem(p, &p, &pName, &EnumValue) != True) { + return (False); + } + pEntry->n_value = EnumValue; + pEntry->n_type = TotalSize; + pEntry->n_sclass = C_MOE; + } + + /* Prepare Common Tag Header items */ + if ((n = AddNameToEntry(pName, pEntry)) == 0) { + fprintf(stderr,"\nOut of memory adding local %s to string table", pString); + return (False); + } + pEntry->n_scnum = N_ABS; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_tagndx = SymbolIndex; + pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; + pName = p; + } + + /* End of Structures/Unions/Enumberations */ + if ((pEntry = (struct syment *)AllocateTwoListObjects(&ci->ListOfGlobals, sizeof(struct syment) * 2)) == 0) { + fprintf(stderr, "\nOut of memory allocating special headers for structure!"); + return (False); + } + strcpy(pEntry->n_name, ".eos"); + pEntry->n_value = TotalSize; + pEntry->n_scnum = N_ABS; + pEntry->n_type = 0; + pEntry->n_sclass = C_EOS; + pEntry->n_numaux = 1; + pEntry++; /* point to aux entry */ + pAux = (union auxent *)pEntry; + pAux->x_sym.x_tagndx = SymbolIndex; /* point to the .bf entry index */ + pAux->x_sym.x_misc.x_lnsz.x_size = TotalSize; + + return (True); +} + +int +SetupDefinedType(unsigned short Type, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels) +{ + + int i, Dlimit, Dstart; + unsigned short StabType; + + StabType = pMap->StabType; /* save the new type we found earlier */ + if (CopyStabCoffMap(Type, pMap) != True) { + fprintf(stderr, "\nCould not find defined type %d", Type); + return (False); + } + pMap->StabType = StabType; /* save the new type we found earlier */ + + /* Determine existing derived types for base class */ + for (i = 0; i < 6; i++) { + if ((pMap->CoffType & (3 << (4 + i + i))) == 0) + break; + } + Dstart = i; + Dlimit = i + ExtraLevels; + if ((Dlimit) >= 6) { + fprintf(stderr, "\nStab Type %d has too many derived (%d) types!", pMap->StabType, Dlimit); + return (False); + } + /* Add the new derived levels */ + for (; i < Dlimit; i++) { + pMap->CoffType |= ((DerivedBits[i - Dstart] & 3) << (4 + i + i)); /* add in the derived bits */ + } + return (True); +} + +int +GetArrayDefinitions(STABCOFFMAP *pMap, char *pMinIndex, char *pMaxIndex, char *pType, unsigned short *DerivedBits, int ExtraLevels) +{ + + int MinIndex, MaxIndex, Result, Size, i; + unsigned short Type; + + Result = True; + if ((*pMinIndex != ';') || (*pMaxIndex != ';') || (*pType != ';')) + Result = False; + /* bump the pointers to the digits */ + pMinIndex++; + if (!isdigit(*pMinIndex)) + Result = False; + pMaxIndex++; + if (!isdigit(*pMaxIndex)) + Result = False; + pType++; + if (!isdigit(*pType)) + Result = False; + /* Is syntax ok ? */ + if (Result != True) { + fprintf(stderr,"\nSyntax error on array parameters %s%s%s", pMinIndex, pMaxIndex, pType); + return (False); + } + MinIndex = atoi(pMinIndex); + MaxIndex = atoi(pMaxIndex); + Type = (unsigned short)atoi(pType); + if (SetupDefinedType(Type, pMap, DerivedBits, ExtraLevels) != True) + return (False); + /* Now update the size based on the indicies */ + Size = (MaxIndex - MinIndex) + 1; + pMap->ByteSize *= Size; + pMap->Line = ci->CurrentSourceLine; + /* add the dimension information */ + for (i = 5; i >= 0; i--) { + if (pMap->Dimensions[i] != 0) { + i++; + pMap->Dimensions[i] = Size; + break; + } + } + return (True); +} + +int +GetInternalType(char *pName, STABCOFFMAP *pMap) +{ + + int n, found, i; + + if (!pName) { + return (False); + } + + found = False; + n = strlen(pName); + /* Find out if it is a local type */ + for (i = 0; FundamentalTypes[i].pString != 0; i++) { + if (!strncmp(pName, FundamentalTypes[i].pString, n)) { + /* found an internal type */ + pMap->CoffType = FundamentalTypes[i].Type; + pMap->ByteSize = FundamentalTypes[i].Size; + found = True; + } + } + return (found); +} + +int +GetSubRangeType(unsigned short Type, STABCOFFMAP *pMap, char *pLow, char *pHigh) +{ + + int Result, i; + long High, Low; + unsigned long Test; + + Result = True; + if ((*pLow != ';') || (*pHigh != ';') || (Type <= 0)) + Result = False; + + /* Is syntax ok ? */ + if (Result != True) { + fprintf(stderr,"\nSyntax error on sub range parameters!"); + return (False); + } + Low = atol(++pLow); + High = atol(++pHigh); + + /* Special handling of type void */ + if ((Low == 0) && (High == 0)) { + /* Declare type void */ + pMap->ByteSize =0; + pMap->CoffType = T_VOID; + pMap->Line = ci->CurrentSourceLine; + return (True); + } + + if ((pMap->CoffType = GetCoffType(Type)) != 0) { + pMap->ByteSize = GetCoffTypeSize(Type); + } else { + /* Try to base everything off integer */ + pMap->ByteSize = FundamentalTypes[T_INT].Size; + } + + /* Now calculate the byte size */ + if (High == 0) { + pMap->ByteSize = (unsigned short)Low; /* floating point */ + } else { + if (Low == 0) { + /* Unsigned */ + Test = (unsigned long)High; + } else if (Low < 0) { + /* signed */ + Test = (unsigned long)High << 1; + } else { + if (Low <= High) + Test = (unsigned long)High; + else + Test = (unsigned long)Low; + } + if (pMap->ByteSize == 0) { + fprintf(stderr,"\nType Range Error 1, need previous type %d size!", pMap->CoffType); + return (False); + } + for (i = 0; i < sizeof(unsigned long); i++) { + if (!(Test & (0xff << (i * 8)))) + break; + } + pMap->ByteSize = i; + } + /* Now determine the best fit based on byte size, compare against IAR Compiler */ + if (pMap->ByteSize == 1) { + if (Low < 0) + pMap->CoffType = T_CHAR; + else + pMap->CoffType = T_UCHAR; + } else if (pMap->ByteSize == 2) { + if (Low < 0) + pMap->CoffType = T_INT; + else + pMap->CoffType = T_UINT; + } else if (pMap->ByteSize == 4) { + if (Low == 0) + pMap->CoffType = T_FLOAT; + if (Low < 0) + pMap->CoffType = T_LONG; + else + pMap->CoffType = T_ULONG; + } else { + fprintf(stderr,"\nGetSubRangeType failure - byte size %d", pMap->ByteSize); + return (False); + } + return (True); +} + +int +CopyStabCoffMap(unsigned short StabType, STABCOFFMAP *pMap) +{ + + STABCOFFMAP *p; + + for (p = FindFirstListObject(&ci->ListOfTypes); p != 0; p = FindNextListObject(&ci->ListOfTypes)) { + if (p->StabType == StabType) { + memcpy(pMap, p, sizeof(STABCOFFMAP)); + return (True); + } + } + return (False); /* Nothing found */ +} + +unsigned short +GetCoffType(unsigned short StabType) +{ + + STABCOFFMAP *p; + + for (p = FindFirstListObject(&ci->ListOfTypes); p != 0; p = FindNextListObject(&ci->ListOfTypes)) { + if (p->StabType == StabType) + return (p->CoffType); + } + return (0); /* Nothing found */ +} + +unsigned short +GetCoffTypeSize(unsigned short StabType) +{ + + STABCOFFMAP *p; + + for (p = FindFirstListObject(&ci->ListOfTypes); p != 0; p = FindNextListObject(&ci->ListOfTypes)) { + if (p->StabType == StabType) + return (p->ByteSize); + } + return (0); /* Nothing found */ +} + + +int +GetDigitLength(char *p) +{ + + int i; + + if (p == 0) + return (0); + + for (i = 0; (*p != 0) && (*p >= '0') && (*p <= '9'); i++); + + return (i); + +} + +int +GetStringDelimiters(char *pString, char **pTokens, int MaxTokens) +{ + + int i; + char *p; + + p = pString; + + if (!p) + return (0); + + for (i = 0; i < MaxTokens; i++) { + while (True) { + if ((*p == ':') || (*p == ';') || (*p == '=') || (*p == ',') || (*p == '"') || (*p == 0)) { + *(pTokens + i) = p; /* Remember this location */ + p++; + if (*p == 0) + return (i); + break; + } + p++; + } + } + return (i); +} + +int +IsTypeArray(unsigned short CoffType) +{ + + int Result; + + Result = False; + + if ((CoffType & (DT_ARY << 4)) == (DT_ARY << 4)) + Result = True; + if ((CoffType & (DT_ARY << 6)) == (DT_ARY << 6)) + Result = True; + if ((CoffType & (DT_ARY << 8)) == (DT_ARY << 8)) + Result = True; + if ((CoffType & (DT_ARY << 10)) == (DT_ARY << 10)) + Result = True; + if ((CoffType & (DT_ARY << 12)) == (DT_ARY << 12)) + Result = True; + if ((CoffType & (DT_ARY << 14)) == (DT_ARY << 14)) + Result = True; + + return (Result); +} + +void +AddArrayAuxInfo(union auxent *pAux, unsigned short SymbolIndex, STABCOFFMAP *pMap) +{ + + int i; + + pAux->x_sym.x_tagndx = SymbolIndex; /* point to the .bf entry index */ + pAux->x_sym.x_misc.x_lnsz.x_lnno = pMap->Line; + pAux->x_sym.x_misc.x_lnsz.x_size = pMap->ByteSize; + for (i = 0; i < 4; i++) + pAux->x_sym.x_fcnary.x_ary.x_dimen[i] = pMap->Dimensions[i]; +} + +int +AddNameToEntry(char *pName, struct syment *pEntry) +{ + + int n; + char *p; + + n = strlen(pName); /* see if it's 8 bytes or less */ + if (n <= 8) { + strncpy(pEntry->n_name, pName, 8); + } else { + /* point to current offset in string table */ + pEntry->n_offset = ci->ListOfStrings.TotalBytes; + /* Allocate string table entry */ + if ((p = (char *)AllocateListObject(&ci->ListOfStrings, n + 1)) == 0) { + return (0); + } + strcpy(p, pName); + } + return (n); /* return size of string */ +} + +char * +SkipPastDigits(char *p) +{ + + if (!p) + return (p); + if (*p == 0) + return (p); + for (p--; (*p >= '0') && (*p <= '9') && (*p != 0); p--); + return (p); +} + +void +InitializeList(LISTNODEHEAD *pHead) +{ + + pHead->Node.Next = &pHead->Node; + pHead->Node.Last = &pHead->Node; + pHead->TotalBytes = 0; + pHead->TotalItems = 0; + pHead->current = &pHead->Node; + return; +} + +void * +AllocateTwoListObjects(LISTNODEHEAD *pHead, int size) +{ + + void *p; + + if ((p = AllocateListObject(pHead, size))) + pHead->TotalItems++; /* already incremented once in addtolist */ + return (p); +} + +void * +AllocateListObject(LISTNODEHEAD *pHead, int size) +{ + + void *pObject; + + LISTNODE *pNode; + + if ((pObject = calloc(1, size)) != 0) { + if (!(pNode = AddListObject(pHead, pObject, size))) { + free(pObject); + pObject = 0; + } + } + return (pObject); +} + +LISTNODE * +AddListObject(LISTNODEHEAD *pHead, void *pObject, int size) +{ + + LISTNODE *pNode; + + if ((pNode = calloc(1, sizeof(LISTNODE))) != 0) { + pNode->pObject = pObject; + pNode->Size = size; + pNode->FileNumber = ci->CurrentFileNumber; + AddNodeToList(pHead, pNode); + } + return (pNode); +} + +LISTNODE * +AllocateListNode(void *pObject, int size) +{ + + LISTNODE *pNew; + + if ((pNew = calloc(1, sizeof(LISTNODE))) != 0) { + /* Then we initialize the node */ + pNew->pObject = pObject; + pNew->Size = size; + pNew->FileNumber = ci->CurrentFileNumber; + } + return (pNew); +} + +void +AddNodeToList(LISTNODEHEAD *pHead, LISTNODE *pNode) +{ + + LISTNODE *p; + + p = &pHead->Node; + + pNode->Next = p->Last->Next; + p->Last->Next = pNode; + pNode->Last = p->Last; + p->Last = pNode; + + /* and update current size of data contained in the list */ + pHead->TotalBytes += pNode->Size; + pHead->TotalItems++; +} + +void +RemoveNodeFromList(LISTNODEHEAD *pHead, LISTNODE *pNode) +{ + + pNode->Last->Next = pNode->Next; + pNode->Next->Last = pNode->Last; + + pHead->TotalBytes -= pNode->Size; + pHead->TotalItems--; +} + +void * +FindFirstListObject(LISTNODEHEAD *pHead) +{ + + if (pHead->Node.Next == &pHead->Node) + return (0); /* Nothing in list */ + + pHead->current = pHead->Node.Next; + return (pHead->current->pObject); +} + +void * +FindNextListObject(LISTNODEHEAD *pHead) +{ + + if (pHead->current->Next == &pHead->Node) + return (0); + + pHead->current = pHead->current->Next; + + return (pHead->current->pObject); +} + +LISTNODE * +GetCurrentNode(LISTNODEHEAD *pHead) +{ + + return (pHead->current); +} + +void * +GetCurrentListObject(LISTNODEHEAD *pHead) +{ + + return (pHead->current->pObject); +} + +void * +FindLastListObject(LISTNODEHEAD *pHead) +{ + + if (pHead->Node.Last == &pHead->Node) + return (0); /* Nothing in list */ + + pHead->current = pHead->Node.Last; + return (pHead->current->pObject); +} + +void * +FindNextLastListObject(LISTNODEHEAD *pHead) +{ + + if (pHead->current->Last == &pHead->Node) + return (0); + + pHead->current = pHead->current->Last; + + return (pHead->current->pObject); +} + +void +FreeList(LISTNODEHEAD *pHead) +{ + + LISTNODE *pNode; + + for (pNode = pHead->Node.Last; pNode->Next != &pHead->Node; pNode = pHead->Node.Last) { + + RemoveNodeFromList(pHead, pNode); + free(pNode->pObject); + free(pNode); + } + pHead->TotalBytes = 0; + pHead->TotalItems = 0; + pHead->current = &pHead->Node; } -/****************************************************************************************/ - diff -Nru avra-1.3.0/src/coff.h avra-1.4.2+dfsg/src/coff.h --- avra-1.3.0/src/coff.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/coff.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,403 +1,355 @@ -// -// coff.h - Common Object File Format (COFF) support -// -// This file was developed for the avra assembler in order to produce COFF output files -// for use with the Atmel AVR Studio. The Lean C Compiler (LCC) debugging stabs -// output was used as input to the assembler. -// -// This software has absolutely no warrantee! The money you paid for this will be -// promptly refunded if not fully satisfied. -// -// Beta release 1/20/2000 by Bob Harris -// -// This software has not been fully tested and probably has a few software deficiencies. -// Some software support may be possible by sending a problem description report to -// rth@mclean.sparta.com - -#define MAGIC_NUMBER_AVR 0xa12 - -#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ -#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ -#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ -#define N_STSYM 0x26 /* static symbol: name,,0,type,address */ -#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ -#define N_MAIN 0x2a /* name of main routine : name,,0,0,0 */ -#define N_ROSYM 0x2c /* ro_data objects */ -#define N_OBJ 0x38 /* object file path or name */ -#define N_OPT 0x3c /* compiler options */ -#define N_RSYM 0x40 /* register sym: name,,0,type,register */ -#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ -#define N_FLINE 0x4c /* function start.end */ -#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ -#define N_ENDM 0x62 /* last stab emitted for module */ -#define N_SO 0x64 /* source file name: name,,0,0,address */ -#define N_LSYM 0x80 /* local sym: name,,0,type,offset */ -#define N_BINCL 0x82 /* header file: name,,0,0,0 */ -#define N_SOL 0x84 /* #included file name: name,,0,0,address */ -#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ -#define N_EINCL 0xa2 /* end of include file */ -#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ -#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ -#define N_EXCL 0xc2 /* excluded include file */ -#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ -#define N_BCOMM 0xe2 /* begin common: name,, */ -#define N_ECOMM 0xe4 /* end common: name,, */ -#define N_ECOML 0xe8 /* end common (local name): ,,address */ -#define N_LENG 0xfe /* second stab entry with length information */ - - -/* - * Type of a symbol, in low N bits of the word - */ -#define T_NULL 0 -#define T_VOID 1 /* function argument (only used by compiler) */ -#define T_CHAR 2 /* character */ -#define T_SHORT 3 /* short integer */ -#define T_INT 4 /* integer */ -#define T_LONG 5 /* long integer */ -#define T_FLOAT 6 /* floating point */ -#define T_DOUBLE 7 /* double word */ -#define T_STRUCT 8 /* structure */ -#define T_UNION 9 /* union */ -#define T_ENUM 10 /* enumeration */ -#define T_MOE 11 /* member of enumeration*/ -#define T_UCHAR 12 /* unsigned character */ -#define T_USHORT 13 /* unsigned short */ -#define T_UINT 14 /* unsigned integer */ -#define T_ULONG 15 /* unsigned long */ -#define T_LNGDBL 16 /* long double */ - -/* - * derived types, in n_type -*/ -#define DT_NON (0) /* no derived type */ -#define DT_PTR (1) /* pointer */ -#define DT_FCN (2) /* function */ -#define DT_ARY (3) /* array */ - -struct external_filehdr { - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - unsigned long f_timdat; /* time & date stamp */ - unsigned long f_symptr; /* file pointer to symtab */ - unsigned long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ -}; - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved external references) - * F_LNNO line numbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) - */ - -#define F_RELFLG (0x0001) -#define F_EXEC (0x0002) -#define F_LNNO (0x0004) -#define F_LSYMS (0x0008) - -/*********************************************************************/ -struct external_scnhdr { - char s_name[8]; /* section name */ - unsigned long s_paddr; /* physical address, aliased s_nlib */ - unsigned long s_vaddr; /* virtual address */ - unsigned long s_size; /* section size */ - unsigned long s_scnptr; /* file ptr to raw data for section */ - unsigned long s_relptr; /* file ptr to relocation */ - unsigned long s_lnnoptr; /* file ptr to line numbers */ - unsigned short s_nreloc; /* number of relocation entries */ - unsigned short s_nlnno; /* number of line number entries*/ - unsigned long s_flags; /* flags */ -}; - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" -#define _COMMENT ".comment" -#define _LIB ".lib" - -/* - * s_flags "type" - */ -#define STYP_TEXT (0x0020) /* section contains text only */ -#define STYP_DATA (0x0040) /* section contains data only */ -#define STYP_BSS (0x0080) /* section contains bss only */ - - -/*********************************************************************/ - -struct lineno -{ - union - { - long l_symndx; /* symtbl index of func name */ - long l_paddr; /* paddr of line number */ - } l_addr; - unsigned short l_lnno; /* line number */ -}; - -#define LINENO struct lineno -#define LINESZ 6 - - - -#define N_UNDEF ((short)0) /* undefined symbol */ -#define N_ABS ((short)-1) /* value of symbol is absolute */ -#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ - -/********************** STORAGE CLASSES **********************/ - -/* This used to be defined as -1, but now n_sclass is unsigned. */ -#define C_EFCN 0xff /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ -#define C_AUTOARG 19 /* auto argument */ -#define C_LASTENT 20 /* dummy entry (end of block) */ -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib */ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct syment -{ - union - { - char _n_name[E_SYMNMLEN]; /* symbol name*/ - struct - { - long _n_zeroes; /* symbol name */ - - long _n_offset; /* location in string table */ - } _n_n; - char *_n_nptr[2]; /* allows overlaying */ - } _n; - unsigned long n_value; /* value of symbol */ - - short n_scnum; /* section number */ - - unsigned short n_type; /* type and derived */ - - char n_sclass; /* storage class */ - - char n_numaux; /* number of aux entries */ -}; - -#define n_name _n._n_name -#define n_zeroes _n._n_n._n_zeroes -#define n_offset _n._n_n._n_offset -#define n_nptr _n._n_nptr[1] - -#define SYMNMLEN 8 -#define SYMESZ 18 /* size of a symbol table entry */ - -union auxent -{ - struct - { - long x_tagndx; - union - { - struct - { - unsigned short x_lnno; - unsigned short x_size; - } x_lnsz; - long x_fsize; - } x_misc; - union - { - struct - { - long x_lnnoptr; - long x_endndx; - } x_fcn; - struct - { - unsigned short x_dimen[E_DIMNUM]; - } x_ary; - } x_fcnary; - unsigned short x_tvndx; - } x_sym; - union - { - char x_fname[E_FILNMLEN]; - struct { - unsigned long x_zeroes; - unsigned long x_offset; - } x_n; - } x_file; - struct - { - long x_scnlen; - unsigned short x_nreloc; - unsigned short x_nlinno; - } x_scn; - struct - { - long x_tvfill; - unsigned short x_tvlen; - unsigned short x_tvran[2]; - } x_tv; -}; - -#define FILNMLEN 14 -#define DIMNUM 4 -#define AUXENT union auxent -#define AUXESZ 18 - - -/* Coff additions */ -typedef struct ListNodeTag{ - struct ListNodeTag *Next; /* Double Linked List */ - struct ListNodeTag *Last; /* Double Linked List */ - void *pObject; /* points to list object */ - unsigned long Size; - int FileNumber; /* corresponds to individual file(s) */ -} LISTNODE; - -//#define LISTNODE struct ListNodeTag; - -typedef struct ListNodeHeadTag { - LISTNODE Node; -// struct ListNodeTag *Next; /* Double Linked List */ -// struct ListNodeTag *Last; /* Double Linked List */ - int TotalBytes; /* size of allocated object(s) */ - int TotalItems; /* number of allocated objects */ - LISTNODE *current; /* pointer for FindFirst/FindNext */ -} LISTNODEHEAD ; - - -typedef struct { - unsigned short StabType; - unsigned short CoffType; - unsigned short ByteSize; - unsigned short Line; /* used by arrays */ - unsigned short Dimensions[6]; /* used by arrays */ -} STABCOFFMAP; - -struct coff_info { - - int CurrentFileNumber; - int FunctionStartLine; /* used in Line number table */ - int CurrentSourceLine; - - /* Internal */ - unsigned char *pRomMemory; /* 16 bit wide words/addresses */ - unsigned char *pEEPRomMemory; /* 8 bit wide words/addresses */ - int MaxRomAddress; - int MaxEepromAddress; - int NeedLineNumberFixup; - int GlobalStartAddress; - int GlobalEndAddress; - LISTNODEHEAD ListOfSplitLines; - - /* External */ - struct external_filehdr FileHeader; /* Only one of these per output file */ - LISTNODEHEAD ListOfSectionHeaders; /* .text, .bss */ - LISTNODEHEAD ListOfRawData; /* Program, EEPROM */ - LISTNODEHEAD ListOfRelocations; /* Not used now */ - LISTNODEHEAD ListOfLineNumbers; - LISTNODEHEAD ListOfSymbols; - LISTNODEHEAD ListOfGlobals; - LISTNODEHEAD ListOfSpecials; - LISTNODEHEAD ListOfUndefined; - LISTNODEHEAD ListOfStrings; - LISTNODEHEAD ListOfTypes; -}; - -#if 0 /* defined in avra.h */ - -FILE *open_coff_file(struct prog_info *pi, char *filename); -void write_coff_file(struct prog_info *pi); -void write_coff_eeprom( struct prog_info *pi, int address, unsigned char data); -void write_coff_program( struct prog_info *pi, int address, unsigned char data); -void close_coff_file(struct prog_info *pi, FILE *fp); -int parse_stabs( struct prog_info *pi, char *p ); -int parse_stabn( struct prog_info *pi, char *p ); - -#endif - -/**************************************************************/ -/*********** Internal Routines ********************************/ -/**************************************************************/ -int stab_add_lineno( struct prog_info *pi, int LineNumber, char *pLabel, char *pFunction ); -int stab_add_lbracket( struct prog_info *pi, int Level, char *pLabel, char *pFunction ); -int stab_add_rbracket( struct prog_info *pi, int Level, char *pLabel, char *pFunction ); -int stab_add_filename( char *pName, char *pLabel ); -int stab_add_function( struct prog_info *pi, char *pName, char *pLabel ); -int stab_add_global( struct prog_info *pi, char *pName, char *pType ); -int stab_add_local( struct prog_info *pi, char *pName, char *pType, char *pOffset ); -int stab_add_parameter_symbol( struct prog_info *pi, char *pName, char *pType, char *pOffset ); -int stab_add_static_symbol( struct prog_info *pi, char *pName, char *pType, char *pLabel ); -int stab_add_local_register( struct prog_info *pi, char *pName, char *pType, char *pRegister ); -int stab_add_local_type( char *pString, char *pType ); -int stab_add_tag_type( char *pName, char *pDesciptor ); - -int GetStabType( char *p, unsigned short *pType, char **pEnd ); -int AddNameToEntry( char *pName, struct syment *pEntry ); -int GetArrayType( char *p, char **pEnd, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels ); -int GetEnumTagItem( char *p, char **pEnd, char **pEnumName, int *pEnumValue ); -int GetStructUnionTagItem( char *p, char **pEnd, char **pName, unsigned short *pType, unsigned short *pBitOffset, unsigned short *pBitSize); -int GetStringDelimiters( char *pString, char **pTokens, int MaxTokens ); -int SetupDefinedType( unsigned short Type, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels ); -int GetArrayDefinitions( STABCOFFMAP *pMap , char *pMinIndex, char *pMaxIndex, char *pType, unsigned short *DerivedBits, int ExtraLevels ); -int GetInternalType( char *pName, STABCOFFMAP *pMap ); -unsigned short GetCoffType( unsigned short StabType ); -unsigned short GetCoffTypeSize( unsigned short StabType ); -int CopyStabCoffMap( unsigned short StabType, STABCOFFMAP *pMap ); -int IsTypeArray( unsigned short CoffType ); -void AddArrayAuxInfo( union auxent *pAux, unsigned short SymbolIndex, STABCOFFMAP *pMap ); -int GetSubRangeType( unsigned short Type, STABCOFFMAP *pMap , char *pLow, char *pHigh ); -char *SkipPastDigits( char *p ); -int GetDigitLength( char *p ); - -/****************************************************************************************/ -/* List management routines */ -/****************************************************************************************/ - -void InitializeList( LISTNODEHEAD *pNode ); -void *AllocateTwoListObjects( LISTNODEHEAD *pHead, int size ); -void *AllocateListObject( LISTNODEHEAD *pHead, int size ); -LISTNODE *AllocateListNode( void *pObject, int size ); -void AddNodeToList( LISTNODEHEAD *pHead, LISTNODE *pNode ); -void *FindFirstListObject( LISTNODEHEAD *pHead ); -void *FindNextListObject( LISTNODEHEAD *pHead ); -LISTNODE *GetCurrentNode( LISTNODEHEAD *pHead ); -void *GetCurrentListObject( LISTNODEHEAD *pHead ); -void *FindLastListObject( LISTNODEHEAD *pHead ); -void *FindNextLastListObject( LISTNODEHEAD *pHead ); -void FreeList( LISTNODEHEAD *pHead ); -LISTNODE *AddListObject(LISTNODEHEAD *pHead, void *pObject, int size ); - +/* coff.h - Common Object File Format (COFF) support + * + * This file was developed for the AVRA assembler in order to produce COFF output files + * for use with the Atmel AVR Studio. The Lean C Compiler (LCC) debugging stabs + * output was used as input to the assembler. + * + * This software has absolutely no warrantee! The money you paid for this will be + * promptly refunded if not fully satisfied. + * + * Beta release 1/20/2000 by Bob Harris + * + * This software has not been fully tested and probably has a few software deficiencies. + * Some software support may be possible by sending a problem description report to + * rth@mclean.sparta.com */ + +#define MAGIC_NUMBER_AVR 0xa12 + +#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ +#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ +#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ +#define N_STSYM 0x26 /* static symbol: name,,0,type,address */ +#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ +#define N_MAIN 0x2a /* name of main routine : name,,0,0,0 */ +#define N_ROSYM 0x2c /* ro_data objects */ +#define N_OBJ 0x38 /* object file path or name */ +#define N_OPT 0x3c /* compiler options */ +#define N_RSYM 0x40 /* register sym: name,,0,type,register */ +#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ +#define N_FLINE 0x4c /* function start.end */ +#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ +#define N_ENDM 0x62 /* last stab emitted for module */ +#define N_SO 0x64 /* source file name: name,,0,0,address */ +#define N_LSYM 0x80 /* local sym: name,,0,type,offset */ +#define N_BINCL 0x82 /* header file: name,,0,0,0 */ +#define N_SOL 0x84 /* #included file name: name,,0,0,address */ +#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ +#define N_EINCL 0xa2 /* end of include file */ +#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ +#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ +#define N_EXCL 0xc2 /* excluded include file */ +#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ +#define N_BCOMM 0xe2 /* begin common: name,, */ +#define N_ECOMM 0xe4 /* end common: name,, */ +#define N_ECOML 0xe8 /* end common (local name): ,,address */ +#define N_LENG 0xfe /* second stab entry with length information */ + + +/* Type of a symbol, in low N bits of the word */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* derived types, in n_type */ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +struct external_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + unsigned long f_timdat; /* time & date stamp */ + unsigned long f_symptr; /* file pointer to symtab */ + unsigned long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) + +struct external_scnhdr { + char s_name[8]; /* section name */ + unsigned long s_paddr; /* physical address, aliased s_nlib */ + unsigned long s_vaddr; /* virtual address */ + unsigned long s_size; /* section size */ + unsigned long s_scnptr; /* file ptr to raw data for section */ + unsigned long s_relptr; /* file ptr to relocation */ + unsigned long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + unsigned long s_flags; /* flags */ +}; + +#define SCNHDR struct external_scnhdr +#define SCNHSZ sizeof(SCNHDR) + +/* names of "special" sections */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _COMMENT ".comment" +#define _LIB ".lib" + +/* s_flags "type" */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ + + +struct lineno { + union { + long l_symndx; /* symtbl index of func name */ + long l_paddr; /* paddr of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + +#define LINENO struct lineno +#define LINESZ 6 + + + +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ + +/* STORAGE CLASSES */ + +/* This used to be defined as -1, but now n_sclass is unsigned. */ +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct syment { + union { + char _n_name[E_SYMNMLEN]; /* symbol name*/ + struct { + long _n_zeroes; /* symbol name */ + + long _n_offset; /* location in string table */ + } _n_n; + char *_n_nptr[2]; /* allows overlaying */ + } _n; + unsigned long n_value; /* value of symbol */ + + short n_scnum; /* section number */ + + unsigned short n_type; /* type and derived */ + + char n_sclass; /* storage class */ + + char n_numaux; /* number of aux entries */ +}; + +#define n_name _n._n_name +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset +#define n_nptr _n._n_nptr[1] + +#define SYMNMLEN 8 +#define SYMESZ 18 /* size of a symbol table entry */ + +union auxent { + struct { + long x_tagndx; + union { + struct { + unsigned short x_lnno; + unsigned short x_size; + } x_lnsz; + long x_fsize; + } x_misc; + union { + struct { + long x_lnnoptr; + long x_endndx; + } x_fcn; + struct { + unsigned short x_dimen[E_DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; + } x_sym; + union { + char x_fname[E_FILNMLEN]; + struct { + unsigned long x_zeroes; + unsigned long x_offset; + } x_n; + } x_file; + struct { + long x_scnlen; + unsigned short x_nreloc; + unsigned short x_nlinno; + } x_scn; + struct { + long x_tvfill; + unsigned short x_tvlen; + unsigned short x_tvran[2]; + } x_tv; +}; + +#define FILNMLEN 14 +#define DIMNUM 4 +#define AUXENT union auxent +#define AUXESZ 18 + + +/* Coff additions */ +typedef struct ListNodeTag { + struct ListNodeTag *Next; /* Double Linked List */ + struct ListNodeTag *Last; /* Double Linked List */ + void *pObject; /* points to list object */ + unsigned long Size; + int FileNumber; /* corresponds to individual file(s) */ +} LISTNODE; + +typedef struct ListNodeHeadTag { + LISTNODE Node; + int TotalBytes; /* size of allocated object(s) */ + int TotalItems; /* number of allocated objects */ + LISTNODE *current; /* pointer for FindFirst/FindNext */ +} LISTNODEHEAD ; + + +typedef struct { + unsigned short StabType; + unsigned short CoffType; + unsigned short ByteSize; + unsigned short Line; /* used by arrays */ + unsigned short Dimensions[6]; /* used by arrays */ +} STABCOFFMAP; + +struct coff_info { + + int CurrentFileNumber; + int FunctionStartLine; /* used in Line number table */ + int CurrentSourceLine; + + /* Internal */ + unsigned char *pRomMemory; /* 16 bit wide words/addresses */ + unsigned char *pEEPRomMemory; /* 8 bit wide words/addresses */ + int MaxRomAddress; + int MaxEepromAddress; + int NeedLineNumberFixup; + int GlobalStartAddress; + int GlobalEndAddress; + LISTNODEHEAD ListOfSplitLines; + + /* External */ + struct external_filehdr FileHeader; /* Only one of these per output file */ + LISTNODEHEAD ListOfSectionHeaders; /* .text, .bss */ + LISTNODEHEAD ListOfRawData; /* Program, EEPROM */ + LISTNODEHEAD ListOfRelocations; /* Not used now */ + LISTNODEHEAD ListOfLineNumbers; + LISTNODEHEAD ListOfSymbols; + LISTNODEHEAD ListOfGlobals; + LISTNODEHEAD ListOfSpecials; + LISTNODEHEAD ListOfUndefined; + LISTNODEHEAD ListOfStrings; + LISTNODEHEAD ListOfTypes; +}; + +/* Internal routines */ +int stab_add_lineno(struct prog_info *pi, int LineNumber, char *pLabel, char *pFunction); +int stab_add_lbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction); +int stab_add_rbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction); +int stab_add_filename(char *pName, char *pLabel); +int stab_add_function(struct prog_info *pi, char *pName, char *pLabel); +int stab_add_global(struct prog_info *pi, char *pName, char *pType); +int stab_add_local(struct prog_info *pi, char *pName, char *pType, char *pOffset); +int stab_add_parameter_symbol(struct prog_info *pi, char *pName, char *pType, char *pOffset); +int stab_add_static_symbol(struct prog_info *pi, char *pName, char *pType, char *pLabel); +int stab_add_local_register(struct prog_info *pi, char *pName, char *pType, char *pRegister); +int stab_add_local_type(char *pString, char *pType); +int stab_add_tag_type(char *pName, char *pDesciptor); + +int GetStabType(char *p, unsigned short *pType, char **pEnd); +int AddNameToEntry(char *pName, struct syment *pEntry); +int GetArrayType(char *p, char **pEnd, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels); +int GetEnumTagItem(char *p, char **pEnd, char **pEnumName, int *pEnumValue); +int GetStructUnionTagItem(char *p, char **pEnd, char **pName, unsigned short *pType, unsigned short *pBitOffset, unsigned short *pBitSize); +int GetStringDelimiters(char *pString, char **pTokens, int MaxTokens); +int SetupDefinedType(unsigned short Type, STABCOFFMAP *pMap, unsigned short *DerivedBits, int ExtraLevels); +int GetArrayDefinitions(STABCOFFMAP *pMap, char *pMinIndex, char *pMaxIndex, char *pType, unsigned short *DerivedBits, int ExtraLevels); +int GetInternalType(char *pName, STABCOFFMAP *pMap); +unsigned short GetCoffType(unsigned short StabType); +unsigned short GetCoffTypeSize(unsigned short StabType); +int CopyStabCoffMap(unsigned short StabType, STABCOFFMAP *pMap); +int IsTypeArray(unsigned short CoffType); +void AddArrayAuxInfo(union auxent *pAux, unsigned short SymbolIndex, STABCOFFMAP *pMap); +int GetSubRangeType(unsigned short Type, STABCOFFMAP *pMap, char *pLow, char *pHigh); +char *SkipPastDigits(char *p); +int GetDigitLength(char *p); + +/* List management routines */ + +void InitializeList(LISTNODEHEAD *pNode); +void *AllocateTwoListObjects(LISTNODEHEAD *pHead, int size); +void *AllocateListObject(LISTNODEHEAD *pHead, int size); +LISTNODE *AllocateListNode(void *pObject, int size); +void AddNodeToList(LISTNODEHEAD *pHead, LISTNODE *pNode); +void *FindFirstListObject(LISTNODEHEAD *pHead); +void *FindNextListObject(LISTNODEHEAD *pHead); +LISTNODE *GetCurrentNode(LISTNODEHEAD *pHead); +void *GetCurrentListObject(LISTNODEHEAD *pHead); +void *FindLastListObject(LISTNODEHEAD *pHead); +void *FindNextLastListObject(LISTNODEHEAD *pHead); +void FreeList(LISTNODEHEAD *pHead); +LISTNODE *AddListObject(LISTNODEHEAD *pHead, void *pObject, int size); + diff -Nru avra-1.3.0/src/configure avra-1.4.2+dfsg/src/configure --- avra-1.3.0/src/configure 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/configure 1970-01-01 00:00:00.000000000 +0000 @@ -1,5530 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59. -# -# Copyright (C) 2003 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -exec 6>&1 - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_config_libobj_dir=. -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= - -ac_unique_file="avra.c" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#if HAVE_SYS_TYPES_H -# include -#endif -#if HAVE_SYS_STAT_H -# include -#endif -#if STDC_HEADERS -# include -# include -#else -# if HAVE_STDLIB_H -# include -# endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#endif -#if HAVE_STRINGS_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif -#if HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBOBJS LTLIBOBJS' -ac_subst_files='' - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -ac_prev= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -_ACEOF - - cat <<_ACEOF -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -_ACEOF -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - ac_popdir=`pwd` - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" - done -fi - -test -n "$ac_init_help" && exit 0 -if $ac_init_version; then - cat <<\_ACEOF - -Copyright (C) 2003 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit 0 -fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was - - $ $0 $@ - -_ACEOF -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_sep= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -{ - (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - - - - - - - - - - -am__api_version="1.9" -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f $ac_dir/shtool; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} - { (exit 1); exit 1; }; } -fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL=$ac_install_sh - fi -fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 -# Just in case -sleep 1 -echo timestamp > conftest.file -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -test "$program_prefix" != NONE && - program_transform_name="s,^,$program_prefix,;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s,\$,$program_suffix,;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. -# By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm conftest.sed - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 -echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AWK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$AWK" && break -done - -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -all: - @echo 'ac_maketemp="$(MAKE)"' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftest.make -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - SET_MAKE= -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE=avra - VERSION=1.1 - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -install_sh=${install_sh-"$am_aux_dir/install-sh"} - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - STRIP=$ac_ct_STRIP -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - - -# Checks for programs. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CC" && break -done - - CC=$ac_ct_CC -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cc_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_stdc=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext -done -rm -f conftest.$ac_ext conftest.$ac_objext -CC=$ac_save_CC - -fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; - *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; -esac - -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - - ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi - - -echo "$as_me:$LINENO: result: $_am_result" >&5 -echo "${ECHO_T}$_am_result" >&6 -rm -f confinc confmf - -# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then - enableval="$enable_dependency_tracking" - -fi; -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - - -if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - - -depcc="$CC" am_compiler_list= - -echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - - -if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - - -# Checks for header files. - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - -for ac_header in stdlib.h string.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. -echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 -echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 -if test "${ac_cv_c_const+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset x; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *ccp; - char **p; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - ccp = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++ccp; - p = (char**) ccp; - ccp = (char const *const *) p; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - } -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_const=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_const=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 -echo "${ECHO_T}$ac_cv_c_const" >&6 -if test $ac_cv_c_const = no; then - -cat >>confdefs.h <<\_ACEOF -#define const -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for size_t" >&5 -echo $ECHO_N "checking for size_t... $ECHO_C" >&6 -if test "${ac_cv_type_size_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((size_t *) 0) - return 0; -if (sizeof (size_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_size_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_size_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -echo "${ECHO_T}$ac_cv_type_size_t" >&6 -if test $ac_cv_type_size_t = yes; then - : -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned -_ACEOF - -fi - - -# Checks for library functions. - -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 -echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6 -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_malloc_0_nonnull=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if STDC_HEADERS || HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -exit (malloc (0) ? 0 : 1); - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_malloc_0_nonnull=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6 -if test $ac_cv_func_malloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 0 -_ACEOF - - case $LIBOBJS in - "malloc.$ac_objext" | \ - *" malloc.$ac_objext" | \ - "malloc.$ac_objext "* | \ - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; -esac - - -cat >>confdefs.h <<\_ACEOF -#define malloc rpl_malloc -_ACEOF - -fi - - - - -for ac_func in strftime -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -else - # strftime is in -lintl on SCO UNIX. -echo "$as_me:$LINENO: checking for strftime in -lintl" >&5 -echo $ECHO_N "checking for strftime in -lintl... $ECHO_C" >&6 -if test "${ac_cv_lib_intl_strftime+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lintl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char strftime (); -int -main () -{ -strftime (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_intl_strftime=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_intl_strftime=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_intl_strftime" >&5 -echo "${ECHO_T}$ac_cv_lib_intl_strftime" >&6 -if test $ac_cv_lib_intl_strftime = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_STRFTIME 1 -_ACEOF - -LIBS="-lintl $LIBS" -fi - -fi -done - - -for ac_func in vprintf -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -echo "$as_me:$LINENO: checking for _doprnt" >&5 -echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 -if test "${ac_cv_func__doprnt+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define _doprnt to an innocuous variant, in case declares _doprnt. - For example, HP-UX 11i declares gettimeofday. */ -#define _doprnt innocuous__doprnt - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char _doprnt (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef _doprnt - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char _doprnt (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub__doprnt) || defined (__stub____doprnt) -choke me -#else -char (*f) () = _doprnt; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != _doprnt; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func__doprnt=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func__doprnt=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 -echo "${ECHO_T}$ac_cv_func__doprnt" >&6 -if test $ac_cv_func__doprnt = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DOPRNT 1 -_ACEOF - -fi - -fi -done - - - - - -for ac_func in memset strchr strstr -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - ac_config_files="$ac_config_files Makefile" -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g -t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g -t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed - - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - -exec 6>&1 - -# Open the log real soon, to keep \$[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 -_ACEOF - -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi - -cat >>$CONFIG_STATUS <<\_ACEOF - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to ." -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2003 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` - ac_shift=: - ;; - -*) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; - esac - - case $ac_option in - # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# -# INIT-COMMANDS section. -# - -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - -_ACEOF - - - -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_config_target in $ac_config_targets -do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. -$debug || -{ - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} - -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - -# -# CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@CYGPATH_W@,$CYGPATH_W,;t t -s,@PACKAGE@,$PACKAGE,;t t -s,@VERSION@,$VERSION,;t t -s,@ACLOCAL@,$ACLOCAL,;t t -s,@AUTOCONF@,$AUTOCONF,;t t -s,@AUTOMAKE@,$AUTOMAKE,;t t -s,@AUTOHEADER@,$AUTOHEADER,;t t -s,@MAKEINFO@,$MAKEINFO,;t t -s,@install_sh@,$install_sh,;t t -s,@STRIP@,$STRIP,;t t -s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t -s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t -s,@mkdir_p@,$mkdir_p,;t t -s,@AWK@,$AWK,;t t -s,@SET_MAKE@,$SET_MAKE,;t t -s,@am__leading_dot@,$am__leading_dot,;t t -s,@AMTAR@,$AMTAR,;t t -s,@am__tar@,$am__tar,;t t -s,@am__untar@,$am__untar,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@DEPDIR@,$DEPDIR,;t t -s,@am__include@,$am__include,;t t -s,@am__quote@,$am__quote,;t t -s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t -s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t -s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t -s,@CCDEPMODE@,$CCDEPMODE,;t t -s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t -s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t -s,@CPP@,$CPP,;t t -s,@EGREP@,$EGREP,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat - fi -fi # test -n "$CONFIG_FILES" - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_COMMANDS section. -# -for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -echo "$as_me: executing $ac_dest commands" >&6;} - case $ac_dest in - depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`(dirname "$mf") 2>/dev/null || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`(dirname "$file") 2>/dev/null || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p $dirpart/$fdir - else - as_dir=$dirpart/$fdir - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 -echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} - { (exit 1); exit 1; }; }; } - - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done - ;; - esac -done -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - diff -Nru avra-1.3.0/src/configure.in avra-1.4.2+dfsg/src/configure.in --- avra-1.3.0/src/configure.in 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/configure.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -# Autoconf configure.in file -AC_INIT(avra.c) -AM_INIT_AUTOMAKE(avra, 1.3) - -# Checks for programs. -AC_PROG_CC - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h string.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MALLOC -AC_FUNC_STRFTIME -AC_FUNC_VPRINTF -AC_CHECK_FUNCS([memset strchr strstr]) - -AC_OUTPUT(Makefile) diff -Nru avra-1.3.0/src/device.c avra-1.4.2+dfsg/src/device.c --- avra-1.3.0/src/device.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/device.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2010 Jon Anders Haugum, Tobias Weber, Jerry Jacobs + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,10 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra - * + * www: https://github.com/Ro5bert/avra */ @@ -34,180 +33,213 @@ #include "avra.h" #include "device.h" -#define DEV_VAR "__DEVICE__" // Device var name -#define FLASH_VAR "__FLASH_SIZE__" // Flash size var name -#define EEPROM_VAR "__EEPROM_SIZE__" // EEPROM size var name -#define RAM_VAR "__RAM_SIZE__" // RAM size var name -#define DEV_PREFIX "__" // Device name prefix -#define DEV_SUFFIX "__" // Device name suffix -#define DEF_DEV_NAME "DEFAULT" // Default device name (without prefix/suffix) -#define MAX_DEV_NAME 32 // Max device name length +#define DEV_VAR "__DEVICE__" /* Device var name */ +#define FLASH_VAR "__FLASH_SIZE__" /* Flash size var name */ +#define EEPROM_VAR "__EEPROM_SIZE__" /* EEPROM size var name */ +#define RAM_VAR "__RAM_SIZE__" /* RAM size var name */ +#define DEV_PREFIX "__" /* Device name prefix */ +#define DEV_SUFFIX "__" /* Device name suffix */ +#define DEF_DEV_NAME "DEFAULT" /* Default device name (without prefix/suffix) */ +#define MAX_DEV_NAME 32 /* Max device name length */ + + +/* Field Order: + * name, flash size (words), RAM start, RAM size (bytes), EEPROM size (bytes), + * flags */ +/* IMPORTANT: THE FLASH SIZE IS IN WORDS, NOT BYTES. This has been a fairly + * consistent source of bugs when new devices are added. */ +struct device device_list[] = { + /* Default device */ + {NULL, 4194304, 0x60, 8388608, 65536, 0}, /* Total instructions: 137 */ + + /* ATtiny Series */ + {"ATtiny4" , 256, 0x040, 32, 0, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP|DF_AVR8L}, + {"ATtiny5" , 256, 0x040, 32, 0, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP|DF_AVR8L}, + {"ATtiny9" , 512, 0x040, 32, 0, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP|DF_AVR8L}, + {"ATtiny10" , 512, 0x040, 32, 0, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP|DF_AVR8L}, + {"ATtiny11" , 512, 0x000, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny12" , 512, 0x000, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny13" , 512, 0x060, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny13A" , 512, 0x060, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny15" , 512, 0x000, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP|DF_TINY1X}, + {"ATtiny20" , 1024, 0x040, 128, 0, DF_NO_MUL|DF_NO_JMP|DF_NO_EIJMP|DF_NO_EICALL|DF_NO_MOVW|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK|DF_AVR8L}, + {"ATtiny22" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny24" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny24A" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny25" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny26" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny28" , 1024, 0x000, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny44" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny44A" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny45" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny48" , 2048, 0x100, 256, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny84" , 4096, 0x060, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny85" , 4096, 0x060, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny88" , 4096, 0x100, 512, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny261A" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny461A" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny861A" , 4096, 0x060, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny2313" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny2313A" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + {"ATtiny4313" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, + + /* AT90 series */ + {"AT90S1200" , 512, 0x000, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S2313" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S2323" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S2333" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S2343" , 1024, 0x060, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S4414" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S4433" , 2048, 0x060, 128, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S4434" , 2048, 0x060, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S8515" , 4096, 0x060, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90C8534" , 4096, 0x060, 256, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + {"AT90S8535" , 4096, 0x060, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, + + /* AT90USB series */ + /* AT90USB168 */ + /* AT90USB1287 */ + + /* ATmega series */ + {"ATmega8" , 4096, 0x060, 1024, 512, DF_NO_JMP|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega8A" , 4096, 0x060, 1024, 512, DF_NO_JMP|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega161" , 8192, 0x060, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega162" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega163" , 8192, 0x060, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega16" , 8192, 0x060, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega323" , 16384, 0x060, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega32" , 16384, 0x060, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega603" , 32768, 0x060, 4096, 2048, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_MUL|DF_NO_MOVW|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, + {"ATmega103" , 65536, 0x060, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_MUL|DF_NO_MOVW|DF_NO_LPM_X|DF_NO_ELPM_X|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, + {"ATmega104" , 65536, 0x060, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, /* Old name for mega128 */ + {"ATmega128" , 65536, 0x100, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, + {"ATmega128A" , 65536, 0x100, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, + {"ATmega48" , 2048, 0x100, 512, 256, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega48A" , 2048, 0x100, 512, 256, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega48P" , 2048, 0x100, 512, 256, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega48PA" , 2048, 0x100, 512, 256, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega88" , 4096, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega88A" , 4096, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega88P" , 4096, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega88PA" , 4096, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega168" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega168A" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega168P" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega168PA" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega328" , 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega328P" , 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega328PB" , 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega8515" , 8192, 0x060, 512, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega1280" , 65536, 0x200, 8192, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, + {"ATmega164P" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega164PA" , 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega324P" , 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega324PA" , 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega644" , 32768, 0x100, 4096, 2048, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega644P" , 32768, 0x100, 4096, 2096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega644PA" , 32768, 0x100, 4096, 2096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, + {"ATmega1284P" , 65536, 0x100, 16384, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, + {"ATmega1284PA", 65536, 0x100, 16384, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, + {"ATmega2560" , 131072, 0x200, 8192, 4096, DF_NO_ESPM}, + /* Other */ + {"AT94K" , 8192, 0x060, 16384, 0, DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, -struct device device_list[] = -{ - /* Name, Flash(words),RAM start, RAM size, EEPROM, flags */ - { NULL, 4194304, 0x60, 8388608, 65536, 0}, // Total instructions: 137 - /* ATtiny Series */ - // ATtiny4 - // ATtiny5 - // ATtiny9 - { "ATtiny10", 512, 0x00, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny11", 512, 0x00, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny12", 512, 0x00, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny13", 512, 0x60, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny13A", 512, 0x60, 64, 64, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny15", 512, 0x00, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - // ATtiny20 - { "ATtiny22", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny24", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny24A", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny25", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny26", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny28", 1024, 0x00, 0, 0, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - // ATtiny43U - { "ATtiny44", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny44A", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny45", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny84", 4096, 0x60, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny85", 4096, 0x60, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - // ATtiny87 - // ATtiny167 - // ATtiny261A - // ATtiny461A - // ATtiny861A - { "ATtiny2313", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny2313A", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - { "ATtiny4313", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_ELPM|DF_NO_ESPM|DF_NO_EICALL|DF_NO_EIJMP}, - /* AT90 series */ - { "AT90S1200", 512, 0x00, 0, 64, DF_NO_MUL|DF_NO_JMP|DF_TINY1X|DF_NO_XREG|DF_NO_YREG|DF_NO_LPM|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, // 137 - MUL(6) - JMP(2) - TINY(10) - { "AT90S2313", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S2323", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S2333", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S2343", 1024, 0x60, 128, 128, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S4414", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S4433", 2048, 0x60, 128, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S4434", 2048, 0x60, 256, 256, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S8515", 4096, 0x60, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, // 137 - MUL(6) - JMP(2) - LPM_X(2) - ELPM(3) - SPM - ESPM - MOVW - BREAK - EICALL - EIJMP = 118 - { "AT90C8534", 4096, 0x60, 256, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - { "AT90S8535", 4096, 0x60, 512, 512, DF_NO_MUL|DF_NO_JMP|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_MOVW|DF_NO_BREAK|DF_NO_EICALL|DF_NO_EIJMP}, - /* AT90USB series*/ - // AT90USB168 - // AT90USB1287 - /* ATmega series */ - { "ATmega8", 4096, 0x60, 1024, 512, DF_NO_JMP|DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega161", 8192, 0x60, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega162", 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega163", 8192, 0x60, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega16", 8192, 0x60, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega323", 16384, 0x60, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, // 137 - EICALL - EIJMP - ELPM(3) - ESPM = 131 (Data sheet says 130 but it's wrong) - { "ATmega328P", 16384, 0x100, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega32", 16384, 0x60, 2048, 1024, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega603", 32768, 0x60, 4096, 2048, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_MUL|DF_NO_MOVW|DF_NO_LPM_X|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, - { "ATmega103", 65536, 0x60, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_MUL|DF_NO_MOVW|DF_NO_LPM_X|DF_NO_ELPM_X|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, // 137 - EICALL - EIJMP - MUL(6) - MOVW - LPM_X(2) - ELPM_X(2) - SPM - ESPM - BREAK = 121 - { "ATmega104", 65536, 0x60, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, // Old name for mega128 - { "ATmega128", 65536, 0x100, 4096, 4096, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ESPM}, // 137 - EICALL - EIJMP - ESPM = 134 (Data sheet says 133 but it's wrong) - { "ATmega48", 2048, 0x100, 512, 256, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega88", 4096, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega168", 8192, 0x100, 1024, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - { "ATmega8515", 8192, 0x60, 512, 512, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_ESPM}, - /* Other */ - { "AT94K", 8192, 0x60, 16384, 0, DF_NO_EICALL|DF_NO_EIJMP|DF_NO_ELPM|DF_NO_SPM|DF_NO_ESPM|DF_NO_BREAK}, // 137 - EICALL - EIJMP - ELPM(3) - SPM - ESPM - BREAK = 129 - {NULL, 0, 0, 0, 0} + {NULL, 0, 0, 0, 0} }; static int LastDevice=0; -/*********************************************/ -/* Define vars for device in LastDevice */ -/*********************************************/ - -static void def_dev(struct prog_info *pi) +/* Define vars for device in LastDevice. */ +static void +def_dev(struct prog_info *pi) { - def_var(pi,DEV_VAR,LastDevice); - def_var(pi,FLASH_VAR,device_list[LastDevice].flash_size); - def_var(pi,EEPROM_VAR,device_list[LastDevice].eeprom_size); - def_var(pi,RAM_VAR,device_list[LastDevice].ram_size); + def_var(pi,DEV_VAR,LastDevice); + def_var(pi,FLASH_VAR,device_list[LastDevice].flash_size); + def_var(pi,EEPROM_VAR,device_list[LastDevice].eeprom_size); + def_var(pi,RAM_VAR,device_list[LastDevice].ram_size); } struct device *get_device(struct prog_info *pi, char *name) { int i = 1; - LastDevice = 0; - if(name == NULL) { - def_dev(pi); - return(&device_list[0]); + LastDevice = 0; + if (name == NULL) { + def_dev(pi); + return (&device_list[0]); } - while(device_list[i].name) { - if(!nocase_strcmp(name, device_list[i].name)) { + while (device_list[i].name) { + if (!nocase_strcmp(name, device_list[i].name)) { LastDevice=i; - def_dev(pi); - return(&device_list[i]); + def_dev(pi); + return (&device_list[i]); } i++; } def_dev(pi); - return(NULL); + return (NULL); } -// Pre-define devices. B.A. : Return value change from void to int -int predef_dev(struct prog_info *pi) +/* Pre-define devices. */ +int +predef_dev(struct prog_info *pi) { int i; char temp[MAX_DEV_NAME+1]; def_dev(pi); - for (i=0;(!i)||(device_list[i].name);i++) { + for (i=0; (!i)||(device_list[i].name); i++) { strncpy(temp,DEV_PREFIX,MAX_DEV_NAME); if (!i) strncat(temp,DEF_DEV_NAME,MAX_DEV_NAME); else strncat(temp,device_list[i].name,MAX_DEV_NAME); strncat(temp,DEV_SUFFIX,MAX_DEV_NAME); - /* B.A. : New. Forward references allowed. But check, if everything is ok ... */ - if(pi->pass==PASS_1) { /* Pass 1 */ - if(test_constant(pi,temp,NULL)!=NULL) { - fprintf(stderr,"Error: Can't define symbol %s twice. Please don't use predefined symbols !\n", temp); - return(False); - } - if(def_const(pi, temp, i)==False) - return(False); - } else { /* Pass 2 */ + /* Forward references allowed. But check, if everything is ok ... */ + if (pi->pass==PASS_1) { /* Pass 1 */ + if (test_constant(pi,temp,NULL)!=NULL) { + fprintf(stderr,"Error: Can't define symbol %s twice. Please don't use predefined symbols !\n", temp); + return (False); + } + if (def_const(pi, temp, i)==False) + return (False); + } else { /* Pass 2 */ int j; - if(get_constant(pi, temp, &j)==False) { /* Defined in Pass 1 and now missing ? */ - fprintf(stderr,"Constant %s is missing in pass 2\n",temp); - return(False); + if (get_constant(pi, temp, &j)==False) { /* Defined in Pass 1 and now missing ? */ + fprintf(stderr,"Constant %s is missing in pass 2\n",temp); + return (False); } - if(i != j) { - fprintf(stderr,"Constant %s changed value from %d in pass1 to %d in pass 2\n",temp,j,i); - return(False); + if (i != j) { + fprintf(stderr,"Constant %s changed value from %d in pass1 to %d in pass 2\n",temp,j,i); + return (False); } /* OK. definition is unchanged */ - } + } } - return(True); + return (True); } -void list_devices() +void +list_devices(void) { - int i = 1; - printf("Device name | Flash size | RAM start | RAM size | EEPROM size | Supported\n" - " | (words) | (bytes) | (bytes) | (bytes) | instructions\n" - "------------+------------+-----------+----------+-------------+--------------\n" - " (default) | %7d | 0x%04x | %7d | %5d | %3d\n", - device_list[0].flash_size, - device_list[0].ram_start, - device_list[0].ram_size, - device_list[0].eeprom_size, - count_supported_instructions(device_list[0].flag)); - while(device_list[i].name) { - printf(" %-10s | %7d | 0x%04x | %7d | %5d | %3d\n", - device_list[i].name, - device_list[i].flash_size, - device_list[i].ram_start, - device_list[i].ram_size, - device_list[i].eeprom_size, - count_supported_instructions(device_list[i].flag)); - i++; - } + int i = 1; + printf("Device name | Flash size | RAM start | RAM size | EEPROM size | Supported\n" + " | (words) | (bytes) | (bytes) | (bytes) | instructions\n" + "--------------+------------+-----------+----------+-------------+--------------\n" + " (default) | %7ld | 0x%04lx | %7ld | %5ld | %3d\n", + device_list[0].flash_size, + device_list[0].ram_start, + device_list[0].ram_size, + device_list[0].eeprom_size, + count_supported_instructions(device_list[0].flag)); + while (device_list[i].name) { + printf(" %-12s | %7ld | 0x%04lx | %7ld | %5ld | %3d\n", + device_list[i].name, + device_list[i].flash_size, + device_list[i].ram_start, + device_list[i].ram_size, + device_list[i].eeprom_size, + count_supported_instructions(device_list[i].flag)); + i++; + } } /* end of device.c */ diff -Nru avra-1.3.0/src/device.h avra-1.4.2+dfsg/src/device.h --- avra-1.3.0/src/device.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/device.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,33 +1,64 @@ +/*********************************************************************** + * + * AVRA - Assembler for the Atmel AVR microcontroller series + * + * Copyright (C) 1998-2020 The AVRA Authors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * + * Authors of AVRA can be reached at: + * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com + * www: https://github.com/Ro5bert/avra + */ /* Device flags */ -#define DF_NO_MUL 0x00000001 -#define DF_NO_JMP 0x00000002 // No JMP, CALL -#define DF_NO_XREG 0x00000004 // No X register -#define DF_NO_YREG 0x00000008 // No Y register -#define DF_TINY1X 0x00000010 /* AT90S1200, ATtiny10-12 set: No ADIW, SBIW, - IJMP, ICALL, LDD, STD, LDS, STS, PUSH, POP */ -#define DF_NO_LPM 0x00000020 // No LPM instruction -#define DF_NO_LPM_X 0x00000040 // No LPM Rd,Z or LPM Rd,Z+ instruction -#define DF_NO_ELPM 0x00000080 // No ELPM instruction -#define DF_NO_ELPM_X 0x00000100 // No ELPM Rd,Z or LPM Rd,Z+ instruction -#define DF_NO_SPM 0x00000200 // No SPM instruction -#define DF_NO_ESPM 0x00000400 // No ESPM instruction -#define DF_NO_MOVW 0x00000800 // No MOVW instruction -#define DF_NO_BREAK 0x00001000 // No BREAK instruction -#define DF_NO_EICALL 0x00002000 // No EICALL instruction -#define DF_NO_EIJMP 0x00004000 // No EIJMP instruction +#define DF_NO_MUL 0x0001 /* No {,F}MUL{,S,SU} */ +#define DF_NO_JMP 0x0002 /* No JMP, CALL */ +#define DF_NO_XREG 0x0004 /* No X register */ +#define DF_NO_YREG 0x0008 /* No Y register */ +#define DF_TINY1X 0x0010 /* AT90S1200, ATtiny11/12 set: No ADIW, SBIW, + * IJMP, ICALL, LDD, STD, LDS, STS, PUSH, POP */ +#define DF_NO_LPM 0x0020 /* No LPM instruction */ +#define DF_NO_LPM_X 0x0040 /* No LPM Rd,Z or LPM Rd,Z+ instruction */ +#define DF_NO_ELPM 0x0080 /* No ELPM instruction */ +#define DF_NO_ELPM_X 0x0100 /* No ELPM Rd,Z or LPM Rd,Z+ instruction */ +#define DF_NO_SPM 0x0200 /* No SPM instruction */ +#define DF_NO_ESPM 0x0400 /* No ESPM instruction */ +#define DF_NO_MOVW 0x0800 /* No MOVW instruction */ +#define DF_NO_BREAK 0x1000 /* No BREAK instruction */ +#define DF_NO_EICALL 0x2000 /* No EICALL instruction */ +#define DF_NO_EIJMP 0x4000 /* No EIJMP instruction */ +#define DF_AVR8L 0x8000 /* Also known as AVRrc (reduced core)? + * ATtiny4,5,9,10,20,40,102,104: No ADIW, SBIW; + * one word LDS/STS */ +/* If more flags are added, the size of the flag field in struct device must + * be increased! C ints are only guaranteed to be at least 16 bits, and we're + * currently using all of them. */ -struct device - { +struct device { char *name; - int flash_size; - int ram_start; - int ram_size; - int eeprom_size; + long flash_size; + long ram_start; + long ram_size; + long eeprom_size; int flag; - }; +}; /* device.c */ struct device *get_device(struct prog_info *pi,char *name); int predef_dev(struct prog_info *pi); -void list_devices(); +void list_devices(void); diff -Nru avra-1.3.0/src/directiv.c avra-1.4.2+dfsg/src/directiv.c --- avra-1.3.0/src/directiv.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/directiv.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** -// Modified at line 252 to print out DW value in list file by davidrjburke@hotmail.com 11 Nov 2005 - * avra - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * AVRA - Assembler for the Atmel AVR microcontroller series + * + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #include @@ -35,8 +35,7 @@ #include "avra.h" #include "device.h" -enum -{ +enum { DIRECTIVE_BYTE = 0, DIRECTIVE_CSEG, DIRECTIVE_CSEGSIZE, @@ -64,18 +63,19 @@ DIRECTIVE_IFNDEF, DIRECTIVE_IF, DIRECTIVE_ELSE, - DIRECTIVE_ELSEIF, /* B.A. : The Atmel AVR Assembler version 1.71 and later use ELSEIF and not ELIF */ - DIRECTIVE_ELIF, + DIRECTIVE_ELSEIF, /* The Atmel AVR Assembler version 1.71 and later use ELSEIF and not ELIF */ + DIRECTIVE_ELIF, DIRECTIVE_ENDIF, DIRECTIVE_MESSAGE, DIRECTIVE_WARNING, DIRECTIVE_ERROR, DIRECTIVE_PRAGMA, + DIRECTIVE_OVERLAP, + DIRECTIVE_NOOVERLAP, DIRECTIVE_COUNT }; -char *directive_list[] = -{ +static const char *const directive_list[] = { "BYTE", "CSEG", "CSEGSIZE", @@ -103,22 +103,62 @@ "IFNDEF", "IF", "ELSE", - "ELSEIF", /* B.A. : The Atmel AVR Assembler version 1.71 and later use ELSEIF and not ELIF */ + "ELSEIF", /* The Atmel AVR Assembler version 1.71 and later use ELSEIF and not ELIF */ "ELIF", "ENDIF", "MESSAGE", "WARNING", "ERROR", - "PRAGMA" + "PRAGMA", + "OVERLAP", + "NOOVERLAP", + NULL }; +enum { + PRAGMA_OVERLAP, + PRAGMA_COUNT +}; + +static const char *const pragma_list[] = { + "OVERLAP", + NULL +}; -int parse_directive(struct prog_info *pi) +static const char *const overlap_value[] = { + "DEFAULT", + "IGNORE", + "WARNING", + "ERROR", + NULL +}; + +/* caller has to free result */ +static char * +joinpaths(const char *dirname, const char *fname) { - int directive; + char *res; + int len; + + len = strlen(dirname); + res = malloc(len + strlen(fname) + 2); + if (!res) { + return NULL; + } + strcpy(res, dirname); + if ((res[len - 1] != '\\') && (res[len - 1] != '/')) + res[len++] = '/'; + strcpy(&res[len], fname); + return res; +} + +int +parse_directive(struct prog_info *pi) +{ + int directive, pragma; int ok = True; int i; - char *next, *data; + char *next, *data, buf[140]; struct file_info *fi_bak; struct def *def; @@ -126,807 +166,803 @@ next = get_next_token(pi->fi->scratch, TERM_SPACE); - for(i = 0; pi->fi->scratch[i] != '\0'; i++) { - pi->fi->scratch[i] = toupper(pi->fi->scratch[i]); - } - directive = get_directive_type(pi->fi->scratch + 1); - if(directive == -1) { + my_strupr(pi->fi->scratch); + directive = lookup_keyword(directive_list, pi->fi->scratch + 1, True); + if (directive == -1) { print_msg(pi, MSGTYPE_ERROR, "Unknown directive: %s", pi->fi->scratch); - return(True); + return (True); } - switch(directive) { - case DIRECTIVE_BYTE: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".BYTE needs a size operand"); - return(True); - } - if(pi->segment != SEGMENT_DATA) - print_msg(pi, MSGTYPE_ERROR, ".BYTE directive can only be used in data segment (.DSEG)"); - get_next_token(next, TERM_END); - if(!get_expr(pi, next, &i)) - return(False); - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, "D:%06x %s\n", pi->dseg_addr, pi->list_line); - pi->list_line = NULL; - } - pi->dseg_addr += i; - if(pi->pass == PASS_1) - pi->dseg_count += i; - break; - case DIRECTIVE_CSEG: - fix_orglist(pi); - pi->segment = SEGMENT_CODE; - def_orglist(pi); - break; - case DIRECTIVE_CSEGSIZE: - break; - case DIRECTIVE_DB: - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - } - return(parse_db(pi, next)); -// break; - /* Directive .def */ - case DIRECTIVE_DEF: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".DEF needs an operand"); - return(True); - } - data = get_next_token(next, TERM_EQUAL); - if(!(data && (tolower(data[0]) == 'r') && isdigit(data[1]))) { - print_msg(pi, MSGTYPE_ERROR, "%s needs a register (e.g. .def BZZZT = r16)", next); - return(True); - } - i = atoi(&data[1]); - /* check range of given register */ - if(i > 31) - print_msg(pi, MSGTYPE_ERROR, "R%d is not a valid register", i); - /* check if this reg is already assigned */ - for(def = pi->first_def; def; def = def->next) { - if(def->reg == i && pi->pass == PASS_1 && !pi->NoRegDef) { - print_msg(pi, MSGTYPE_WARNING, "r%d is already assigned to '%s'!", i, def->name); - return(True); - } - } - /* check if this regname is already defined */ - for(def = pi->first_def; def; def = def->next) { - if(!nocase_strcmp(def->name, next)) { - if(pi->pass == PASS_1 && !pi->NoRegDef) { - print_msg(pi, MSGTYPE_WARNING, "'%s' is already assigned as r%d but will now be set to r%i!", next, def->reg, i); - } - def->reg = i; - return(True); - } - } - /* B.A.: Check, if symbol is already defined as a label or constant */ - if(pi->pass == PASS_2) { - if(get_label(pi,next,NULL)) - print_msg(pi, MSGTYPE_WARNING, "Name '%s' is used for a register and a label", next); - if(get_constant(pi,next,NULL)) - print_msg(pi, MSGTYPE_WARNING, "Name '%s' is used for a register and a constant", next); - } - - def = malloc(sizeof(struct def)); - if(!def) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - def->next = NULL; - if(pi->last_def) - pi->last_def->next = def; - else - pi->first_def = def; - pi->last_def = def; - def->name = malloc(strlen(next) + 1); - if(!def->name) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(def->name, next); - def->reg = i; - break; - case DIRECTIVE_DEVICE: - if(pi->pass == PASS_2) - return(True); - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".DEVICE needs an operand"); - return(True); - } - if(pi->device->name!=NULL) { /* B.A.: Check for multiple device definitions */ - print_msg(pi, MSGTYPE_ERROR, "More than one .DEVICE definition"); + switch (directive) { + case DIRECTIVE_BYTE: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".BYTE needs a size operand"); + return (True); + } + if (pi->segment == pi->cseg) { + print_msg(pi, MSGTYPE_ERROR, ".BYTE directive cannot be used within the code segment (.CSEG)"); + return False; + } + get_next_token(next, TERM_END); + if (!get_expr(pi, next, &i)) + return (False); + if (i < 0) { + print_msg(pi, MSGTYPE_ERROR, ".BYTE directive must have nonnegative operand"); + return False; + } + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, "%c:%06lx %s\n", + pi->segment->ident, pi->segment->addr, pi->list_line); + pi->list_line = NULL; + } + advance_ip(pi->segment, i); + break; + case DIRECTIVE_CSEG: + fix_orglist(pi->segment); + def_orglist(pi->cseg); + break; + case DIRECTIVE_CSEGSIZE: + break; + case DIRECTIVE_DB: + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + } + return (parse_db(pi, next)); + /* Directive .def */ + case DIRECTIVE_DEF: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".DEF needs an operand"); + return (True); + } + data = get_next_token(next, TERM_EQUAL); + if (!(data && (tolower(data[0]) == 'r') && isdigit(data[1]))) { + print_msg(pi, MSGTYPE_ERROR, "%s needs a register (e.g. .def BZZZT = r16)", next); + return (True); + } + i = atoi(&data[1]); + /* check range of given register */ + if (i > 31) + print_msg(pi, MSGTYPE_ERROR, "R%d is not a valid register", i); + /* check if this reg is already assigned */ + for (def = pi->first_def; def; def = def->next) { + if (def->reg == i && pi->pass == PASS_1 && !pi->NoRegDef) { + print_msg(pi, MSGTYPE_WARNING, "r%d is already assigned to '%s'!", i, def->name); + return (True); } - if(pi->cseg_count || pi->dseg_count || pi->eseg_count) { /* B.A.: Check if something was already assembled */ - print_msg(pi, MSGTYPE_ERROR, ".DEVICE definition must be before any code lines"); - } else { - if(pi->cseg_addr || pi->eseg_addr || (pi->dseg_addr != pi->device->ram_start)) { /* B.A.: Check if something was already assembled */ - print_msg(pi, MSGTYPE_ERROR, ".DEVICE definition must be before any .ORG directive"); + } + /* check if this regname is already defined */ + for (def = pi->first_def; def; def = def->next) { + if (!nocase_strcmp(def->name, next)) { + if (pi->pass == PASS_1 && !pi->NoRegDef) { + print_msg(pi, MSGTYPE_WARNING, "'%s' is already assigned as r%d but will now be set to r%i!", next, def->reg, i); } + def->reg = i; + return (True); } + } + /* Check, if symbol is already defined as a label or constant */ + if (pi->pass == PASS_2) { + if (get_label(pi,next,NULL)) + print_msg(pi, MSGTYPE_WARNING, "Name '%s' is used for a register and a label", next); + if (get_constant(pi,next,NULL)) + print_msg(pi, MSGTYPE_WARNING, "Name '%s' is used for a register and a constant", next); + } - get_next_token(next, TERM_END); - pi->device = get_device(pi,next); - if(!pi->device) { - print_msg(pi, MSGTYPE_ERROR, "Unknown device: %s", next); - pi->device = get_device(pi,NULL); /* B.A.: Fix segmentation fault if device is unknown */ - } - - /* Now that we know the device type, we can - * start memory allocation from the correct offsets. - */ - fix_orglist(pi); - pi->cseg_addr = 0; - pi->dseg_addr = pi->device->ram_start; - pi->eseg_addr = 0; - def_orglist(pi); - break; - case DIRECTIVE_DSEG: - fix_orglist(pi); - pi->segment = SEGMENT_DATA; - def_orglist(pi); - if(pi->device->ram_size == 0) { - print_msg(pi, MSGTYPE_ERROR, "Can't use .DSEG directive because device has no RAM"); + def = malloc(sizeof(struct def)); + if (!def) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + def->next = NULL; + if (pi->last_def) + pi->last_def->next = def; + else + pi->first_def = def; + pi->last_def = def; + def->name = malloc(strlen(next) + 1); + if (!def->name) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(def->name, next); + def->reg = i; + break; + case DIRECTIVE_DEVICE: + if (pi->pass == PASS_2) + return (True); + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".DEVICE needs an operand"); + return (True); + } + if (pi->device->name != NULL) { /* Check for multiple device definitions */ + print_msg(pi, MSGTYPE_ERROR, "More than one .DEVICE definition"); + } + if (pi->cseg->count || pi->dseg->count || pi->eseg->count) { + /* Check if something was already assembled */ + print_msg(pi, MSGTYPE_ERROR, ".DEVICE definition must be before any code lines"); + } else { + if ((pi->cseg->addr != pi->cseg->lo_addr) + || (pi->dseg->addr != pi->dseg->lo_addr) + || (pi->eseg->addr != pi->eseg->lo_addr)) { + /* Check if something was already assembled */ + print_msg(pi, MSGTYPE_ERROR, ".DEVICE definition must be before any .ORG directive"); } - break; - case DIRECTIVE_DW: - if(pi->segment == SEGMENT_DATA) { - print_msg(pi, MSGTYPE_ERROR, "Can't use .DW directive in data segment (.DSEG)"); - return(True); - } - while(next) { - data = get_next_token(next, TERM_COMMA); - if(pi->pass == PASS_2) { - if(!get_expr(pi, next, &i)) - return(False); - if((i < -32768) || (i > 65535)) - print_msg(pi, MSGTYPE_WARNING, "Value %d is out of range (-32768 <= k <= 65535). Will be masked", i); - } - if(pi->segment == SEGMENT_EEPROM) { - if(pi->pass == PASS_2) { - write_ee_byte(pi, pi->eseg_addr, (unsigned char)i); - write_ee_byte(pi, pi->eseg_addr + 1, (unsigned char)(i >> 8)); - } - pi->eseg_addr += 2; - if(pi->pass == PASS_1) - pi->eseg_count += 2; - } - // Modified by David Burke to print DW word in list file 4/Nov/2005 - else { - if((pi->pass == PASS_2) && pi->hfi) { - write_prog_word(pi, pi->cseg_addr, i); - // Actual fiddling - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - fprintf(pi->list_file, "C:%06x %04x\n", pi->cseg_addr,i); - } - } - pi->cseg_addr++; - if(pi->pass == PASS_1) pi->cseg_count++; - } - // End of Modification by David Burke - next = data; + } + + get_next_token(next, TERM_END); + pi->device = get_device(pi,next); + if (!pi->device) { + print_msg(pi, MSGTYPE_ERROR, "Unknown device: %s", next); + pi->device = get_device(pi,NULL); /* Fix segmentation fault if device is unknown */ + } + + /* Now that we know the device type, we can + * start memory allocation from the correct offsets. + */ + fix_orglist(pi->segment); + + init_segment_size(pi, pi->device); /* Resync. ...->lo_addr variables */ + def_orglist(pi->segment); + break; + case DIRECTIVE_DSEG: + fix_orglist(pi->segment); + def_orglist(pi->dseg); + if (pi->dseg->hi_addr == 0) { + /* XXX move to emit */ + print_msg(pi, MSGTYPE_ERROR, "Can't use .DSEG directive because device has no RAM"); + } + break; + case DIRECTIVE_DW: + if (pi->segment->flags & SEG_BSS_DATA) { + print_msg(pi, MSGTYPE_ERROR, "Can't use .DW directive in data segment (.DSEG)"); + return (True); + } + while (next) { + data = get_next_token(next, TERM_COMMA); + if (pi->pass == PASS_2) { + if (!get_expr(pi, next, &i)) + return (False); + if ((i < -32768) || (i > 65535)) + print_msg(pi, MSGTYPE_WARNING, "Value %d is out of range (-32768 <= k <= 65535). Will be masked", i); + } + if (pi->pass == PASS_2) { + if (pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + fprintf(pi->list_file, "%c:%06lx %04x\n", + pi->segment->ident, pi->segment->addr, i); + } + if (pi->segment == pi->eseg) { + write_ee_byte(pi, pi->eseg->addr, (unsigned char)i); + write_ee_byte(pi, pi->eseg->addr + 1, (unsigned char)(i >> 8)); + } + if (pi->segment == pi->cseg) { + write_prog_word(pi, pi->cseg->addr, i); + } + } + if (pi->segment == pi->eseg) + advance_ip(pi->eseg, 2); + if (pi->segment == pi->cseg) + advance_ip(pi->cseg, 1); + next = data; + } + break; + case DIRECTIVE_ENDM: + case DIRECTIVE_ENDMACRO: + print_msg(pi, MSGTYPE_ERROR, "No .MACRO found before .ENDMACRO"); + break; + case DIRECTIVE_EQU: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".EQU needs an operand"); + return (True); + } + data = get_next_token(next, TERM_EQUAL); + if (!data) { + print_msg(pi, MSGTYPE_ERROR, "%s needs an expression (e.g. .EQU BZZZT = 0x2a)", next); + return (True); + } + get_next_token(data, TERM_END); + if (!get_expr(pi, data, &i)) + return (False); + if (test_label(pi,next,"%s have already been defined as a label")!=NULL) + return (True); + if (test_variable(pi,next,"%s have already been defined as a .SET variable")!=NULL) + return (True); + /* Forward references allowed. But check, if everything is ok ... */ + if (pi->pass==PASS_1) { /* Pass 1 */ + if (test_constant(pi,next,"Can't redefine constant %s, use .SET instead")!=NULL) + return (True); + if (def_const(pi, next, i)==False) + return (False); + } else { /* Pass 2 */ + int j; + if (get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */ + print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next); + return (False); + } + if (i != j) { + print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i); + return (False); } - break; - case DIRECTIVE_ENDM: - case DIRECTIVE_ENDMACRO: - print_msg(pi, MSGTYPE_ERROR, "No .MACRO found before .ENDMACRO"); - break; - case DIRECTIVE_EQU: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".EQU needs an operand"); - return(True); - } - data = get_next_token(next, TERM_EQUAL); - if(!data) { - print_msg(pi, MSGTYPE_ERROR, "%s needs an expression (e.g. .EQU BZZZT = 0x2a)", next); - return(True); + /* OK. Definition is unchanged */ + } + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + } + break; + case DIRECTIVE_ESEG: + fix_orglist(pi->segment); + def_orglist(pi->eseg); + if (pi->device->eeprom_size == 0) { /* XXX */ + print_msg(pi, MSGTYPE_ERROR, "Can't use .ESEG directive because device has no EEPROM"); + } + break; + case DIRECTIVE_EXIT: + pi->fi->exit_file = True; + break; + case DIRECTIVE_INCLUDE: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, "Nothing to include"); + return (True); + } + next = term_string(pi, next); + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + } + /* Test if include is in local directory */ + ok = test_include(next); + data = NULL; + if (!ok) { +#ifdef DEFAULT_INCLUDE_PATH + data = joinpaths(DEFAULT_INCLUDE_PATH, next); + ok = test_include(data); +#endif + for (incpath = GET_ARG_LIST(pi->args, ARG_INCLUDEPATH); incpath && !ok; incpath = incpath->next) { + if (data != NULL) { + free(data); + } + data = joinpaths(incpath->data, next); + if (data == NULL) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + ok = test_include(data); } + } + if (ok) { + fi_bak = pi->fi; + ok = parse_file(pi, data ? data : next); + pi->fi = fi_bak; + } else + print_msg(pi, MSGTYPE_ERROR, "Cannot find include file: %s", next); + if (data) + free(data); + break; + case DIRECTIVE_INCLUDEPATH: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".INCLUDEPATH needs an operand"); + return (True); + } + data = get_next_token(next, TERM_SPACE); + if (data) { + print_msg(pi, MSGTYPE_ERROR, ".INCLUDEPATH needs an operand!!!"); get_next_token(data, TERM_END); - if(!get_expr(pi, data, &i)) - return(False); - if(test_label(pi,next,"%s have already been defined as a label")!=NULL) - return(True); - if(test_variable(pi,next,"%s have already been defined as a .SET variable")!=NULL) - return(True); - /* B.A. : New. Forward references allowed. But check, if everything is ok ... */ - if(pi->pass==PASS_1) { /* Pass 1 */ - if(test_constant(pi,next,"Can't redefine constant %s, use .SET instead")!=NULL) - return(True); - if(def_const(pi, next, i)==False) - return(False); - } else { /* Pass 2 */ - int j; - if(get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */ - print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next); - return(False); - } - if(i != j) { - print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i); - return(False); - } - /* OK. Definition is unchanged */ - } - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - } - break; - case DIRECTIVE_ESEG: - fix_orglist(pi); - pi->segment = SEGMENT_EEPROM; - def_orglist(pi); - if(pi->device->eeprom_size == 0) { - print_msg(pi, MSGTYPE_ERROR, "Can't use .ESEG directive because device has no EEPROM"); - } - break; - case DIRECTIVE_EXIT: - pi->fi->exit_file = True; - break; - /*** .include ***/ - case DIRECTIVE_INCLUDE: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, "Nothing to include"); - return(True); + if (!get_expr(pi, data, &i)) + return (False); + } + next = term_string(pi, next); + /* get arg list start pointer */ + incpath = GET_ARG_LIST(pi->args, ARG_INCLUDEPATH); + /* search for last element */ + if (incpath == NULL) { + dl = malloc(sizeof(struct data_list)); + data = malloc(strlen(next)+1); + if (dl && data) { + dl->next = NULL; + strcpy(data, next); + dl->data = data; + SET_ARG_LIST(pi->args, ARG_INCLUDEPATH, dl); + } else { + printf("Error: Unable to allocate memory\n"); + return (False); } - next = term_string(pi, next); - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - } - // Test if include is in local directory - ok = test_include(next); - data = NULL; - if(!ok) - for(incpath = GET_ARG(pi->args, ARG_INCLUDEPATH); incpath && !ok; incpath = incpath->next) { - i = strlen(incpath->data); - if(data) - free(data); - data = malloc(i + strlen(next) + 2); - if(!data) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(data, incpath->data); - if((data[i - 1] != '\\') && (data[i - 1] != '/')) - data[i++] = '/'; - strcpy(&data[i], next); - //printf("testing: %s\n", data); - ok = test_include(data); - } - if(ok) { - fi_bak = pi->fi; - ok = parse_file(pi, data ? data : next); - pi->fi = fi_bak; - } - else - print_msg(pi, MSGTYPE_ERROR, "Cannot find include file: %s", next); - if(data) - free(data); - break; - /*** .includepath ***/ - case DIRECTIVE_INCLUDEPATH: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".INCLUDEPATH needs an operand"); - return(True); - } - data = get_next_token(next, TERM_SPACE); - if(data) { - print_msg(pi, MSGTYPE_ERROR, ".INCLUDEPATH needs an operand!!!"); - get_next_token(data, TERM_END); - if(!get_expr(pi, data, &i)) - return(False); + } else + add_arg(&incpath, next); + break; + case DIRECTIVE_LIST: + if (pi->pass == PASS_2) + if (pi->list_file) + pi->list_on = True; + break; + case DIRECTIVE_LISTMAC: + if (pi->pass == PASS_2) + SET_ARG_I(pi->args, ARG_LISTMAC, True); + break; + case DIRECTIVE_MACRO: + return (read_macro(pi, next)); + case DIRECTIVE_NOLIST: + if (pi->pass == PASS_2) + pi->list_on = False; + break; + case DIRECTIVE_ORG: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".ORG needs an operand"); + return (True); + } + get_next_token(next, TERM_END); + if (!get_expr(pi, next, &i)) + return (False); + fix_orglist(pi->segment); + pi->segment->addr = i; /* XXX advance */ + def_orglist(pi->segment); + if (pi->fi->label) + pi->fi->label->value = i; + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + } + break; + case DIRECTIVE_SET: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".SET needs an operand"); + return (True); + } + data = get_next_token(next, TERM_EQUAL); + if (!data) { + print_msg(pi, MSGTYPE_ERROR, "%s needs an expression (e.g. .SET BZZZT = 0x2a)", next); + return (True); + } + get_next_token(data, TERM_END); + if (!get_expr(pi, data, &i)) + return (False); + + if (test_label(pi,next,"%s have already been defined as a label")!=NULL) + return (True); + if (test_constant(pi,next,"%s have already been defined as a .EQU constant")!=NULL) + return (True); + return (def_var(pi, next, i)); + case DIRECTIVE_DEFINE: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".DEFINE needs an operand"); + return (True); + } + data = get_next_token(next, TERM_SPACE); + if (data) { + get_next_token(data, TERM_END); + if (!get_expr(pi, data, &i)) + return (False); + } else + i = 1; + if (test_label(pi,next,"%s have already been defined as a label")!=NULL) + return (True); + if (test_variable(pi,next,"%s have already been defined as a .SET variable")!=NULL) + return (True); + /* Forward references allowed. But check, if everything is ok ... */ + if (pi->pass==PASS_1) { /* Pass 1 */ + if (test_constant(pi,next,"Can't redefine constant %s, use .SET instead")!=NULL) + return (True); + if (def_const(pi, next, i)==False) + return (False); + } else { /* Pass 2 */ + int j; + if (get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */ + print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next); + return (False); + } + if (i != j) { + print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i); + return (False); } - next = term_string(pi, next); - /* get arg list start pointer */ - incpath = GET_ARG(pi->args, ARG_INCLUDEPATH); - /* search for last element */ - if(incpath == NULL) { - dl = malloc(sizeof(struct data_list)); - data = malloc(strlen(next)+1); - if(dl && data) { - dl->next = NULL; - strcpy(data, next); - dl->data = data; - SET_ARG(pi->args, ARG_INCLUDEPATH, dl); - } - else { - printf("Error: Unable to allocate memory\n"); - return(False); - } - } - else - add_arg(&incpath, next); - break; - case DIRECTIVE_LIST: - if(pi->pass == PASS_2) - if(pi->list_file) - pi->list_on = True; - break; - case DIRECTIVE_LISTMAC: - if(pi->pass == PASS_2) - SET_ARG(pi->args, ARG_LISTMAC, True); - break; - case DIRECTIVE_MACRO: - return(read_macro(pi, next)); -// break; - case DIRECTIVE_NOLIST: - if(pi->pass == PASS_2) - pi->list_on = False; - break; - case DIRECTIVE_ORG: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".ORG needs an operand"); - return(True); - } - get_next_token(next, TERM_END); - if(!get_expr(pi, next, &i)) - return(False); - fix_orglist(pi); /* Update last segment */ - switch(pi->segment) { - case SEGMENT_CODE: - pi->cseg_addr = i; + /* OK. Definition is unchanged */ + } + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) { + fprintf(pi->list_file, " %s\n", pi->list_line); + pi->list_line = NULL; + } + break; + case DIRECTIVE_NOOVERLAP: + if (pi->pass == PASS_1) { + fix_orglist(pi->segment); + pi->segment_overlap = SEG_DONT_OVERLAP; + def_orglist(pi->segment); + } + break; + case DIRECTIVE_OVERLAP: + if (pi->pass == PASS_1) { + fix_orglist(pi->segment); + pi->segment_overlap = SEG_ALLOW_OVERLAP; + def_orglist(pi->segment); + } + break; + case DIRECTIVE_PRAGMA: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, "PRAGMA needs an operand, %s should be specified", + snprint_list(buf, sizeof(buf), pragma_list)); + return (True); + } + my_strupr(next); + data = get_next_token(next, TERM_SPACE); + pragma = lookup_keyword(pragma_list, next, False); + switch (pragma) { + + case PRAGMA_OVERLAP: + if (pi->pass == PASS_1) { + int overlap_setting = OVERLAP_UNDEFINED; + if (data) { + my_strupr(data); + overlap_setting = lookup_keyword(overlap_value, data, False); + }; + switch (overlap_setting) { + case OVERLAP_DEFAULT: + pi->effective_overlap = GET_ARG_I(pi->args, ARG_OVERLAP); break; - case SEGMENT_DATA: - pi->dseg_addr = i; + + case OVERLAP_IGNORE: + case OVERLAP_WARNING: + case OVERLAP_ERROR: + pi->effective_overlap = overlap_setting; break; - case SEGMENT_EEPROM: - pi->eseg_addr = i; - } - def_orglist(pi); /* Create new segment */ - if(pi->fi->label) - pi->fi->label->value = i; - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - } - break; - case DIRECTIVE_SET: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".SET needs an operand"); - return(True); - } - data = get_next_token(next, TERM_EQUAL); - if(!data) { - print_msg(pi, MSGTYPE_ERROR, "%s needs an expression (e.g. .SET BZZZT = 0x2a)", next); - return(True); - } - get_next_token(data, TERM_END); - if(!get_expr(pi, data, &i)) - return(False); - if(test_label(pi,next,"%s have already been defined as a label")!=NULL) - return(True); - if(test_constant(pi,next,"%s have already been defined as a .EQU constant")!=NULL) - return(True); - return(def_var(pi, next, i)); -// break; - case DIRECTIVE_DEFINE: - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".DEFINE needs an operand"); - return(True); - } - data = get_next_token(next, TERM_SPACE); - if(data) { - get_next_token(data, TERM_END); - if(!get_expr(pi, data, &i)) - return(False); - } - else - i = 1; - if(test_label(pi,next,"%s have already been defined as a label")!=NULL) - return(True); - if(test_variable(pi,next,"%s have already been defined as a .SET variable")!=NULL) - return(True); - /* B.A. : New. Forward references allowed. But check, if everything is ok ... */ - if(pi->pass==PASS_1) { /* Pass 1 */ - if(test_constant(pi,next,"Can't redefine constant %s, use .SET instead")!=NULL) - return(True); - if(def_const(pi, next, i)==False) - return(False); - } else { /* Pass 2 */ - int j; - if(get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */ - print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next); - return(False); - } - if(i != j) { - print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i); - return(False); - } - /* OK. Definition is unchanged */ - } - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) { - fprintf(pi->list_file, " %s\n", pi->list_line); - pi->list_line = NULL; - } - break; - case DIRECTIVE_PRAGMA: -#if 0 - may_do_something_with_pragma_someday(); -#else - // if ( !flag_no_warnings ) - print_msg(pi, MSGTYPE_MESSAGE, "PRAGMA directives currently ignored"); -#endif - break; - case DIRECTIVE_UNDEF: // TODO - break; - case DIRECTIVE_IFDEF: - if(!next) - { - print_msg(pi, MSGTYPE_ERROR, ".IFDEF needs an operand"); - return(True); - } - get_next_token(next, TERM_END); - /* B.A. : Forward referenc is not allowed for ifdef and ifndef */ - /* Store undefined symbols in blacklist in pass1 and check, if they are still undefined in pass2 */ - if(get_symbol(pi, next, NULL)) { -#if 0 - // If it's not defined in the first pass, but was defined later - // then it should be considered OK with regards to ifdef..endif and - // ifndef..endif code sections. Removed this code. - if(pi->pass==PASS_2) { /* B.A. : 'Still undefined'-test in pass 2 */ - if(test_blacklist(pi,next,"Forward reference (%s) not allowed in .ifdef directive")!=NULL) - return(False); + default: + print_msg(pi, MSGTYPE_ERROR, "For PRAGMA %s directive" + " %s should be specified as the parameter", next, + snprint_list(buf, sizeof(buf), overlap_value)); + return (False); } -#else - pi->conditional_depth++; -#endif - } else { - if(pi->pass==PASS_1) { /* B.A. : Store undefined symbols in pass 1 */ - if(def_blacklist(pi, next)==False) - return(False); - } - if(!spool_conditional(pi, False)) - return(False); } - break; - case DIRECTIVE_IFNDEF: - if(!next) - { - print_msg(pi, MSGTYPE_ERROR, ".IFNDEF needs an operand"); - return(True); - } - get_next_token(next, TERM_END); - /* B.A. : Forward referenc is not allowed for ifdef and ifndef */ - /* Store undefined symbols in blacklist in pass1 and check, if they are still undefined in pass2 */ - if(get_symbol(pi, next, NULL)) - { -#if 0 - if(pi->pass==PASS_2) { /* B.A. : 'Still undefined'-test in pass 2 */ - // If it's not defined in the first pass, but was defined later - // then it should be considered OK with regards to ifdef..endif and - // ifndef..endif code sections. Removed this code. - if(test_blacklist(pi,next,"Forward reference (%s) not allowed in .ifndef directive")!=NULL) - return(False); - } - if(!spool_conditional(pi, False)) - return(False); -#else - pi->conditional_depth++; -#endif + return (True); + break; + default: + if (pi->pass == PASS_2) + print_msg(pi, MSGTYPE_MESSAGE, "PRAGMA %s directive currently ignored", next); + return (True); + } + break; + case DIRECTIVE_UNDEF: /* TODO */ + break; + case DIRECTIVE_IFDEF: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".IFDEF needs an operand"); + return True; + } + get_next_token(next, TERM_END); + /* Store location of ifdef (line number and file number) if the condition + * fails on pass 1 so that we do not reinterpret it as succeeding on pass 2. */ + if ((pi->pass==PASS_1 && get_symbol(pi, next, NULL)) || (pi->pass==PASS_2 && !ifdef_is_blacklisted(pi))) { + pi->conditional_depth++; + } else { + if (pi->pass==PASS_1) { + /* Blacklist this ifdef. */ + if (!ifdef_blacklist(pi)) { + return False; } - else { - if(pi->pass==PASS_1) { /* B.A. : Store undefined symbols in pass 1 */ - if(def_blacklist(pi, next)==False) - return(False); - } - pi->conditional_depth++; } - break; - case DIRECTIVE_IF: - if(!next) - { - print_msg(pi, MSGTYPE_ERROR, ".IF needs an expression"); - return(True); - } - get_next_token(next, TERM_END); - if(!get_expr(pi, next, &i)) - return(False); - if(i) - pi->conditional_depth++; - else - { - if(!spool_conditional(pi, False)) - return(False); + if (!spool_conditional(pi, False)) { + return False; + } + } + break; + case DIRECTIVE_IFNDEF: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".IFNDEF needs an operand"); + return True; + } + get_next_token(next, TERM_END); + /* Store location of ifndef (line number and file number) if the condition + * fails on pass 1 so that we do not reinterpret it as succeeding on pass 2. */ + if ((pi->pass==PASS_1 && !get_symbol(pi, next, NULL)) || (pi->pass==PASS_2 && !ifndef_is_blacklisted(pi))) { + pi->conditional_depth++; + } else { + if (pi->pass==PASS_1) { + /* Blacklist this ifndef. */ + if (!ifndef_blacklist(pi)) { + return False; } - break; - case DIRECTIVE_ELSE: - case DIRECTIVE_ELIF: - case DIRECTIVE_ELSEIF: - if(!spool_conditional(pi, True)) - return(False); - break; - case DIRECTIVE_ENDIF: - if(pi->conditional_depth == 0) - print_msg(pi, MSGTYPE_ERROR, "Too many .ENDIF"); - else - pi->conditional_depth--; - break; - case DIRECTIVE_MESSAGE: - if(pi->pass == PASS_1) - return(True); - if(!next) { - print_msg(pi, MSGTYPE_ERROR, "No message parameter supplied"); - return(True); - } - /* B.A : Extended .MESSAGE. Now a comma separated list like in .db is possible and not only a string */ - print_msg(pi, MSGTYPE_MESSAGE_NO_LF, NULL); /* Prints Line Header (filename, linenumber) without trailing /n */ - while(next) { /* Modified code from parse_db(). Thank you :-) */ - data = get_next_token(next, TERM_COMMA); - if(next[0] == '\"') { /* string parsing */ - next = term_string(pi, next); - print_msg(pi, MSGTYPE_APPEND,"%s",next); - while(*next != '\0') { + } + if (!spool_conditional(pi, False)) { + return False; + } + } + break; + case DIRECTIVE_IF: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".IF needs an expression"); + return (True); + } + get_next_token(next, TERM_END); + if (!get_expr(pi, next, &i)) + return (False); + if (i) + pi->conditional_depth++; + else { + if (!spool_conditional(pi, False)) + return (False); + } + break; + case DIRECTIVE_ELSE: + case DIRECTIVE_ELIF: + case DIRECTIVE_ELSEIF: + if (!spool_conditional(pi, True)) + return (False); + break; + case DIRECTIVE_ENDIF: + if (pi->conditional_depth == 0) + print_msg(pi, MSGTYPE_ERROR, "Too many .ENDIF"); + else + pi->conditional_depth--; + break; + case DIRECTIVE_MESSAGE: + if (pi->pass == PASS_1) + return (True); + if (!next) { + print_msg(pi, MSGTYPE_ERROR, "No message parameter supplied"); + return (True); + } + print_msg(pi, MSGTYPE_MESSAGE_NO_LF, NULL); /* Prints Line Header (filename, linenumber) without trailing \n */ + while (next) { + data = get_next_token(next, TERM_COMMA); + if (next[0] == '\"') { /* string parsing */ + next = term_string(pi, next); + print_msg(pi, MSGTYPE_APPEND,"%s",next); + while (*next != '\0') { next++; - } - } else { - if(!get_expr(pi, next, &i)) { - print_msg(pi, MSGTYPE_APPEND,"\n"); /* Add newline */ - return(False); - } - print_msg(pi, MSGTYPE_APPEND,"0x%02X",i); - } - next = data; - } - print_msg(pi, MSGTYPE_APPEND,"\n"); /* Add newline */ - break; - case DIRECTIVE_WARNING: - if(pi->pass == PASS_1) - return(True); - if(!next) { - print_msg(pi, MSGTYPE_ERROR, "No warning string supplied"); - return(True); + } + } else { + if (!get_expr(pi, next, &i)) { + print_msg(pi, MSGTYPE_APPEND,"\n"); /* Add newline */ + return (False); + } + print_msg(pi, MSGTYPE_APPEND,"0x%02X",i); } - next = term_string(pi, next); - print_msg(pi, MSGTYPE_WARNING, next); - break; - case DIRECTIVE_ERROR: - if(!next) { /* B.A : Fix segfault bug if .error without parameter was used */ - print_msg(pi, MSGTYPE_ERROR, "No error string supplied"); - return(True); - } - next = term_string(pi, next); - /* B.A. : Don't use this. It may cause segfaults if the 'next' contains printf control sequences %s,%d etc. - print_msg(pi, MSGTYPE_ERROR, next); - */ - print_msg(pi, MSGTYPE_ERROR,"%s",next); /* B.A. : This is '%s' save :-) */ - pi->error_count = pi->max_errors; - if(pi->pass == PASS_1) - return(True); - break; + next = data; + } + print_msg(pi, MSGTYPE_APPEND,"\n"); /* Add newline */ + break; + case DIRECTIVE_WARNING: + if (pi->pass == PASS_1) + return (True); + if (!next) { + print_msg(pi, MSGTYPE_ERROR, "No warning string supplied"); + return (True); + } + next = term_string(pi, next); + print_msg(pi, MSGTYPE_WARNING, next); + break; + case DIRECTIVE_ERROR: + if (!next) { + print_msg(pi, MSGTYPE_ERROR, "No error string supplied"); + return (True); + } + next = term_string(pi, next); + print_msg(pi, MSGTYPE_ERROR, "%s", next); + pi->error_count = pi->max_errors; + if (pi->pass == PASS_1) + return (True); + break; } - return(ok); + return (ok); } -int get_directive_type(char *directive) { - int i; +int +lookup_keyword(const char *const keyword_list[], const char *const keyword, int strict) +{ + int i; - for(i = 0; i < DIRECTIVE_COUNT; i++) { - if(!strcmp(directive, directive_list[i])) return(i); - } - return(-1); + for (i = 0; keyword_list[i] != NULL; i++) { + if (strict) { + if (!strcmp(keyword, keyword_list[i])) + return (i); + } else { + if (!strncmp(keyword, keyword_list[i], strlen(keyword_list[i]))) + return (i); + } + } + return (-1); } +char * +term_string(struct prog_info *pi, char *string) +{ + int i; -char *term_string(struct prog_info *pi, char *string) { - int i; - - if(string[0] != '\"') { - print_msg(pi, MSGTYPE_ERROR, "String must be enclosed in \"-signs"); - } - else { - string++; - } - /* skip to the end of the string*/ - for(i = 0; (string[i] != '\"') && !((string[i] == 10) || (string[i] == 13) || (string[i] == '\0')); i++); - if((string[i] == 10) || (string[i] == 13) || (string[i] == '\0')) { - print_msg(pi, MSGTYPE_ERROR, "String is missing a closing \"-sign"); - } - string[i] = '\0'; /* and terminate it where the " was */ - return(string); + if (string[0] != '\"') { + print_msg(pi, MSGTYPE_ERROR, "String must be enclosed in \"-signs"); + } else { + string++; + } + /* skip to the end of the string*/ + for (i = 0; (string[i] != '\"') && !((string[i] == 10) || (string[i] == 13) || (string[i] == '\0')); i++); + if ((string[i] == 10) || (string[i] == 13) || (string[i] == '\0')) { + print_msg(pi, MSGTYPE_ERROR, "String is missing a closing \"-sign"); + } + string[i] = '\0'; /* and terminate it where the " was */ + return (string); } /* Parse data byte directive */ -int parse_db(struct prog_info *pi, char *next) { - int i; - int count; - char *data; - char prev = 0; - - /* check if .db is allowed in this segment type */ - if(pi->segment == SEGMENT_DATA) { - print_msg(pi, MSGTYPE_ERROR, "Can't use .DB directive in data segment (.DSEG) !"); - return(True); - } - - count = 0; - if(pi->pass == PASS_2 && pi->list_on) { - if(pi->segment == SEGMENT_EEPROM) - fprintf(pi->list_file, "E:%06X ", pi->eseg_addr); - if(pi->segment == SEGMENT_CODE) - fprintf(pi->list_file, "C:%06X ", pi->cseg_addr); - } - /* get each db token */ - while(next) { - data = get_next_token(next, TERM_COMMA); - /* string parsing */ - if(next[0] == '\"') { - next = term_string(pi, next); - while(*next != '\0') { - count++; - write_db(pi, *next, &prev, count); - if(pi->pass == PASS_2 && pi->list_on) - fprintf(pi->list_file, "%02X", (unsigned char)*next); // B.A.: Patch for chars with bit 7 = 1 (Example: °) - if((unsigned char)*next > 127 && pi->pass == PASS_2) - print_msg(pi, MSGTYPE_WARNING, "Found .DB string with characters > code 127. Be careful !"); // B.A.: Print warning for codes > 127 - next++; - } - } - else { - if(pi->pass == PASS_2) { - if(!get_expr(pi, next, &i)) - return(False); - if((i < -128) || (i > 255)) - print_msg(pi, MSGTYPE_WARNING, "Value %d is out of range (-128 <= k <= 255). Will be masked", i); - if(pi->list_on) fprintf(pi->list_file, "%02X", i); - } - count++; - write_db(pi, (char)i, &prev, count); - } - next = data; - } - if(pi->segment == SEGMENT_CODE) { - if((count % 2) == 1) { - if(pi->pass == PASS_2) { - if(pi->list_on) fprintf(pi->list_file, "00 ; zero byte added"); - write_prog_word(pi, pi->cseg_addr, prev & 0xFF); - print_msg(pi, MSGTYPE_WARNING, "A .DB segment with an odd number of bytes is detected. A zero byte is added."); - } - pi->cseg_addr++; - if(pi->pass == PASS_1) { - pi->cseg_count++; - } - } - } - if(pi->pass == PASS_2 && pi->list_on) { - fprintf(pi->list_file, "\n"); - pi->list_line = NULL; - } - return(True); +int +parse_db(struct prog_info *pi, char *next) +{ + int i; + int count; + char *data; + char prev = 0; + + /* check if .db is allowed in this segment type */ + if (pi->segment->flags & SEG_BSS_DATA) { + print_msg(pi, MSGTYPE_ERROR, "Can't use .DB directive in data segment (.DSEG) !"); + return True ; + } + + count = 0; + if (pi->pass == PASS_2 && pi->list_on) { + fprintf(pi->list_file, "%c:%06lX ", pi->segment->ident, pi->segment->addr); + } + /* get each db token */ + while (next) { + data = get_next_token(next, TERM_COMMA); + /* string parsing */ + if (next[0] == '\"') { + next = term_string(pi, next); + while (*next != '\0') { + count++; + write_db(pi, *next, &prev, count); + if (pi->pass == PASS_2 && pi->list_on) + fprintf(pi->list_file, "%02X", (unsigned char)*next); + if ((unsigned char)*next > 127 && pi->pass == PASS_2) + print_msg(pi, MSGTYPE_WARNING, "Found .DB string with characters > code 127. Be careful !"); /* Print warning for codes > 127 */ + next++; + } + } else { + if (pi->pass == PASS_2) { + if (!get_expr(pi, next, &i)) + return (False); + if ((i < -128) || (i > 255)) + print_msg(pi, MSGTYPE_WARNING, "Value %d is out of range (-128 <= k <= 255). Will be masked", i); + if (pi->list_on) fprintf(pi->list_file, "%02X", i); + } + count++; + write_db(pi, (char)i, &prev, count); + } + next = data; + } + if (pi->segment == pi->cseg) { /* XXX PAD */ + if ((count % 2) == 1) { + if (pi->pass == PASS_2) { + if (pi->list_on) fprintf(pi->list_file, "00 ; zero byte added"); + write_prog_word(pi, pi->segment->addr, prev & 0xFF); + print_msg(pi, MSGTYPE_WARNING, "A .DB segment with an odd number of bytes is detected. A zero byte is added."); + } + advance_ip(pi->cseg, 1); + } + } + if (pi->pass == PASS_2 && pi->list_on) { + fprintf(pi->list_file, "\n"); + pi->list_line = NULL; + } + return True; } -void write_db(struct prog_info *pi, char byte, char *prev, int count) { - if(pi->segment == SEGMENT_EEPROM) { - if(pi->pass == PASS_2) { - write_ee_byte(pi, pi->eseg_addr, byte); - } - pi->eseg_addr++; - if(pi->pass == PASS_1) { - pi->eseg_count++; - } - } - else { /* pi->segment == SEGMENT_CODE */ - if((count % 2) == 0) { - if(pi->pass == PASS_2) { - write_prog_word(pi, pi->cseg_addr, (byte << 8) | (*prev & 0xff)); - } - pi->cseg_addr++; - if(pi->pass == PASS_1) { - pi->cseg_count++; - } +void +write_db(struct prog_info *pi, char byte, char *prev, int count) +{ + if (pi->segment == pi->eseg) { + if (pi->pass == PASS_2) { + write_ee_byte(pi, pi->eseg->addr, byte); + } + advance_ip(pi->eseg, 1); } - else { - *prev = byte; + if (pi->segment == pi->cseg) { + if ((count % 2) == 0) { + if (pi->pass == PASS_2) { + write_prog_word(pi, pi->cseg->addr, (byte << 8) | (*prev & 0xff)); + } + advance_ip(pi->cseg, 1); + } else { + *prev = byte; + } } - } } -int spool_conditional(struct prog_info *pi, int only_endif) { +int +spool_conditional(struct prog_info *pi, int only_endif) +{ int current_depth = 0, do_next; - if(pi->macro_line) { - while((pi->macro_line = pi->macro_line->next)) { - pi->macro_call->line_index++; - if(check_conditional(pi, pi->macro_line->line, ¤t_depth, &do_next, only_endif)) { - if(!do_next) - return(True); + if (pi->macro_line) { + while ((pi->macro_line = pi->macro_line->next)) { + pi->macro_call->line_index++; + if (check_conditional(pi, pi->macro_line->line, ¤t_depth, &do_next, only_endif)) { + if (!do_next) + return (True); + } else + return (False); } - else - return(False); - } - print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDIF in macro"); - } - else { - while(fgets_new(pi,pi->fi->buff, LINEBUFFER_LENGTH, pi->fi->fp)) { - pi->fi->line_number++; - if(check_conditional(pi, pi->fi->buff, ¤t_depth, &do_next, only_endif)) { - if(!do_next) - return(True); + print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDIF in macro"); + } else { + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) + fprintf(pi->list_file, " %s\n", pi->list_line); + while (fgets_new(pi,pi->fi->buff, LINEBUFFER_LENGTH, pi->fi->fp)) { + pi->fi->line_number++; + if (check_conditional(pi, pi->fi->buff, ¤t_depth, &do_next, only_endif)) { + if (!do_next) + return (True); + } else + return (False); + } + if (feof(pi->fi->fp)) { + print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDIF"); + return (True); + } else { + perror(pi->fi->include_file->name); + return (False); } - else - return(False); - } - if(feof(pi->fi->fp)) { - print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDIF"); - return(True); - } - else { - perror(pi->fi->include_file->name); - return(False); - } } - return(True); + return (True); } -int check_conditional(struct prog_info *pi, char *pbuff, int *current_depth, int *do_next, int only_endif) +int +check_conditional(struct prog_info *pi, char *pbuff, int *current_depth, int *do_next, int only_endif) { int i = 0; char *next; char linebuff[LINEBUFFER_LENGTH]; - strcpy(linebuff, pbuff); /* avoid cutting of the end of .elif line */ + strcpy(linebuff, pbuff); /* avoid cutting of the end of .elif line */ *do_next = False; - while(IS_HOR_SPACE(linebuff[i]) && !IS_END_OR_COMMENT(linebuff[i])) i++; -#if 0 - if(linebuff[i] == '.') { -#else - if((linebuff[i] == '.') || (linebuff[i] == '#')){ -#endif - i++; - if(!nocase_strncmp(&linebuff[i], "if", 2)) - (*current_depth)++; - else - if(!nocase_strncmp(&linebuff[i], "endif", 5)) { - if(*current_depth == 0) - return(True); - (*current_depth)--; - } else - if(!only_endif && (*current_depth == 0)) { - /* B.A. : Add ELSEIF = ELIF */ - if((!nocase_strncmp(&linebuff[i], "else", 4)) && (nocase_strncmp(&linebuff[i], "elseif", 6))) { - pi->conditional_depth++; - return(True); - } else - if((!nocase_strncmp(&linebuff[i], "elif", 4)) || (!nocase_strncmp(&linebuff[i], "elseif", 6))) { - next = get_next_token(&linebuff[i], TERM_SPACE); - if(!next) { - print_msg(pi, MSGTYPE_ERROR, ".ELSEIF / .ELIF needs an operand"); - return(True); - } - get_next_token(next, TERM_END); - if(!get_expr(pi, next, &i)) - return(False); - if(i) - pi->conditional_depth++; - else { - if(!spool_conditional(pi, False)) - return(False); - } - return(True); - } - } + while (IS_HOR_SPACE(linebuff[i]) && !IS_END_OR_COMMENT(linebuff[i])) i++; + if ((linebuff[i] == '.') || (linebuff[i] == '#')) { + i++; + if (!nocase_strncmp(&linebuff[i], "if", 2)) + (*current_depth)++; + else if (!nocase_strncmp(&linebuff[i], "endif", 5)) { + if (*current_depth == 0) + return (True); + (*current_depth)--; + } else if (!only_endif && (*current_depth == 0)) { + if ((!nocase_strncmp(&linebuff[i], "else", 4)) && (nocase_strncmp(&linebuff[i], "elseif", 6))) { + pi->conditional_depth++; + return (True); + } else if ((!nocase_strncmp(&linebuff[i], "elif", 4)) || (!nocase_strncmp(&linebuff[i], "elseif", 6))) { + next = get_next_token(&linebuff[i], TERM_SPACE); + if (!next) { + print_msg(pi, MSGTYPE_ERROR, ".ELSEIF / .ELIF needs an operand"); + return (True); + } + get_next_token(next, TERM_END); + if (!get_expr(pi, next, &i)) + return (False); + if (i) + pi->conditional_depth++; + else { + if (!spool_conditional(pi, False)) + return (False); + } + return (True); + } + } } *do_next = True; - return(True); + return (True); } -int test_include(const char *filename) +int +test_include(const char *filename) { - FILE *fp; - fp = fopen(filename, "r"); - if(fp) - { - fclose(fp); - return(True); - } - else - return(False); + FILE *fp; + fp = fopen(filename, "r"); + if (fp) { + fclose(fp); + return (True); + } else + return (False); } /* end of directiv.c */ diff -Nru avra-1.3.0/src/expr.c avra-1.4.2+dfsg/src/expr.c --- avra-1.3.0/src/expr.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/expr.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #include @@ -58,7 +58,7 @@ OPERATOR_BITWISE_OR, OPERATOR_LOGICAL_AND, OPERATOR_LOGICAL_OR - }; +}; enum { FUNCTION_LOW = 0, @@ -75,17 +75,14 @@ FUNCTION_COUNT }; -struct element - { +struct element { struct element *next; int data; - }; +}; char *function_list[] = { - /* - ** allow whitespace between function name - ** and opening brace... - */ + /* allow whitespace between function name + * and opening brace... */ "low", "byte1", "high", @@ -99,288 +96,292 @@ "log2" }; -int log_2(int value) +int +log_2(int value) { - int i = 0; - while(value >>= 1) - i++; - return(i); + int i = 0; + while (value >>= 1) + i++; + return (i); } -int get_operator(char *op) +int +get_operator(char *op) { - switch(op[0]) { - case '*': - return(OPERATOR_MUL); - case '/': - return(OPERATOR_DIV); - case '%': - return(OPERATOR_MOD); - case '+': - return(OPERATOR_ADD); - case '-': - return(OPERATOR_SUB); + switch (op[0]) { + case '*': + return (OPERATOR_MUL); + case '/': + return (OPERATOR_DIV); + case '%': + return (OPERATOR_MOD); + case '+': + return (OPERATOR_ADD); + case '-': + return (OPERATOR_SUB); + case '<': + switch (op[1]) { case '<': - switch(op[1]) { - case '<': - return(OPERATOR_SHIFT_LEFT); - case '=': - return(OPERATOR_LESS_OR_EQUAL); - default: - return(OPERATOR_LESS_THAN); - } + return (OPERATOR_SHIFT_LEFT); + case '=': + return (OPERATOR_LESS_OR_EQUAL); + default: + return (OPERATOR_LESS_THAN); + } + case '>': + switch (op[1]) { case '>': - switch(op[1]) { - case '>': - return(OPERATOR_SHIFT_RIGHT); - case '=': - return(OPERATOR_GREATER_OR_EQUAL); - default: - return(OPERATOR_GREATER_THAN); - } + return (OPERATOR_SHIFT_RIGHT); case '=': - if(op[1] == '=') - return(OPERATOR_EQUAL); - case '!': - if(op[1] == '=') - return(OPERATOR_NOT_EQUAL); - case '&': - if(op[1] == '&') - return(OPERATOR_LOGICAL_AND); - else - return(OPERATOR_BITWISE_AND); - case '^': - return(OPERATOR_BITWISE_XOR); - case '|': - if(op[1] == '|') - return(OPERATOR_LOGICAL_OR); - else - return(OPERATOR_BITWISE_OR); + return (OPERATOR_GREATER_OR_EQUAL); + default: + return (OPERATOR_GREATER_THAN); + } + case '=': + if (op[1] == '=') + return (OPERATOR_EQUAL); + case '!': + if (op[1] == '=') + return (OPERATOR_NOT_EQUAL); + case '&': + if (op[1] == '&') + return (OPERATOR_LOGICAL_AND); + else + return (OPERATOR_BITWISE_AND); + case '^': + return (OPERATOR_BITWISE_XOR); + case '|': + if (op[1] == '|') + return (OPERATOR_LOGICAL_OR); + else + return (OPERATOR_BITWISE_OR); } - return(OPERATOR_ERROR); + return (OPERATOR_ERROR); } -int test_operator_at_precedence(int operator, int precedence) +int +test_operator_at_precedence(int operator, int precedence) { - switch(precedence) { - case 13: - return((operator == OPERATOR_MUL) || (operator == OPERATOR_DIV) - || (operator == OPERATOR_MOD)); - case 12: - return((operator == OPERATOR_ADD) || (operator == OPERATOR_SUB)); - case 11: - return((operator == OPERATOR_SHIFT_LEFT) || (operator == OPERATOR_SHIFT_RIGHT)); - case 10: - return((operator == OPERATOR_LESS_THAN) || (operator == OPERATOR_LESS_OR_EQUAL) - || (operator == OPERATOR_GREATER_THAN) || (operator == OPERATOR_GREATER_OR_EQUAL)); - case 9: - return((operator == OPERATOR_EQUAL) || (operator == OPERATOR_NOT_EQUAL)); - case 8: - return(operator == OPERATOR_BITWISE_AND); - case 7: - return(operator == OPERATOR_BITWISE_XOR); - case 6: - return(operator == OPERATOR_BITWISE_OR); - case 5: - return(operator == OPERATOR_LOGICAL_AND); - default: /* Makes the compiler shut up */ - case 4: - return(operator == OPERATOR_LOGICAL_OR); + switch (precedence) { + case 13: + return ((operator == OPERATOR_MUL) || (operator == OPERATOR_DIV) + || (operator == OPERATOR_MOD)); + case 12: + return ((operator == OPERATOR_ADD) || (operator == OPERATOR_SUB)); + case 11: + return ((operator == OPERATOR_SHIFT_LEFT) || (operator == OPERATOR_SHIFT_RIGHT)); + case 10: + return ((operator == OPERATOR_LESS_THAN) || (operator == OPERATOR_LESS_OR_EQUAL) + || (operator == OPERATOR_GREATER_THAN) || (operator == OPERATOR_GREATER_OR_EQUAL)); + case 9: + return ((operator == OPERATOR_EQUAL) || (operator == OPERATOR_NOT_EQUAL)); + case 8: + return (operator == OPERATOR_BITWISE_AND); + case 7: + return (operator == OPERATOR_BITWISE_XOR); + case 6: + return (operator == OPERATOR_BITWISE_OR); + case 5: + return (operator == OPERATOR_LOGICAL_AND); + default: /* Makes the compiler shut up */ + case 4: + return (operator == OPERATOR_LOGICAL_OR); } } -int calc(struct prog_info *pi, int left, int operator, int right) // TODO: Sjekk litt resultater +int +calc(struct prog_info *pi, int left, int operator, int right) /* TODO: Sjekk litt resultater */ { - switch(operator) { - case OPERATOR_MUL: - return(left * right); - case OPERATOR_DIV: - if(right == 0) { - print_msg(pi, MSGTYPE_ERROR, "Division by zero"); - return(0); - } - return(left / right); - case OPERATOR_MOD: - if(right == 0) { - print_msg(pi, MSGTYPE_ERROR, "Division by zero (modulus operator)"); - return(0); - } - return(left % right); - case OPERATOR_ADD: - return(left + right); - case OPERATOR_SUB: - return(left - right); - case OPERATOR_SHIFT_LEFT: - return(left << right); - case OPERATOR_SHIFT_RIGHT: - return((unsigned)left >> right); - case OPERATOR_LESS_THAN: - return(left < right); - case OPERATOR_LESS_OR_EQUAL: - return(left <= right); - case OPERATOR_GREATER_THAN: - return(left > right); - case OPERATOR_GREATER_OR_EQUAL: - return(left >= right); - case OPERATOR_EQUAL: - return(left == right); - case OPERATOR_NOT_EQUAL: - return(left != right); - case OPERATOR_BITWISE_AND: - return(left & right); - case OPERATOR_BITWISE_XOR: - return(left ^ right); - case OPERATOR_BITWISE_OR: - return(left | right); - case OPERATOR_LOGICAL_AND: - return(left && right); - default: /* Make the compiler shut up */ - case OPERATOR_LOGICAL_OR: - return(left || right); + switch (operator) { + case OPERATOR_MUL: + return (left * right); + case OPERATOR_DIV: + if (right == 0) { + print_msg(pi, MSGTYPE_ERROR, "Division by zero"); + return (0); + } + return (left / right); + case OPERATOR_MOD: + if (right == 0) { + print_msg(pi, MSGTYPE_ERROR, "Division by zero (modulus operator)"); + return (0); + } + return (left % right); + case OPERATOR_ADD: + return (left + right); + case OPERATOR_SUB: + return (left - right); + case OPERATOR_SHIFT_LEFT: + return (left << right); + case OPERATOR_SHIFT_RIGHT: + return ((unsigned)left >> right); + case OPERATOR_LESS_THAN: + return (left < right); + case OPERATOR_LESS_OR_EQUAL: + return (left <= right); + case OPERATOR_GREATER_THAN: + return (left > right); + case OPERATOR_GREATER_OR_EQUAL: + return (left >= right); + case OPERATOR_EQUAL: + return (left == right); + case OPERATOR_NOT_EQUAL: + return (left != right); + case OPERATOR_BITWISE_AND: + return (left & right); + case OPERATOR_BITWISE_XOR: + return (left ^ right); + case OPERATOR_BITWISE_OR: + return (left | right); + case OPERATOR_LOGICAL_AND: + return (left && right); + default: /* Make the compiler shut up */ + case OPERATOR_LOGICAL_OR: + return (left || right); } } /* If found, return the ID of the internal function */ -int get_function(char *function) +int +get_function(char *function) { int i; - for(i = 0; i < FUNCTION_COUNT; i++) { - if(!nocase_strncmp(function, function_list[i], strlen(function_list[i]))) - { - /* - ** some more checks to allow whitespace between function name - ** and opening brace... - */ - char *tmp = function + strlen(function_list[i]); - while (*tmp <= ' ') - tmp++; - if (*tmp != '(') - continue; - - return(i); - } - } - return(-1); + for (i = 0; i < FUNCTION_COUNT; i++) { + if (!nocase_strncmp(function, function_list[i], strlen(function_list[i]))) { + /* some more checks to allow whitespace between function name + * and opening brace... */ + char *tmp = function + strlen(function_list[i]); + while (*tmp <= ' ') + tmp++; + if (*tmp != '(') + continue; + + return (i); + } + } + return (-1); } -unsigned int do_function(int function, int value) +unsigned int +do_function(int function, int value) { - switch(function) { - case FUNCTION_LOW: - case FUNCTION_BYTE1: - return(value & 0xFF); - case FUNCTION_HIGH: - case FUNCTION_BYTE2: - return((value >> 8) & 0xff); - case FUNCTION_BYTE3: - return((value >> 16) & 0xff); - case FUNCTION_BYTE4: - return((value >> 24) & 0xff); - case FUNCTION_LWRD: - return(value & 0xffff); - case FUNCTION_HWRD: - return((value >> 16) & 0xffff); - case FUNCTION_PAGE: - return((value >> 16) & 0xff); - case FUNCTION_EXP2: - return(1 << value); - case FUNCTION_LOG2: - return(log_2(value)); - default: - return(0); + switch (function) { + case FUNCTION_LOW: + case FUNCTION_BYTE1: + return (value & 0xFF); + case FUNCTION_HIGH: + case FUNCTION_BYTE2: + return ((value >> 8) & 0xff); + case FUNCTION_BYTE3: + return ((value >> 16) & 0xff); + case FUNCTION_BYTE4: + return ((value >> 24) & 0xff); + case FUNCTION_LWRD: + return (value & 0xffff); + case FUNCTION_HWRD: + return ((value >> 16) & 0xffff); + case FUNCTION_PAGE: + return ((value >> 16) & 0xff); + case FUNCTION_EXP2: + return (1 << value); + case FUNCTION_LOG2: + return (log_2(value)); + default: + return (0); } } -int get_symbol(struct prog_info *pi, char *label_name, int *data) +int +get_symbol(struct prog_info *pi, char *label_name, int *data) { struct label *label; struct macro_call *macro_call; - if(get_constant(pi,label_name,data)) return(True); - if(get_variable(pi,label_name,data)) return(True); + if (get_constant(pi,label_name,data)) return (True); + if (get_variable(pi,label_name,data)) return (True); - for(macro_call = pi->macro_call; macro_call; macro_call = macro_call->prev_on_stack) { - for(label = pi->macro_call->first_label; label; label = label->next) - if(!nocase_strcmp(label->name, label_name)) { - if(data) + for (macro_call = pi->macro_call; macro_call; macro_call = macro_call->prev_on_stack) { + for (label = pi->macro_call->first_label; label; label = label->next) + if (!nocase_strcmp(label->name, label_name)) { + if (data) *data = label->value; - return(True); + return (True); } } - if(get_label(pi,label_name,data)) return(True); - return(False); + if (get_label(pi,label_name,data)) return (True); + return (False); } -int par_length(char *data) +int +par_length(char *data) { int i = 0, b_count = 1; - for(;;) { - if(data[i] == ')') { + for (;;) { + if (data[i] == ')') { b_count--; - if(!b_count) - return(i); - } - else if(data[i] == '(') + if (!b_count) + return (i); + } else if (data[i] == '(') b_count++; - else if(data[i] == '\0') - return(-1); + else if (data[i] == '\0') + return (-1); i++; } } -int get_expr(struct prog_info *pi, char *data, int *value) { - /* Definition */ +int +get_expr(struct prog_info *pi, char *data, int *value) +{ + /* Definition */ int ok, end, i, count, first_flag, length, function; char unary, *label; struct element *element, *first_element = NULL, *temp_element; struct element **last_element = &first_element; - /* Initialisation */ - first_flag = True; - ok = True; - end = False; - count = 0; - unary = 0; - /* the expression parser loop */ - for(i = 0; ; i++) { - /* horizontal space is just skipped */ - if(IS_HOR_SPACE(data[i])); + /* Initialisation */ + first_flag = True; + ok = True; + end = False; + count = 0; + unary = 0; + /* the expression parser loop */ + for (i = 0; ; i++) { + /* horizontal space is just skipped */ + if (IS_HOR_SPACE(data[i])); /* test for clean or premature end */ - else if(IS_END_OR_COMMENT(data[i])) { - if((count % 2) != 1) + else if (IS_END_OR_COMMENT(data[i])) { + if ((count % 2) != 1) print_msg(pi, MSGTYPE_ERROR, "Missing value in expression"); else end = True; break; - } - else if(first_flag && IS_UNARY(data[i])) { + } else if (first_flag && IS_UNARY(data[i])) { unary = data[i]; first_flag = False; - } - else if((count % 2) == 1) { - if(!IS_OPERATOR(data[i])) { + } else if ((count % 2) == 1) { + if (!IS_OPERATOR(data[i])) { print_msg(pi, MSGTYPE_ERROR, "Illegal operator '%c'", data[i]); break; } element = malloc(sizeof(struct element)); - if(!element) { + if (!element) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); ok = False; break; } element->next = NULL; element->data = get_operator(&data[i]); - if(element->data == OPERATOR_ERROR) { - if(IS_2ND_OPERATOR(data[i + 1])) + if (element->data == OPERATOR_ERROR) { + if (IS_2ND_OPERATOR(data[i + 1])) print_msg(pi, MSGTYPE_ERROR, "Unknown operator %c%c", data[i], data[i + 1]); else print_msg(pi, MSGTYPE_ERROR, "Unknown operator %c", data[i]); @@ -388,99 +389,91 @@ } *last_element = element; last_element = &element->next; - if(IS_2ND_OPERATOR(data[i + 1])) + if (IS_2ND_OPERATOR(data[i + 1])) i++; count++; first_flag = True; unary = 0; - } - else { + } else { element = malloc(sizeof(struct element)); - if(!element) { + if (!element) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); ok = False; break; } element->next = NULL; length = 0; - if(isdigit(data[i])) { - if(tolower(data[i + 1]) == 'x') { + if (isdigit(data[i])) { + if (tolower(data[i + 1]) == 'x') { i += 2; - while(isxdigit(data[i + length])) length++; // TODO: Sjekk overflow + while (isxdigit(data[i + length])) length++; /* TODO: Sjekk overflow */ element->data = atox_n(&data[i], length); - } - else if(tolower(data[i + 1]) == 'b') { + } else if (tolower(data[i + 1]) == 'b') { i += 2; element->data = 0; - while((data[i + length] == '1') || (data[i + length] == '0')) { + while ((data[i + length] == '1') || (data[i + length] == '0')) { element->data <<= 1; - element->data |= data[i + length++] - '0'; // TODO: Sjekk overflow + element->data |= data[i + length++] - '0'; /* TODO: Sjekk overflow */ } + } else { + while (isdigit(data[i + length])) length++; + element->data = atoi_n(&data[i], length); /* TODO: Sjekk overflow */ } - else { - while(isdigit(data[i + length])) length++; - element->data = atoi_n(&data[i], length); // TODO: Sjekk overflow - } - } - else if(data[i] == '$') { + } else if (data[i] == '$') { i++; - while(isxdigit(data[i + length])) length++; - element->data = atox_n(&data[i], length); // TODO: Sjekk overflow - } - else if(data[i] == '\'') { + while (isxdigit(data[i + length])) length++; + element->data = atox_n(&data[i], length); /* TODO: Sjekk overflow */ + } else if (data[i] == '\'') { i++; - if(data[i+1] != '\'') { + if (data[i+1] != '\'') { print_msg(pi, MSGTYPE_ERROR, "Not a correct character ! Use 'A' !"); break; } element->data = data[i]; length = 2; - } - else if(data[i] == '(') { + } else if (data[i] == '(') { i++; length = par_length(&data[i]); - if(length == -1) { + if (length == -1) { print_msg(pi, MSGTYPE_ERROR, "Missing ')'"); break; } data[i + length++] = '\0'; ok = get_expr(pi, &data[i], &element->data); - if(!ok) + if (!ok) break; } /* test for internal function */ - else if((function = get_function(&data[i])) != -1) { - while(data[i] != '(') + else if ((function = get_function(&data[i])) != -1) { + while (data[i] != '(') i++; i++; length = par_length(&data[i]); - if(length == -1) { + if (length == -1) { print_msg(pi, MSGTYPE_ERROR, "Missing ')'"); break; } data[i + length++] = '\0'; ok = get_expr(pi, &data[i], &element->data); - if(!ok) + if (!ok) break; element->data = do_function(function, element->data); - } - else if(!nocase_strncmp(&data[i], "defined(", 8)) { + } else if (!nocase_strncmp(&data[i], "defined(", 8)) { i += 8; length = par_length(&data[i]); - if(length == -1) { + if (length == -1) { print_msg(pi, MSGTYPE_ERROR, "Missing ')'"); break; } data[i + length++] = '\0'; - if(get_symbol(pi, &data[i], NULL)) + if (get_symbol(pi, &data[i], NULL)) element->data = 1; else element->data = 0; - } - else if(!nocase_strncmp(&data[i], "supported(", 10)) { + } else if (!nocase_strncmp(&data[i], "supported(", 10)) { i += 10; length = par_length(&data[i]); - if(length == -1) { + if (length == -1) { print_msg(pi, MSGTYPE_ERROR, "Missing ')'"); break; } @@ -490,33 +483,30 @@ if (toupper(data[i])=='X') { if (pi->device->flag&DF_NO_XREG) element->data = 0; else element->data = 1; - } - else if (toupper(data[i])=='Y') { + } else if (toupper(data[i])=='Y') { if (pi->device->flag&DF_NO_YREG) element->data = 0; else element->data = 1; - } - else if (toupper(data[i])=='Z') + } else if (toupper(data[i])=='Z') element->data = 1; else { print_msg(pi, MSGTYPE_ERROR, "Unknown mnemonic: %s",&data[i]); element->data = 0; } } - } - else { - while(IS_LABEL(data[i + length])) length++; - if((length == 2) && !nocase_strncmp(&data[i], "PC", 2)) - element->data = pi->cseg_addr; + } else { + while (IS_LABEL(data[i + length])) length++; + if ((length == 2) && !nocase_strncmp(&data[i], "PC", 2)) + element->data = pi->cseg->addr; else { label = malloc(length + 1); - if(!label) { + if (!label) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); ok = False; break; } strncpy(label, &data[i], length); label[length] = '\0'; - if(get_symbol(pi, label, &element->data)) + if (get_symbol(pi, label, &element->data)) free(label); else { print_msg(pi, MSGTYPE_ERROR, "Found no label/variable/constant named %s", label); @@ -527,15 +517,15 @@ } /* now the expression has been evaluated */ i += length - 1; - switch(unary) { // TODO: Få den til å takle flere unary på rad. - case '-': - element->data = -element->data; - break; - case '!': - element->data = !element->data; - break; - case '~': - element->data = ~element->data; + switch (unary) { /* TODO: Få den til å takle flere unary på rad. */ + case '-': + element->data = -element->data; + break; + case '!': + element->data = !element->data; + break; + case '~': + element->data = ~element->data; } *last_element = element; last_element = &element->next; @@ -543,29 +533,28 @@ first_flag = False; } } - if(end) { - for(i = 13; (i >= 4) && (count != 1); i--) { - for(element = first_element; element->next;) { - if(test_operator_at_precedence(element->next->data, i)) { // TODO: Vurder en hi_i for kjapphet + if (end) { + for (i = 13; (i >= 4) && (count != 1); i--) { + for (element = first_element; element->next;) { + if (test_operator_at_precedence(element->next->data, i)) { /* TODO: Vurder en hi_i for kjapphet */ element->data = calc(pi, element->data, element->next->data, element->next->next->data); temp_element = element->next->next->next; free(element->next->next); free(element->next); count -= 2; element->next = temp_element; - } - else + } else element = element->next->next; } } *value = first_element->data; } - for(element = first_element; element;) { + for (element = first_element; element;) { temp_element = element; element = element->next; free(temp_element); } - return(ok); + return (ok); } diff -Nru avra-1.3.0/src/file.c avra-1.4.2+dfsg/src/file.c --- avra-1.3.0/src/file.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/file.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,232 +20,241 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #include #include #include #include -#include /* B.A. for unlink function */ +#include #include "misc.h" #include "avra.h" #include "args.h" - -int open_out_files(struct prog_info *pi, char *filename) +int +open_out_files(struct prog_info *pi, const char *basename, const char *outputfile, + const char *debugfile, const char *eepfile) { int length; char *buff; int ok = True; /* flag for coff results */ - length = strlen(filename); + length = strlen(basename); buff = malloc(length + 9); - if(buff == NULL) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(buff, filename); - if(length < 4) { - printf("Error: wrong input file name\n"); - } - if(!nocase_strcmp(&buff[length - 4], ".asm")) { - length -= 4; - buff[length] = '\0'; - } - //printf("pi->cseg_count = %i\n", pi->cseg_count); - //printf("pi->eseg_count = %i\n", pi->eseg_count); - + if (buff == NULL) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(buff, basename); + if (length < 4) { + printf("Error: wrong input file name\n"); + } + if (!nocase_strcmp(&buff[length - 4], ".asm")) { + length -= 4; + buff[length] = '\0'; + } + /* open files for code output */ - strcpy(&buff[length], ".hex"); - if(!(pi->hfi = open_hex_file(buff))) { /* check if open failed */ - print_msg(pi, MSGTYPE_ERROR, "Could not create output hex file!"); - ok = False; - } - strcpy(&buff[length], ".obj"); - if(!(pi->obj_file = open_obj_file(pi, buff))) { - print_msg(pi, MSGTYPE_ERROR, "Could not create object file!"); - ok = False; - } - + strcpy(&buff[length], ".hex"); + if (!(pi->cseg->hfi = open_hex_file((outputfile == NULL) ? buff : outputfile))) { + print_msg(pi, MSGTYPE_ERROR, "Could not create output hex file!"); + ok = False; + } + + strcpy(&buff[length], ".obj"); + if (!(pi->obj_file = open_obj_file(pi, (debugfile == NULL) ? buff : debugfile))) { + print_msg(pi, MSGTYPE_ERROR, "Could not create object file!"); + ok = False; + } + /* open files for eeprom output */ - strcpy(&buff[length], ".eep.hex"); - if(!(pi->eep_hfi = open_hex_file(buff))) { + strcpy(&buff[length], ".eep.hex"); + if (!(pi->eseg->hfi = open_hex_file((eepfile == NULL) ? buff : eepfile))) { print_msg(pi, MSGTYPE_ERROR, "Could not create eeprom hex file!"); - ok = False; - } - /* coff file is always generated */ - strcpy(&buff[length], ".cof"); - pi->coff_file = open_coff_file(pi, buff); - /* open list file */ + ok = False; + } + + if (GET_ARG_I(pi->args, ARG_COFF) == True) { + strcpy(&buff[length], ".cof"); + pi->coff_file = open_coff_file(pi, buff); + } else + pi->coff_file = 0; + + /* open list file */ if (pi->list_on) { - strcpy(buff, GET_ARG(pi->args, ARG_LISTFILE)); - pi->list_file = fopen(buff, "w"); - if(pi->list_file == NULL) { + pi->list_file = fopen(GET_ARG_P(pi->args, ARG_LISTFILE), "w"); + if (pi->list_file == NULL) { print_msg(pi, MSGTYPE_ERROR, "Could not create list file!"); - ok = False; - } - /* write list file header */ - fprintf(pi->list_file, "\nAVRA Ver. %i.%i.%i %s %s\n\n",VER_MAJOR, VER_MINOR, VER_RELEASE, filename, ctime(&pi->time)); - } - else { - pi->list_file = NULL; - } - free(buff); - - if(ok) - return(True); - else - close_out_files(pi); - return(False); + ok = False; + } + /* write list file header */ + fprintf(pi->list_file, + "\nAVRA Ver. %s %s %s\n\n", + VERSION, basename, ctime(&pi->time)); + } else { + pi->list_file = NULL; + } + free(buff); + + if (ok) + return True; + else { + close_out_files(pi); + return False; + } } /* delete all output files */ -void unlink_out_files(struct prog_info *pi, char *filename) +void +unlink_out_files(struct prog_info *pi, const char *filename) { char *buff; int length; - close_out_files(pi); + close_out_files(pi); length = strlen(filename); buff = malloc(length + 9); - if(buff == NULL) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return; - } - strcpy(buff, filename); - if(!nocase_strcmp(&buff[length - 4], ".asm")) { - length -= 4; - buff[length] = '\0'; - } -#if debug == 1 - printf("unlinking files"); -#endif - strcpy(&buff[length], ".hex"); - unlink(buff); - strcpy(&buff[length], ".obj"); - unlink(buff); - strcpy(&buff[length], ".eep.hex"); - unlink(buff); - strcpy(&buff[length], ".cof"); - unlink(buff); - strcpy(&buff[length], ".lst"); - unlink(buff); - strcpy(&buff[length], ".map"); - unlink(buff); -} - -void close_out_files(struct prog_info *pi) -{ - char stmp[2048]; - - if(pi->error_count == 0) { - sprintf(stmp, - "Segment usage:\n" - " Code : %7d words (%d bytes)\n" - " Data : %7d bytes\n" - " EEPROM : %7d bytes\n", - pi->cseg_count, pi->cseg_count * 2, pi->dseg_count, pi->eseg_count); - printf("%s", stmp); - } - if(pi->hfi) - close_hex_file(pi->hfi); - if(pi->eep_hfi) - close_hex_file(pi->eep_hfi); - if(pi->list_file) { - fprintf(pi->list_file, "\n\n%s", stmp); - if(pi->error_count == 0) + if (buff == NULL) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return; + } + strcpy(buff, filename); + if (!nocase_strcmp(&buff[length - 4], ".asm")) { + length -= 4; + buff[length] = '\0'; + } + strcpy(&buff[length], ".hex"); + unlink(buff); + strcpy(&buff[length], ".obj"); + unlink(buff); + strcpy(&buff[length], ".eep.hex"); + unlink(buff); + strcpy(&buff[length], ".cof"); + unlink(buff); + strcpy(&buff[length], ".lst"); + unlink(buff); + strcpy(&buff[length], ".map"); + unlink(buff); +} + +void +close_out_files(struct prog_info *pi) +{ + char stmp[2048]; + + if (pi->error_count == 0) { + snprintf(stmp, sizeof(stmp), + "Segment usage:\n" + " Code : %7ld words (%ld bytes)\n" + " Data : %7ld bytes\n" + " EEPROM : %7ld bytes\n", + pi->cseg->count, pi->cseg->count * 2, pi->dseg->count, pi->eseg->count); + printf("%s", stmp); + } + if (pi->cseg->hfi) + close_hex_file(pi->cseg->hfi); + if (pi->eseg->hfi) + close_hex_file(pi->eseg->hfi); + if (pi->list_file) { + fprintf(pi->list_file, "\n\n%s", stmp); + if (pi->error_count == 0) fprintf(pi->list_file, "\nAssembly completed with no errors.\n"); fclose(pi->list_file); } - if(pi->obj_file) - close_obj_file(pi, pi->obj_file); - if(pi->coff_file) - close_coff_file(pi, pi->coff_file); + if (pi->obj_file) + close_obj_file(pi, pi->obj_file); + if (pi->coff_file) + close_coff_file(pi, pi->coff_file); } - -struct hex_file_info *open_hex_file(char *filename) +struct hex_file_info * +open_hex_file(const char *filename) { struct hex_file_info *hfi; hfi = calloc(1, sizeof(struct hex_file_info)); - if(hfi) { + if (hfi) { hfi->segment = -1; hfi->fp = fopen(filename, "wb"); - if(!hfi->fp) { + if (!hfi->fp) { close_hex_file(hfi); hfi = NULL; } } - return(hfi); + return hfi; } - -void close_hex_file(struct hex_file_info *hfi) +void +close_hex_file(struct hex_file_info *hfi) { - if(hfi->fp) { - if(hfi->count != 0) - do_hex_line(hfi); + if (hfi->fp) { + if (hfi->count != 0) + do_hex_line(hfi); fprintf(hfi->fp, ":00000001FF\x0d\x0a"); fclose(hfi->fp); } free(hfi); } - -void write_ee_byte(struct prog_info *pi, int address, unsigned char data) +void +write_ee_byte(struct prog_info *pi, int address, unsigned char data) { - if((pi->eep_hfi->count == 16) || ((address != (pi->eep_hfi->linestart_addr + pi->eep_hfi->count)) && (pi->eep_hfi->count != 0))) - do_hex_line(pi->eep_hfi); - if(pi->eep_hfi->count == 0) - pi->eep_hfi->linestart_addr = address; - pi->eep_hfi->hex_line[pi->eep_hfi->count++] = data; + if ((pi->eseg->hfi->count == 16) + || ((address != (pi->eseg->hfi->linestart_addr + pi->eseg->hfi->count)) + && (pi->eseg->hfi->count != 0))) + do_hex_line(pi->eseg->hfi); + if (pi->eseg->hfi->count == 0) + pi->eseg->hfi->linestart_addr = address; + pi->eseg->hfi->hex_line[pi->eseg->hfi->count++] = data; - if(pi->coff_file) - write_coff_eeprom(pi, address, data); + if (pi->coff_file) + write_coff_eeprom(pi, address, data); } -void write_prog_word(struct prog_info *pi, int address, int data) +void +write_prog_word(struct prog_info *pi, int address, int data) { + struct hex_file_info *hfi = pi->cseg->hfi; write_obj_record(pi, address, data); address *= 2; - if(pi->hfi->segment != (address >> 16)) { - if(pi->hfi->count != 0) - do_hex_line(pi->hfi); - pi->hfi->segment = address >> 16; - if(pi->hfi->segment >= 16) // Use 04 record for addresses above 1 meg since 02 can support max 1 meg - fprintf(pi->hfi->fp, ":02000004%04X%02X\x0d\x0a", pi->hfi->segment & 0xffff, - (0 - 2 - 4 - ((pi->hfi->segment >> 8) & 0xff) - (pi->hfi->segment & 0xff)) & 0xff); - else // Use 02 record for addresses below 1 meg since more programmers know about the 02 instead of the 04 - fprintf(pi->hfi->fp, ":02000002%04X%02X\x0d\x0a", (pi->hfi->segment << 12) & 0xffff, - (0 - 2 - 2 - ((pi->hfi->segment << 4) & 0xf0)) & 0xff); - } - if((pi->hfi->count == 16) || ((address != (pi->hfi->linestart_addr + pi->hfi->count)) && (pi->hfi->count != 0))) - do_hex_line(pi->hfi); - if(pi->hfi->count == 0) - pi->hfi->linestart_addr = address; - pi->hfi->hex_line[pi->hfi->count++] = data & 0xff; - pi->hfi->hex_line[pi->hfi->count++] = (data >> 8) & 0xff; + if (hfi->segment != (address >> 16)) { + if (hfi->count != 0) + do_hex_line(hfi); + hfi->segment = address >> 16; + if (hfi->segment >= 16) /* Use 04 record for addresses above 1 meg since 02 can support max 1 meg */ + fprintf(hfi->fp, ":02000004%04X%02X\x0d\x0a", hfi->segment & 0xffff, + (0 - 2 - 4 - ((hfi->segment >> 8) & 0xff) - (hfi->segment & 0xff)) & 0xff); + else /* Use 02 record for addresses below 1 meg since more programmers know about the 02 instead of the 04 */ + fprintf(hfi->fp, ":02000002%04X%02X\x0d\x0a", (hfi->segment << 12) & 0xffff, + (0 - 2 - 2 - ((hfi->segment << 4) & 0xf0)) & 0xff); + } + if ((hfi->count == 16) || ((address != (hfi->linestart_addr + hfi->count)) && (hfi->count != 0))) + do_hex_line(hfi); + if (hfi->count == 0) + hfi->linestart_addr = address; + hfi->hex_line[hfi->count++] = data & 0xff; + hfi->hex_line[hfi->count++] = (data >> 8) & 0xff; - if(pi->coff_file != 0) - write_coff_program(pi, address, data); + if (pi->coff_file) + write_coff_program(pi, address, data); } -void do_hex_line(struct hex_file_info *hfi) +void +do_hex_line(struct hex_file_info *hfi) { int i; unsigned char checksum = 0; fprintf(hfi->fp, ":%02X%04X00", hfi->count, hfi->linestart_addr & 0xffff); checksum -= hfi->count + ((hfi->linestart_addr >> 8) & 0xff) + (hfi->linestart_addr & 0xff); - for(i = 0; i < hfi->count; i++) { + for (i = 0; i < hfi->count; i++) { fprintf(hfi->fp, "%02X", hfi->hex_line[i]); checksum -= hfi->hex_line[i]; } @@ -254,15 +263,16 @@ } -FILE *open_obj_file(struct prog_info *pi, char *filename) +FILE * +open_obj_file(struct prog_info *pi, const char *filename) { int i; FILE *fp; struct include_file *include_file; fp = fopen(filename, "wb"); - if(fp) { - i = pi->cseg_count * 9 + 26; + if (fp) { + i = pi->cseg->count * 9 + 26; fputc((i >> 24) & 0xff, fp); fputc((i >> 16) & 0xff, fp); fputc((i >> 8) & 0xff, fp); @@ -274,21 +284,22 @@ fputc(i & 0xff, fp); fputc(9, fp); i = 0; - for(include_file = pi->first_include_file; include_file; include_file = include_file->next) + for (include_file = pi->first_include_file; include_file; include_file = include_file->next) i++; fputc(i, fp); fprintf(fp, "AVR Object File"); fputc('\0', fp); } - return(fp); + return (fp); } -void close_obj_file(struct prog_info *pi, FILE *fp) +void +close_obj_file(struct prog_info *pi, FILE *fp) { struct include_file *include_file; - for(include_file = pi->first_include_file; include_file; include_file = include_file->next) { + for (include_file = pi->first_include_file; include_file; include_file = include_file->next) { fprintf(fp, "%s", include_file->name); fputc('\0', fp); } @@ -297,7 +308,8 @@ } -void write_obj_record(struct prog_info *pi, int address, int data) +void +write_obj_record(struct prog_info *pi, int address, int data) { fputc((address >> 16) & 0xff, pi->obj_file); fputc((address >> 8) & 0xff, pi->obj_file); @@ -307,7 +319,7 @@ fputc(pi->fi->include_file->num & 0xff, pi->obj_file); fputc((pi->fi->line_number >> 8) & 0xff, pi->obj_file); fputc(pi->fi->line_number & 0xff, pi->obj_file); - if(pi->macro_call) + if (pi->macro_call) fputc(1, pi->obj_file); else fputc(0, pi->obj_file); diff -Nru avra-1.3.0/src/macro.c avra-1.4.2+dfsg/src/macro.c --- avra-1.3.0/src/macro.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/macro.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, TObias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,14 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra - */ - -/* - * In append_type: added generic register names support - * Alexey Pavluchenko, 16.Nov.2005 + * www: https://github.com/Ro5bert/avra */ #include @@ -40,185 +35,181 @@ #include "avra.h" #include "device.h" +const int ML_DEFINED = 0x01; + /* Only Windows LIBC does support itoa, so we add this function for other systems here manually. Thank you Peter Hettkamp for your work. */ #ifndef WIN32 -char * itoa(int num, char *str, const int number_format) +char * +itoa(int num, char *str, const int number_format) { - int num1 = num; - int num_chars = 0; - int pos; - - while (num1>0) - { - num_chars++; - num1 /= number_format; - } - - if (num_chars == 0) num_chars = 1; - - str[num_chars] = 0; - - for (pos = num_chars-1; pos>=0; pos--) - { - int cur_char = num % number_format; - - if (cur_char < 10) /* Insert number */ - { - str[pos] = cur_char + '0'; - } - else - { - str[pos] = cur_char-10 + 'A'; - } - - num /= number_format; - } - return(str); + int num1 = num; + int num_chars = 0; + int pos; + + while (num1>0) { + num_chars++; + num1 /= number_format; + } + + if (num_chars == 0) num_chars = 1; + + str[num_chars] = 0; + + for (pos = num_chars-1; pos>=0; pos--) { + int cur_char = num % number_format; + + if (cur_char < 10) { /* Insert number */ + str[pos] = cur_char + '0'; + } else { + str[pos] = cur_char-10 + 'A'; + } + + num /= number_format; + } + return (str); } #endif -int read_macro(struct prog_info *pi, char *name) +int +read_macro(struct prog_info *pi, char *name) { int loopok; - int i; - int start; + int i; + int start; struct macro *macro; struct macro_line *macro_line; - struct macro_line **last_macro_line = NULL; + struct macro_line **last_macro_line = NULL; struct macro_label *macro_label; - if(pi->pass == PASS_1) { - if(!name) { + if (pi->pass == PASS_1) { + if (!name) { print_msg(pi, MSGTYPE_ERROR, "missing macro name"); - return(True); + return (True); } get_next_token(name, TERM_END); - for(i = 0; !IS_END_OR_COMMENT(name[i]); i++) { - if(!IS_LABEL(name[i])) { + for (i = 0; !IS_END_OR_COMMENT(name[i]); i++) { + if (!IS_LABEL(name[i])) { print_msg(pi, MSGTYPE_ERROR, "illegal characters used in macro name '%s'",name); - return(False); + return (False); } } macro = calloc(1, sizeof(struct macro)); - if(!macro) { + if (!macro) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } - if(pi->last_macro) + if (pi->last_macro) pi->last_macro->next = macro; else pi->first_macro = macro; pi->last_macro = macro; macro->name = malloc(strlen(name) + 1); - if(!macro->name) { + if (!macro->name) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } strcpy(macro->name, name); macro->include_file = pi->fi->include_file; macro->first_line_number = pi->fi->line_number; last_macro_line = ¯o->first_macro_line; - } - else { /* pi->pass == PASS_2 */ - if(pi->list_line && pi->list_on) { + } else { /* pi->pass == PASS_2 */ + if (pi->list_line && pi->list_on) { fprintf(pi->list_file, " %s\n", pi->list_line); pi->list_line = NULL; } - // reset macro label running numbers + /* reset macro label running numbers */ get_next_token(name, TERM_END); macro = get_macro(pi, name); if (!macro) { print_msg(pi, MSGTYPE_ERROR, "macro inconsistency in '%s'", name); - return(True); + return (True); } - for(macro_label = macro->first_label; macro_label; macro_label = macro_label->next) { + for (macro_label = macro->first_label; macro_label; macro_label = macro_label->next) { macro_label->running_number = 0; + macro_label->flags = 0; } } loopok = True; - while(loopok) { - if(fgets_new(pi,pi->fi->buff, LINEBUFFER_LENGTH, pi->fi->fp)) { + while (loopok) { + if (fgets_new(pi,pi->fi->buff, LINEBUFFER_LENGTH, pi->fi->fp)) { pi->fi->line_number++; i = 0; - while(IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i])) i++; - if(pi->fi->buff[i] == '.') { - i++; - if(!nocase_strncmp(&pi->fi->buff[i], "endm", 4)) - loopok = False; - if(!nocase_strncmp(&pi->fi->buff[i], "endmacro", 8)) - loopok = False; + while (IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i])) i++; + if (pi->fi->buff[i] == '.') { + i++; + if (!nocase_strncmp(&pi->fi->buff[i], "endm", 4)) + loopok = False; + if (!nocase_strncmp(&pi->fi->buff[i], "endmacro", 8)) + loopok = False; } - if(pi->pass == PASS_1) { - if(loopok) { + if (pi->pass == PASS_1) { + if (loopok) { i = 0; /* find start of line */ - while(IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i])) { - i++; + while (IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i])) { + i++; } start = i; /* find end of line */ - while(!IS_END_OR_COMMENT(pi->fi->buff[i]) && (IS_LABEL(pi->fi->buff[i]) || pi->fi->buff[i] == ':')) { - i++; + while (!IS_END_OR_COMMENT(pi->fi->buff[i]) && (IS_LABEL(pi->fi->buff[i]) || pi->fi->buff[i] == ':')) { + i++; } - if(pi->fi->buff[i-1] == ':' && (pi->fi->buff[i-2] == '%' - && (IS_HOR_SPACE(pi->fi->buff[i]) || IS_END_OR_COMMENT(pi->fi->buff[i])))) { - if(macro->first_label) { - for(macro_label = macro->first_label; macro_label->next; macro_label=macro_label->next){} - macro_label->next = calloc(1,sizeof(struct macro_label)); - macro_label = macro_label->next; - } - else { - macro_label = calloc(1,sizeof(struct macro_label)); - macro->first_label = macro_label; - } - macro_label->label = malloc(strlen(&pi->fi->buff[start])+1); - pi->fi->buff[i-1] = '\0'; - strcpy(macro_label->label, &pi->fi->buff[start]); - pi->fi->buff[i-1] = ':'; - macro_label->running_number = 0; + if (pi->fi->buff[i-1] == ':' && (pi->fi->buff[i-2] == '%' + && (IS_HOR_SPACE(pi->fi->buff[i]) || IS_END_OR_COMMENT(pi->fi->buff[i])))) { + if (macro->first_label) { + for (macro_label = macro->first_label; macro_label->next; macro_label=macro_label->next) {} + macro_label->next = calloc(1,sizeof(struct macro_label)); + macro_label = macro_label->next; + } else { + macro_label = calloc(1,sizeof(struct macro_label)); + macro->first_label = macro_label; + } + macro_label->label = malloc(strlen(&pi->fi->buff[start])+1); + pi->fi->buff[i-1] = '\0'; + strcpy(macro_label->label, &pi->fi->buff[start]); + pi->fi->buff[i-1] = ':'; + macro_label->running_number = 0; + macro_label->flags |= ML_DEFINED; } - + macro_line = calloc(1, sizeof(struct macro_line)); - if(!macro_line) { + if (!macro_line) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } *last_macro_line = macro_line; last_macro_line = ¯o_line->next; macro_line->line = malloc(strlen(pi->fi->buff) + 1); - if(!macro_line->line) { + if (!macro_line->line) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } strcpy(macro_line->line, &pi->fi->buff[start]); } - } - else if(pi->fi->buff && pi->list_file && pi->list_on) { - if(pi->fi->buff[i] == ';') + } else if (pi->fi->buff && pi->list_file && pi->list_on) { + if (pi->fi->buff[i] == ';') fprintf(pi->list_file, " %s\n", pi->fi->buff); else fprintf(pi->list_file, " %s\n", pi->fi->buff); } - } - else { - if(feof(pi->fi->fp)) { + } else { + if (feof(pi->fi->fp)) { print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDMACRO"); - return(True); - } - else { + return (True); + } else { perror(pi->fi->include_file->name); - return(False); + return (False); } } } - return(True); + return (True); } @@ -226,13 +217,14 @@ { struct macro *macro; - for(macro = pi->first_macro; macro; macro = macro->next) - if(!nocase_strcmp(macro->name, name)) - return(macro); - return(NULL); + for (macro = pi->first_macro; macro; macro = macro->next) + if (!nocase_strcmp(macro->name, name)) + return (macro); + return (NULL); } -void append_type(struct prog_info *pi, char *name, int c, char *value) +void +append_type(struct prog_info *pi, char *name, int c, char *value) { int p, l; struct def *def; @@ -240,24 +232,21 @@ p = strlen(name); name[p++] = '_'; - if(c == 0) - { + if (c == 0) { name[p++] = 'v'; name[p] = '\0'; return; } l = strlen(value); - if ((l==2 || l==3) && (tolower(value[0])=='r') && isdigit(value[1]) && (l==3?isdigit(value[2]):1) && (atoi(&value[1])<32)) - { + if ((l==2 || l==3) && (tolower(value[0])=='r') && isdigit(value[1]) && (l==3?isdigit(value[2]):1) && (atoi(&value[1])<32)) { itoa((c*8),&name[p],10); return; } - - for(def = pi->first_def; def; def = def->next) - if(!nocase_strcmp(def->name, value)) - { + + for (def = pi->first_def; def; def = def->next) + if (!nocase_strcmp(def->name, value)) { itoa((c*8),&name[p],10); return; } @@ -267,289 +256,283 @@ } -/********************************************************* - * This routine replaces the macro call with mnemonics. * - *********************************************************/ - -int expand_macro(struct prog_info *pi, struct macro *macro, char *rest_line) +/* Replace the macro call with mnemonics. */ +int +expand_macro(struct prog_info *pi, struct macro *macro, char *rest_line) { - int ok = True, macro_arg_count = 0, off, a, b = 0, c, i = 0, j = 0; - char *line = NULL; - char *temp; - char *macro_args[MAX_MACRO_ARGS]; - char tmp[7]; - char buff[LINEBUFFER_LENGTH]; - char arg = False; - char *nmn; //string buffer for 'n'ew 'm'acro 'n'ame - struct macro_line *old_macro_line; - struct macro_call *macro_call; - struct macro_label *macro_label; - - if(rest_line) { - //we reserve some extra space for extended macro parameters - line = malloc(strlen(rest_line) + 20); - if(!line) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - - /* exchange amca word 'src' with YH:YL and 'dst' with ZH:ZL */ - for(c = 0, a = strlen(rest_line); c < a; c++) { - switch (tolower(rest_line[c])) { - case 's': - if(IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 'r') && (rest_line[c+2] == 'c') && IS_SEPARATOR(rest_line[c+3])) { - strcpy(&line[b],"YH:YL"); - b += 5; - c += 2; - } - else { - line[b++] = rest_line[c]; - } - break; - case 'd': - if(IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 's') && (rest_line[c+2] == 't') && IS_SEPARATOR(rest_line[c+3])) { - strcpy(&line[b],"ZH:ZL"); - b += 5; - c += 2; - } - else { - line[b++] = rest_line[c]; - } - break; -// case ';': -// break; - default: - line[b++] = rest_line[c]; - } - } - strcpy(&line[b],"\n"); /* set CR/LF at the end of the line */ - - - /* here we split up the macro arguments into "macro_args" - * Extended macro code interpreter added by TW 2002 - */ - - temp = line; - /* test for advanced parameters */ - if( temp[0] == '[' ) { // there must be "[" " then "]", else it is garbage - if(!strchr(temp, ']')) { - print_msg(pi, MSGTYPE_ERROR, "found no closing ']'"); - return(False); - } - - // Okay now we are within the advanced code interpreter - - temp++; // = &temp[1]; // skip the first bracket - nmn = malloc(LINEBUFFER_LENGTH); - if(!nmn) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(nmn,macro->name); // create a new macro name buffer - c = 1; // byte counter - arg = True; // loop flag - - while(arg) { - while(IS_HOR_SPACE(temp[0])) { //skip leading spaces - temp++; // = &temp[1]; - } - off = 0; // pointer offset - do { - switch(temp[off]) { //test current character code - case ':': - temp[off] = '\0'; - if(off > 0) { - c++; - macro_args[macro_arg_count++] = temp; - } - else { - print_msg(pi, MSGTYPE_ERROR, "missing register before ':'",nmn); - return(False); - } - break; - case ']': - arg = False; - case ',': - a = off; - do temp[a--] = '\0'; while( IS_HOR_SPACE(temp[a]) ); - if(off > 0) { - macro_args[macro_arg_count++] = temp; - append_type(pi, nmn, c, temp); - c = 1; - } - else { - append_type(pi, nmn, 0, temp); - c = 1; - } - break; - - default: - off++; - } - } - while(temp[off] != '\0'); - - if(arg) temp = &temp[off+1]; - else break; - } - - macro = get_macro(pi,nmn); - if(macro == NULL) { - print_msg(pi, MSGTYPE_ERROR, "Macro %s is not defined !",nmn); - return(False); - } - free(nmn); - } - /* or else, we handle the macro as normal macro */ - else { - line = malloc(strlen(rest_line) + 1); - if(!line) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - strcpy(line, rest_line); - temp = line; - while(temp) { - macro_args[macro_arg_count++] = temp; - temp = get_next_token(temp, TERM_COMMA); - } - } - } - - if(pi->pass == PASS_1) { - macro_call = calloc(1, sizeof(struct macro_call)); - if(!macro_call) { - print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); - } - if(pi->last_macro_call) - pi->last_macro_call->next = macro_call; - else - pi->first_macro_call = macro_call; - - pi->last_macro_call = macro_call; - macro_call->line_number = pi->fi->line_number; - macro_call->include_file = pi->fi->include_file; - macro_call->macro = macro; - macro_call->prev_on_stack = pi->macro_call; - - if(macro_call->prev_on_stack) { - macro_call->nest_level = macro_call->prev_on_stack->nest_level + 1; - macro_call->prev_line_index = macro_call->prev_on_stack->line_index; - } - } - else { - for(macro_call = pi->first_macro_call; macro_call; macro_call = macro_call->next) { - if((macro_call->include_file->num == pi->fi->include_file->num) && (macro_call->line_number == pi->fi->line_number)) { - if(pi->macro_call) { - /* Find correct macro_call when using recursion and nesting */ - if(macro_call->prev_on_stack == pi->macro_call) - if((macro_call->nest_level == (pi->macro_call->nest_level + 1)) && (macro_call->prev_line_index == pi->macro_call->line_index)) - break; - } - else break; - } - } - if(pi->list_line && pi->list_on) { - fprintf(pi->list_file, "C:%06x + %s\n", pi->cseg_addr, pi->list_line); - pi->list_line = NULL; - } - } - - macro_call->line_index = 0; - pi->macro_call = macro_call; - old_macro_line = pi->macro_line; - - //printf("\nconvert macro: '%s'\n",macro->name); - - for(pi->macro_line = macro->first_macro_line; pi->macro_line && ok; pi->macro_line = pi->macro_line->next) { - macro_call->line_index++; - if(GET_ARG(pi->args, ARG_LISTMAC)) - pi->list_line = buff; - else - pi->list_line = NULL; - - /* here we change jumps/calls within macro that corresponds to macro labels. - Only in case there is an entry in macro_label list */ - - strcpy(buff,"\0"); - macro_label = get_macro_label(pi->macro_line->line,macro); - if(macro_label) { - /* test if the right macro label has been found */ - temp = strstr(pi->macro_line->line,macro_label->label); - c = strlen(macro_label->label); - if(temp[c] == ':') { /* it is a label definition */ - macro_label->running_number++; - strncpy(buff, macro_label->label, c - 1); - buff[c - 1] = 0; - i = strlen(buff) + 2; /* we set the process indeafter label */ - /* add running number to it */ - strcpy(&buff[c-1],itoa(macro_label->running_number, tmp, 10)); - strcat(buff, ":\0"); - } - else if(IS_HOR_SPACE(temp[c]) || IS_END_OR_COMMENT(temp[c])) { /* it is a jump to a macro defined label */ - strcpy(buff,pi->macro_line->line); - temp = strstr(buff, macro_label->label); - i = temp - buff + strlen(macro_label->label); - strncpy(temp, macro_label->label, c - 1); - strcpy(&temp[c-1], itoa(macro_label->running_number, tmp, 10)); - } - } - else { - i = 0; - } - - /* here we check every character of current line */ - for(j = i; pi->macro_line->line[i] != '\0'; i++) { - /* check for register place holders */ - if(pi->macro_line->line[i] == '@') { - i++; - if(!isdigit(pi->macro_line->line[i])) - print_msg(pi, MSGTYPE_ERROR, "@ must be followed by a number"); - else if((pi->macro_line->line[i] - '0') >= macro_arg_count) - print_msg(pi, MSGTYPE_ERROR, "Missing macro argument (for @%c)", pi->macro_line->line[i]); - else { - /* and replace them with given registers */ - strcat(&buff[j], macro_args[pi->macro_line->line[i] - '0']); - j += strlen(macro_args[pi->macro_line->line[i] - '0']); - } - } - else if (pi->macro_line->line[i] == ';') { - strncat(buff, "\n", 1); - break; - } - else { - strncat(buff, &pi->macro_line->line[i], 1); - } - } - - ok = parse_line(pi, buff); - if(ok) { - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) - fprintf(pi->list_file, " %s\n", pi->list_line); - if(pi->error_count >= pi->max_errors) { - print_msg(pi, MSGTYPE_MESSAGE, "Maximum error count reached. Exiting..."); - ok = False; - break; - } - } - } - - pi->macro_line = old_macro_line; - pi->macro_call = macro_call->prev_on_stack; - if(rest_line) - free(line); - return(ok); + int ok = True, macro_arg_count = 0, off, a, b = 0, c, i = 0, j = 0; + char *line = NULL; + char *temp; + char *macro_args[MAX_MACRO_ARGS]; + char tmp[7]; + char buff[LINEBUFFER_LENGTH]; + char arg = False; + char *nmn; /* string buffer for 'n'ew 'm'acro 'n'ame */ + struct macro_line *old_macro_line; + struct macro_call *macro_call; + struct macro_label *macro_label; + + if (rest_line) { + /* we reserve some extra space for extended macro parameters */ + line = malloc(strlen(rest_line) + 20); + if (!line) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + + /* exchange amca word 'src' with YH:YL and 'dst' with ZH:ZL */ + for (c = 0, a = strlen(rest_line); c < a; c++) { + switch (tolower(rest_line[c])) { + case 's': + if (IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 'r') && (rest_line[c+2] == 'c') && IS_SEPARATOR(rest_line[c+3])) { + strcpy(&line[b],"YH:YL"); + b += 5; + c += 2; + } else { + line[b++] = rest_line[c]; + } + break; + case 'd': + if (IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 's') && (rest_line[c+2] == 't') && IS_SEPARATOR(rest_line[c+3])) { + strcpy(&line[b],"ZH:ZL"); + b += 5; + c += 2; + } else { + line[b++] = rest_line[c]; + } + break; + default: + line[b++] = rest_line[c]; + } + } + strcpy(&line[b],"\n"); /* set CR/LF at the end of the line */ + + + /* here we split up the macro arguments into "macro_args" + * Extended macro code interpreter added by TW 2002 */ + + temp = line; + /* test for advanced parameters */ + if (temp[0] == '[') { /* there must be "[" " then "]", else it is garbage */ + if (!strchr(temp, ']')) { + print_msg(pi, MSGTYPE_ERROR, "found no closing ']'"); + return (False); + } + + /* Okay now we are within the advanced code interpreter */ + + temp++; /* skip the first bracket */ + nmn = malloc(LINEBUFFER_LENGTH); + if (!nmn) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(nmn,macro->name); /* create a new macro name buffer */ + c = 1; /* byte counter */ + arg = True; /* loop flag */ + + while (arg) { + while (IS_HOR_SPACE(temp[0])) { /* skip leading spaces */ + temp++; + } + off = 0; /* pointer offset */ + do { + switch (temp[off]) { /* test current character code */ + case ':': + temp[off] = '\0'; + if (off > 0) { + c++; + macro_args[macro_arg_count++] = temp; + } else { + print_msg(pi, MSGTYPE_ERROR, "missing register before ':'",nmn); + return (False); + } + break; + case ']': + arg = False; + case ',': + a = off; + do temp[a--] = '\0'; + while (IS_HOR_SPACE(temp[a])); + if (off > 0) { + macro_args[macro_arg_count++] = temp; + append_type(pi, nmn, c, temp); + c = 1; + } else { + append_type(pi, nmn, 0, temp); + c = 1; + } + break; + + default: + off++; + } + } while (temp[off] != '\0'); + + if (arg) temp = &temp[off+1]; + else break; + } + + macro = get_macro(pi,nmn); + if (macro == NULL) { + print_msg(pi, MSGTYPE_ERROR, "Macro %s is not defined !",nmn); + return (False); + } + free(nmn); + } + /* or else, we handle the macro as normal macro */ + else { + line = malloc(strlen(rest_line) + 1); + if (!line) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + strcpy(line, rest_line); + temp = line; + while (temp) { + macro_args[macro_arg_count++] = temp; + temp = get_next_token(temp, TERM_COMMA); + } + } + } + + if (pi->pass == PASS_1) { + macro_call = calloc(1, sizeof(struct macro_call)); + if (!macro_call) { + print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); + return (False); + } + if (pi->last_macro_call) + pi->last_macro_call->next = macro_call; + else + pi->first_macro_call = macro_call; + + pi->last_macro_call = macro_call; + macro_call->line_number = pi->fi->line_number; + macro_call->include_file = pi->fi->include_file; + macro_call->macro = macro; + macro_call->prev_on_stack = pi->macro_call; + + if (macro_call->prev_on_stack) { + macro_call->nest_level = macro_call->prev_on_stack->nest_level + 1; + macro_call->prev_line_index = macro_call->prev_on_stack->line_index; + } + } else { + for (macro_call = pi->first_macro_call; macro_call; macro_call = macro_call->next) { + if ((macro_call->include_file->num == pi->fi->include_file->num) && (macro_call->line_number == pi->fi->line_number)) { + if (pi->macro_call) { + /* Find correct macro_call when using recursion and nesting */ + if (macro_call->prev_on_stack == pi->macro_call) + if ((macro_call->nest_level == (pi->macro_call->nest_level + 1)) && (macro_call->prev_line_index == pi->macro_call->line_index)) + break; + } else break; + } + } + if (pi->list_line && pi->list_on) { + fprintf(pi->list_file, "%c:%06lx + %s\n", + pi->cseg->ident, pi->cseg->addr, pi->list_line); + pi->list_line = NULL; + } + } + + macro_call->line_index = 0; + pi->macro_call = macro_call; + old_macro_line = pi->macro_line; + + for (macro_label = macro->first_label; macro_label; macro_label = macro_label->next) { + /* mark all local flags as not yet defined */ + macro_label->flags &= ~ML_DEFINED; + } + + for (pi->macro_line = macro->first_macro_line; pi->macro_line && ok; pi->macro_line = pi->macro_line->next) { + macro_call->line_index++; + if (GET_ARG_I(pi->args, ARG_LISTMAC)) + pi->list_line = buff; + else + pi->list_line = NULL; + + /* here we change jumps/calls within macro that corresponds to macro labels. + * Only in case there is an entry in macro_label list */ + + strcpy(buff,"\0"); + macro_label = get_macro_label(pi->macro_line->line,macro); + if (macro_label) { + /* test if the right macro label has been found */ + temp = strstr(pi->macro_line->line,macro_label->label); + c = strlen(macro_label->label); + if (temp[c] == ':') { /* it is a label definition */ + macro_label->running_number++; + macro_label->flags |= ML_DEFINED; + strncpy(buff, macro_label->label, c - 1); + buff[c - 1] = 0; + i = strlen(buff) + 2; /* we set the process indeafter label */ + /* add running number to it */ + strcpy(&buff[c-1],itoa(macro_label->running_number, tmp, 10)); + strcat(buff, ":\0"); + } else if (IS_HOR_SPACE(temp[c]) || IS_END_OR_COMMENT(temp[c])) { /* it is a jump to a macro defined label */ + int target_number = macro_label->running_number; + if ((macro_label->flags & ML_DEFINED) == 0) + /* Allow forward reference if label is not yet defined */ + target_number++; + strcpy(buff,pi->macro_line->line); + temp = strstr(buff, macro_label->label); + i = temp - buff + strlen(macro_label->label); + strncpy(temp, macro_label->label, c - 1); + strcpy(&temp[c-1], itoa(target_number, tmp, 10)); + } + } else { + i = 0; + } + + /* here we check every character of current line */ + for (j = i; pi->macro_line->line[i] != '\0'; i++) { + /* check for register place holders */ + if (pi->macro_line->line[i] == '@') { + i++; + if (!isdigit(pi->macro_line->line[i])) + print_msg(pi, MSGTYPE_ERROR, "@ must be followed by a number"); + else if ((pi->macro_line->line[i] - '0') >= macro_arg_count) + print_msg(pi, MSGTYPE_ERROR, "Missing macro argument (for @%c)", pi->macro_line->line[i]); + else { + /* and replace them with given registers */ + strcat(&buff[j], macro_args[pi->macro_line->line[i] - '0']); + j += strlen(macro_args[pi->macro_line->line[i] - '0']); + } + } else if (pi->macro_line->line[i] == ';') { + strncat(buff, "\n", 1); + break; + } else { + strncat(buff, &pi->macro_line->line[i], 1); + } + } + + ok = parse_line(pi, buff); + if (ok) { + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) + fprintf(pi->list_file, " %s\n", pi->list_line); + if (pi->error_count >= pi->max_errors) { + print_msg(pi, MSGTYPE_MESSAGE, "Maximum error count reached. Exiting..."); + ok = False; + break; + } + } + } + + pi->macro_line = old_macro_line; + pi->macro_call = macro_call->prev_on_stack; + if (rest_line) + free(line); + return (ok); } struct macro_label *get_macro_label(char *line, struct macro *macro) { char *temp ; - struct macro_label *macro_label; - - for(macro_label = macro->first_label; macro_label; macro_label = macro_label->next) { - temp = strstr(line,macro_label->label); - if(temp) { + struct macro_label *macro_label; + + for (macro_label = macro->first_label; macro_label; macro_label = macro_label->next) { + temp = strstr(line,macro_label->label); + if (temp) { return macro_label; } } diff -Nru avra-1.3.0/src/Makefile.am avra-1.4.2+dfsg/src/Makefile.am --- avra-1.3.0/src/Makefile.am 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -bin_PROGRAMS = avra -avra_SOURCES = avra.c args.c coff.c device.c directiv.c expr.c file.c macro.c map.c mnemonic.c parser.c stdextra.c diff -Nru avra-1.3.0/src/Makefile.in avra-1.4.2+dfsg/src/Makefile.in --- avra-1.3.0/src/Makefile.in 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,523 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = . -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -bin_PROGRAMS = avra$(EXEEXT) -subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ - ChangeLog INSTALL NEWS TODO depcomp install-sh missing -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno configure.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(bin_PROGRAMS) -am_avra_OBJECTS = avra.$(OBJEXT) args.$(OBJEXT) coff.$(OBJEXT) \ - device.$(OBJEXT) directiv.$(OBJEXT) expr.$(OBJEXT) \ - file.$(OBJEXT) macro.$(OBJEXT) map.$(OBJEXT) \ - mnemonic.$(OBJEXT) parser.$(OBJEXT) stdextra.$(OBJEXT) -avra_OBJECTS = $(am_avra_OBJECTS) -avra_LDADD = $(LDADD) -DEFAULT_INCLUDES = -I. -I$(srcdir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(avra_SOURCES) -DIST_SOURCES = $(avra_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_STRIP = @ac_ct_STRIP@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -avra_SOURCES = avra.c args.c coff.c device.c directiv.c expr.c file.c macro.c map.c mnemonic.c parser.c stdextra.c -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .o .obj -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ - cd $(srcdir) && $(AUTOMAKE) --gnu \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -clean-binPROGRAMS: - -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) -avra$(EXEEXT): $(avra_OBJECTS) $(avra_DEPENDENCIES) - @rm -f avra$(EXEEXT) - $(LINK) $(avra_LDFLAGS) $(avra_OBJECTS) $(avra_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/args.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avra.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/device.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/directiv.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expr.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/macro.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mnemonic.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdextra.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -uninstall-info-am: - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - mkdir $(distdir) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: install-binPROGRAMS - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS uninstall-info-am - -.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ - clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ - dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-compile distclean-generic distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-man install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru avra-1.3.0/src/makefiles/BSDmakefile avra-1.4.2+dfsg/src/makefiles/BSDmakefile --- avra-1.3.0/src/makefiles/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/src/makefiles/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,18 @@ +DEBUG_FLAGS = -g -Wall +SRCS = avra.c device.c parser.c expr.c mnemonic.c directiv.c macro.c file.c map.c coff.c args.c stdextra.c +PROG = avra +NO_MAN = yes + +args.o: args.c misc.h args.h +avra.o: avra.c misc.h args.h avra.h device.h +device.o: device.c misc.h avra.h device.h +directiv.o: directiv.c misc.h args.h avra.h device.h +expr.o: expr.c misc.h avra.h +file.o: file.c misc.h avra.h +macro.o: macro.c misc.h args.h avra.h +mnemonic.o: mnemonic.c misc.h avra.h device.h +parser.o: parser.c misc.h avra.h +stdextra.o: stdextra.c misc.h +coff.o: coff.c coff.h + +.include diff -Nru avra-1.3.0/src/makefiles/Makefile.lcc avra-1.4.2+dfsg/src/makefiles/Makefile.lcc --- avra-1.3.0/src/makefiles/Makefile.lcc 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/makefiles/Makefile.lcc 2020-07-18 23:19:00.000000000 +0000 @@ -1,53 +1,53 @@ -CC = lcc.exe -LD = lcclnk.exe -OBJ = avra.o args.o stdextra.o device.o directiv.o expr.o file.o map.o mnemonic.o parser.o coff.o macro.o -LINKOBJ = avra.o args.o stdextra.o device.o directiv.o expr.o file.o map.o mnemonic.o parser.o coff.o macro.o -BIN = avra.exe -CFLAGS = -O -errout=lcc.err -LDFLAGS = -s - -all: avra.exe - - -clean: - rm -f $(OBJ) $(BIN) - -$(BIN): $(LINKOBJ) - $(LD) $(LINKOBJ) -o "avra.exe" $(LDFLAGS) - -avra.o: avra.c - $(CC) avra.c -o avra.o $(CFLAGS) - -args.o: args.c - $(CC) args.c -o args.o $(CFLAGS) - -stdextra.o: stdextra.c - $(CC) stdextra.c -o stdextra.o $(CFLAGS) - -device.o: device.c - $(CC) device.c -o device.o $(CFLAGS) - -directiv.o: directiv.c - $(CC) directiv.c -o directiv.o $(CFLAGS) - -expr.o: expr.c - $(CC) expr.c -o expr.o $(CFLAGS) - -file.o: file.c - $(CC) file.c -o file.o $(CFLAGS) - -map.o: map.c - $(CC) map.c -o map.o $(CFLAGS) - -mnemonic.o: mnemonic.c - $(CC) mnemonic.c -o mnemonic.o $(CFLAGS) - -parser.o: parser.c - $(CC) parser.c -o parser.o $(CFLAGS) - -coff.o: coff.c - $(CC) coff.c -o coff.o $(CFLAGS) - -macro.o: macro.c - $(CC) macro.c -o macro.o $(CFLAGS) - +CC = lcc.exe +LD = lcclnk.exe +OBJ = avra.o args.o stdextra.o device.o directiv.o expr.o file.o map.o mnemonic.o parser.o coff.o macro.o +LINKOBJ = avra.o args.o stdextra.o device.o directiv.o expr.o file.o map.o mnemonic.o parser.o coff.o macro.o +BIN = avra.exe +CFLAGS = -O -errout=lcc.err +LDFLAGS = -s + +all: avra.exe + + +clean: + rm -f $(OBJ) $(BIN) + +$(BIN): $(LINKOBJ) + $(LD) $(LINKOBJ) -o "avra.exe" $(LDFLAGS) + +avra.o: avra.c + $(CC) avra.c -o avra.o $(CFLAGS) + +args.o: args.c + $(CC) args.c -o args.o $(CFLAGS) + +stdextra.o: stdextra.c + $(CC) stdextra.c -o stdextra.o $(CFLAGS) + +device.o: device.c + $(CC) device.c -o device.o $(CFLAGS) + +directiv.o: directiv.c + $(CC) directiv.c -o directiv.o $(CFLAGS) + +expr.o: expr.c + $(CC) expr.c -o expr.o $(CFLAGS) + +file.o: file.c + $(CC) file.c -o file.o $(CFLAGS) + +map.o: map.c + $(CC) map.c -o map.o $(CFLAGS) + +mnemonic.o: mnemonic.c + $(CC) mnemonic.c -o mnemonic.o $(CFLAGS) + +parser.o: parser.c + $(CC) parser.c -o parser.o $(CFLAGS) + +coff.o: coff.c + $(CC) coff.c -o coff.o $(CFLAGS) + +macro.o: macro.c + $(CC) macro.c -o macro.o $(CFLAGS) + diff -Nru avra-1.3.0/src/makefiles/Makefile.linux avra-1.4.2+dfsg/src/makefiles/Makefile.linux --- avra-1.3.0/src/makefiles/Makefile.linux 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/makefiles/Makefile.linux 2020-07-18 23:19:00.000000000 +0000 @@ -1,41 +1,29 @@ -#******************************************************************** -# Makefile for gcc -#******************************************************************** - -CC = gcc -LD = gcc -static -CFLAGS = -Wall -O3 -LDFLAGS = -s - -SOURCES = avra.c device.c parser.c expr.c mnemonic.c directiv.c macro.c file.c map.c coff.c +CC ?= gcc +CFLAGS ?= -Wall -O3 +CFLAGS += $(CDEFS) +LDFLAGS ?= -s + +SOURCES = avra.c \ + device.c \ + parser.c \ + expr.c \ + mnemonic.c \ + directiv.c \ + macro.c \ + file.c \ + map.c \ + coff.c \ + args.c \ + stdextra.c OBJECTS = $(SOURCES:.c=.o) -OBJ_ALL = $(OBJECTS) args.o stdextra.o - -DISTFILES = *.c *.h README ChangeLog Makefile.* COPYING avra.1 avra.txt strip-headers TODO - -ARCHFILES = $(DISTFILES) - -BINFILES = avra README ChangeLog COPYING avra.1 avra.txt - -VERSION = 1.1.0 - -#******************************************************************** - -all: avra - -install: avra - cp avra /usr/local/bin - cp avra.1 /usr/local/man/man1 - chmod +r /usr/local/man/man1/avra.1 +avra: $(OBJECTS) + $(CC) -o $@ $(OBJECTS) $(LDFLAGS) clean: rm -f avra *.o *.p *~ -avra: $(OBJ_ALL) - $(LD) -o avra $(OBJ_ALL) $(LDFLAGS) - args.o: args.c misc.h args.h avra.o: avra.c misc.h args.h avra.h device.h device.o: device.c misc.h avra.h device.h @@ -47,28 +35,3 @@ parser.o: parser.c misc.h avra.h stdextra.o: stdextra.c misc.h coff.o: coff.c coff.h - -avra.txt: avra.1 - groff -man -Tascii avra.1 | ./strip-headers | col -bx > avra.txt - -#******************************************************************** - -disk: archive - mcopy -ovm avra.tar.gz a:avra.tgz - -archive: avra.tar.gz - -avra.tar.gz: $(ARCHFILES) - tar cvf avra.tar $(ARCHFILES) - gzip -9 -f avra.tar - -dist: avra-$(VERSION).tar.gz - -avra-$(VERSION).tar.gz: $(DISTFILES) - mkdir avra-$(VERSION) - cp $(DISTFILES) avra-$(VERSION)/ - tar cvf avra-$(VERSION).tar avra-$(VERSION)/* - gzip -9 -f avra-$(VERSION).tar - rm -r avra-$(VERSION) - -#******************************************************************** diff -Nru avra-1.3.0/src/makefiles/Makefile.os2 avra-1.4.2+dfsg/src/makefiles/Makefile.os2 --- avra-1.3.0/src/makefiles/Makefile.os2 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/makefiles/Makefile.os2 2020-07-18 23:19:00.000000000 +0000 @@ -1,47 +1,47 @@ -# $Id: Makefile.os2,v 1.1 2001/10/02 00:38:39 jonah Exp $ -#******************************************************************** -# Makefile for IBM VisualAge C++ -#******************************************************************** - -CC = icc -LD = icc - -WFLAGS = /Wall /Wppt- /Wuni- /Wext- /Wtrd- /Wppc- -CFLAGS = /C /Fi /Gd- /Gm /Q /Ss $(WFLAGS) -LDFLAGS = /NOLOGO /NOE /MAP - -SOURCES = avra.c device.c parser.c expr.c mnemonic.c directiv.c macro.c file.c map.c - -OBJECTS = $(SOURCES:.c=.obj) - -OBJ_ALL = $(OBJECTS) args.obj stdextra.obj - -#******************************************************************** - -all: avra.exe - -install: avra.exe - copy avra.exe c:\bin\ - -clean: - del *.obj - del avra.exe - -avra.exe: $(OBJ_ALL) - $(LD) $(OBJ_ALL) $(LDFLAGS) - -args.obj: args.c misc.h args.h -avra.obj: avra.c misc.h args.h avra.h device.h -device.obj: device.c misc.h avra.h device.h -directiv.obj: directiv.c misc.h args.h avra.h device.h -expr.obj: expr.c misc.h avra.h -file.obj: file.c misc.h avra.h -macro.obj: macro.c misc.h args.h avra.h -mnemonic.obj: mnemonic.c misc.h avra.h device.h -parser.obj: parser.c misc.h avra.h -stdextra.obj: stdextra.c misc.h - -#******************************************************************** - - -#******************************************************************** +# $Id: Makefile.os2,v 1.1 2001/10/02 00:38:39 jonah Exp $ +#******************************************************************** +# Makefile for IBM VisualAge C++ +#******************************************************************** + +CC = icc +LD = icc + +WFLAGS = /Wall /Wppt- /Wuni- /Wext- /Wtrd- /Wppc- +CFLAGS = /C /Fi /Gd- /Gm /Q /Ss $(WFLAGS) +LDFLAGS = /NOLOGO /NOE /MAP + +SOURCES = avra.c device.c parser.c expr.c mnemonic.c directiv.c macro.c file.c map.c + +OBJECTS = $(SOURCES:.c=.obj) + +OBJ_ALL = $(OBJECTS) args.obj stdextra.obj + +#******************************************************************** + +all: avra.exe + +install: avra.exe + copy avra.exe c:\bin\ + +clean: + del *.obj + del avra.exe + +avra.exe: $(OBJ_ALL) + $(LD) $(OBJ_ALL) $(LDFLAGS) + +args.obj: args.c misc.h args.h +avra.obj: avra.c misc.h args.h avra.h device.h +device.obj: device.c misc.h avra.h device.h +directiv.obj: directiv.c misc.h args.h avra.h device.h +expr.obj: expr.c misc.h avra.h +file.obj: file.c misc.h avra.h +macro.obj: macro.c misc.h args.h avra.h +mnemonic.obj: mnemonic.c misc.h avra.h device.h +parser.obj: parser.c misc.h avra.h +stdextra.obj: stdextra.c misc.h + +#******************************************************************** + + +#******************************************************************** diff -Nru avra-1.3.0/src/makefiles/Makefile.osx avra-1.4.2+dfsg/src/makefiles/Makefile.osx --- avra-1.3.0/src/makefiles/Makefile.osx 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/makefiles/Makefile.osx 2020-07-18 23:19:00.000000000 +0000 @@ -1,5 +1,4 @@ CC=gcc -ARCH=-arch i386 -arch x86_64 -arch ppc SOURCE=args.c \ avra.c \ coff.c \ @@ -14,5 +13,5 @@ stdextra.c all: - $(CC) $(ARCH) -o avra $(SOURCE) + $(CC) $(CDEFS) -o avra $(SOURCE) diff -Nru avra-1.3.0/src/map.c avra-1.4.2+dfsg/src/map.c --- avra-1.3.0/src/map.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/map.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra + * www: https://github.com/Ro5bert/avra */ #include @@ -32,29 +32,30 @@ char *Space(char *n); -void write_map_file(struct prog_info *pi) +void +write_map_file(struct prog_info *pi) { FILE *fp; struct label *label; char Filename[200]; - if (!pi->map_on) { - return; - } + if (!pi->map_on) { + return; + } - strcpy(Filename, GET_ARG(pi->args, ARG_MAPFILE)); + strcpy(Filename, GET_ARG_P(pi->args, ARG_MAPFILE)); fp = fopen(Filename,"w"); - if( fp == NULL ) { + if (fp == NULL) { fprintf(stderr,"Error: cannot create map file\n"); return; } - for(label = pi->first_constant; label; label = label->next) + for (label = pi->first_constant; label; label = label->next) fprintf(fp,"%s%sC\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value); - for(label = pi->first_variable; label; label = label->next) + for (label = pi->first_variable; label; label = label->next) fprintf(fp,"%s%sV\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value); - for(label = pi->first_label; label; label = label->next) + for (label = pi->first_label; label; label = label->next) fprintf(fp,"%s%sL\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value); fprintf(fp,"\n"); @@ -62,13 +63,14 @@ return; } -char *Space(char *n) +char * +Space(char *n) { int i; i = strlen(n); - if( i < 1) return "\t\t\t"; - if( i < 8 ) return "\t\t"; + if (i < 1) return "\t\t\t"; + if (i < 8) return "\t\t"; return "\t"; } diff -Nru avra-1.3.0/src/misc.h avra-1.4.2+dfsg/src/misc.h --- avra-1.3.0/src/misc.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/misc.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,19 +1,36 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2003 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * - * Misc stuff + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * + * Authors of AVRA can be reached at: + * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com + * www: https://github.com/Ro5bert/avra */ enum boolean {False = 0, True}; -enum filetype -{ - AVRSTUDIO = 0, - GENERIC, - INTEL, - MOTOROLA +enum filetype { + AVRSTUDIO = 0, + GENERIC, + INTEL, + MOTOROLA }; diff -Nru avra-1.3.0/src/mnemonic.c avra-1.4.2+dfsg/src/mnemonic.c --- avra-1.3.0/src/mnemonic.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/mnemonic.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,793 +1,845 @@ -/*********************************************************************** - * - * avra - Assembler for the Atmel AVR microcontroller series - * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * - * Authors of avra can be reached at: - * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra - */ - -#include -#include -#include -#include - -#include "misc.h" -#include "avra.h" -#include "device.h" - -#define MAX_MNEMONIC_LEN 8 // Maximum mnemonic length - -enum { - MNEMONIC_NOP = 0, // 0000 0000 0000 0000 - MNEMONIC_SEC, // 1001 0100 0000 1000 - MNEMONIC_CLC, // 1001 0100 1000 1000 - MNEMONIC_SEN, // 1001 0100 0010 1000 - MNEMONIC_CLN, // 1001 0100 1010 1000 - MNEMONIC_SEZ, // 1001 0100 0001 1000 - MNEMONIC_CLZ, // 1001 0100 1001 1000 - MNEMONIC_SEI, // 1001 0100 0111 1000 - MNEMONIC_CLI, // 1001 0100 1111 1000 - MNEMONIC_SES, // 1001 0100 0100 1000 - MNEMONIC_CLS, // 1001 0100 1100 1000 - MNEMONIC_SEV, // 1001 0100 0011 1000 - MNEMONIC_CLV, // 1001 0100 1011 1000 - MNEMONIC_SET, // 1001 0100 0110 1000 - MNEMONIC_CLT, // 1001 0100 1110 1000 - MNEMONIC_SEH, // 1001 0100 0101 1000 - MNEMONIC_CLH, // 1001 0100 1101 1000 - MNEMONIC_SLEEP, // 1001 0101 1000 1000 - MNEMONIC_WDR, // 1001 0101 1010 1000 - MNEMONIC_IJMP, // 1001 0100 0000 1001 - MNEMONIC_EIJMP, // 1001 0100 0001 1001 - MNEMONIC_ICALL, // 1001 0101 0000 1001 - MNEMONIC_EICALL, // 1001 0101 0001 1001 - MNEMONIC_RET, // 1001 0101 0000 1000 - MNEMONIC_RETI, // 1001 0101 0001 1000 - MNEMONIC_SPM, // 1001 0101 1110 1000 - MNEMONIC_ESPM, // 1001 0101 1111 1000 - MNEMONIC_BREAK, // 1001 0101 1001 1000 - MNEMONIC_LPM, // 1001 0101 1100 1000 - MNEMONIC_ELPM, // 1001 0101 1101 1000 - MNEMONIC_BSET, // s 1001 0100 0sss 1000 - MNEMONIC_BCLR, // s 1001 0100 1sss 1000 - MNEMONIC_SER, // Rd 1110 1111 dddd 1111 - MNEMONIC_COM, // Rd 1001 010d dddd 0000 - MNEMONIC_NEG, // Rd 1001 010d dddd 0001 - MNEMONIC_INC, // Rd 1001 010d dddd 0011 - MNEMONIC_DEC, // Rd 1001 010d dddd 1010 - MNEMONIC_LSR, // Rd 1001 010d dddd 0110 - MNEMONIC_ROR, // Rd 1001 010d dddd 0111 - MNEMONIC_ASR, // Rd 1001 010d dddd 0101 - MNEMONIC_SWAP, // Rd 1001 010d dddd 0010 - MNEMONIC_PUSH, // Rr 1001 001r rrrr 1111 - MNEMONIC_POP, // Rd 1001 000d dddd 1111 - MNEMONIC_TST, // Rd 0010 00dd dddd dddd - MNEMONIC_CLR, // Rd 0010 01dd dddd dddd - MNEMONIC_LSL, // Rd 0000 11dd dddd dddd - MNEMONIC_ROL, // Rd 0001 11dd dddd dddd - MNEMONIC_BREQ, // k 1111 00kk kkkk k001 - MNEMONIC_BRNE, // k 1111 01kk kkkk k001 - MNEMONIC_BRCS, // k 1111 00kk kkkk k000 - MNEMONIC_BRCC, // k 1111 01kk kkkk k000 - MNEMONIC_BRSH, // k 1111 01kk kkkk k000 - MNEMONIC_BRLO, // k 1111 00kk kkkk k000 - MNEMONIC_BRMI, // k 1111 00kk kkkk k010 - MNEMONIC_BRPL, // k 1111 01kk kkkk k010 - MNEMONIC_BRGE, // k 1111 01kk kkkk k100 - MNEMONIC_BRLT, // k 1111 00kk kkkk k100 - MNEMONIC_BRHS, // k 1111 00kk kkkk k101 - MNEMONIC_BRHC, // k 1111 01kk kkkk k101 - MNEMONIC_BRTS, // k 1111 00kk kkkk k110 - MNEMONIC_BRTC, // k 1111 01kk kkkk k110 - MNEMONIC_BRVS, // k 1111 00kk kkkk k011 - MNEMONIC_BRVC, // k 1111 01kk kkkk k011 - MNEMONIC_BRIE, // k 1111 00kk kkkk k111 - MNEMONIC_BRID, // k 1111 01kk kkkk k111 - MNEMONIC_RJMP, // k 1100 kkkk kkkk kkkk - MNEMONIC_RCALL, // k 1101 kkkk kkkk kkkk - MNEMONIC_JMP, // k 1001 010k kkkk 110k + 16k - MNEMONIC_CALL, // k 1001 010k kkkk 111k + 16k - MNEMONIC_BRBS, // s, k 1111 00kk kkkk ksss - MNEMONIC_BRBC, // s, k 1111 01kk kkkk ksss - MNEMONIC_ADD, // Rd, Rr 0000 11rd dddd rrrr - MNEMONIC_ADC, // Rd, Rr 0001 11rd dddd rrrr - MNEMONIC_SUB, // Rd, Rr 0001 10rd dddd rrrr - MNEMONIC_SBC, // Rd, Rr 0000 10rd dddd rrrr - MNEMONIC_AND, // Rd, Rr 0010 00rd dddd rrrr - MNEMONIC_OR, // Rd, Rr 0010 10rd dddd rrrr - MNEMONIC_EOR, // Rd, Rr 0010 01rd dddd rrrr - MNEMONIC_CP, // Rd, Rr 0001 01rd dddd rrrr - MNEMONIC_CPC, // Rd, Rr 0000 01rd dddd rrrr - MNEMONIC_CPSE, // Rd, Rr 0001 00rd dddd rrrr - MNEMONIC_MOV, // Rd, Rr 0010 11rd dddd rrrr - MNEMONIC_MUL, // Rd, Rr 1001 11rd dddd rrrr - MNEMONIC_MOVW, // Rd, Rr 0000 0001 dddd rrrr - MNEMONIC_MULS, // Rd, Rr 0000 0010 dddd rrrr - MNEMONIC_MULSU, // Rd, Rr 0000 0011 0ddd 0rrr - MNEMONIC_FMUL, // Rd, Rr 0000 0011 0ddd 1rrr - MNEMONIC_FMULS, // Rd, Rr 0000 0011 1ddd 0rrr - MNEMONIC_FMULSU, // Rd, Rr 0000 0011 1ddd 1rrr - MNEMONIC_ADIW, // Rd, K 1001 0110 KKdd KKKK - MNEMONIC_SBIW, // Rd, K 1001 0111 KKdd KKKK - MNEMONIC_SUBI, // Rd, K 0101 KKKK dddd KKKK - MNEMONIC_SBCI, // Rd, K 0100 KKKK dddd KKKK - MNEMONIC_ANDI, // Rd, K 0111 KKKK dddd KKKK - MNEMONIC_ORI, // Rd, K 0110 KKKK dddd KKKK - MNEMONIC_SBR, // Rd, K 0110 KKKK dddd KKKK - MNEMONIC_CPI, // Rd, K 0011 KKKK dddd KKKK - MNEMONIC_LDI, // Rd, K 1110 KKKK dddd KKKK - MNEMONIC_CBR, // Rd, K 0111 KKKK dddd KKKK ~K - MNEMONIC_SBRC, // Rr, b 1111 110r rrrr 0bbb - MNEMONIC_SBRS, // Rr, b 1111 111r rrrr 0bbb - MNEMONIC_BST, // Rr, b 1111 101d dddd 0bbb - MNEMONIC_BLD, // Rd, b 1111 100d dddd 0bbb - MNEMONIC_IN, // Rd, P 1011 0PPd dddd PPPP - MNEMONIC_OUT, // P, Rr 1011 1PPr rrrr PPPP - MNEMONIC_SBIC, // P, b 1001 1001 PPPP Pbbb - MNEMONIC_SBIS, // P, b 1001 1011 PPPP Pbbb - MNEMONIC_SBI, // P, b 1001 1010 PPPP Pbbb - MNEMONIC_CBI, // P, b 1001 1000 PPPP Pbbb - MNEMONIC_LDS, // Rd, k 1001 000d dddd 0000 + 16k - MNEMONIC_STS, // k, Rr 1001 001d dddd 0000 + 16k - MNEMONIC_LD, // Rd, __ dummy - MNEMONIC_ST, // __, Rr dummy - MNEMONIC_LDD, // Rd, _+q dummy - MNEMONIC_STD, // _+q, Rr dummy - MNEMONIC_COUNT, - MNEMONIC_LPM_Z, // Rd, Z 1001 000d dddd 0100 - MNEMONIC_LPM_ZP, // Rd, Z+ 1001 000d dddd 0101 - MNEMONIC_ELPM_Z, // Rd, Z 1001 000d dddd 0110 - MNEMONIC_ELPM_ZP, // Rd, Z+ 1001 000d dddd 0111 - MNEMONIC_LD_X, // Rd, X 1001 000d dddd 1100 - MNEMONIC_LD_XP, // Rd, X+ 1001 000d dddd 1101 - MNEMONIC_LD_MX, // Rd, -X 1001 000d dddd 1110 - MNEMONIC_LD_Y, // Rd, Y 1000 000d dddd 1000 - MNEMONIC_LD_YP, // Rd, Y+ 1001 000d dddd 1001 - MNEMONIC_LD_MY, // Rd, -Y 1001 000d dddd 1010 - MNEMONIC_LD_Z, // Rd, Z 1000 000d dddd 0000 - MNEMONIC_LD_ZP, // Rd, Z+ 1001 000d dddd 0001 - MNEMONIC_LD_MZ, // Rd, -Z 1001 000d dddd 0010 - MNEMONIC_ST_X, // X, Rr 1001 001d dddd 1100 - MNEMONIC_ST_XP, // X+, Rr 1001 001d dddd 1101 - MNEMONIC_ST_MX, // -X, Rr 1001 001d dddd 1110 - MNEMONIC_ST_Y, // Y, Rr 1000 001d dddd 1000 - MNEMONIC_ST_YP, // Y+, Rr 1001 001d dddd 1001 - MNEMONIC_ST_MY, // -Y, Rr 1001 001d dddd 1010 - MNEMONIC_ST_Z, // Z, Rr 1000 001d dddd 0000 - MNEMONIC_ST_ZP, // Z+, Rr 1001 001d dddd 0001 - MNEMONIC_ST_MZ, // -Z, Rr 1001 001d dddd 0010 - MNEMONIC_LDD_Y, // Rd, Y+q 10q0 qq0d dddd 1qqq - MNEMONIC_LDD_Z, // Rd, Z+q 10q0 qq0d dddd 0qqq - MNEMONIC_STD_Y, // Y+q, Rr 10q0 qq1r rrrr 1qqq - MNEMONIC_STD_Z, // Z+q, Rr 10q0 qq1r rrrr 0qqq - MNEMONIC_END -}; - -struct instruction { - char *mnemonic; - int opcode; - int flag; /* Device flags meaning the instruction is not - supported */ -}; - -struct instruction instruction_list[] = { - {"nop", 0x0000, 0}, - {"sec", 0x9408, 0}, - {"clc", 0x9488, 0}, - {"sen", 0x9428, 0}, - {"cln", 0x94a8, 0}, - {"sez", 0x9418, 0}, - {"clz", 0x9498, 0}, - {"sei", 0x9478, 0}, - {"cli", 0x94f8, 0}, - {"ses", 0x9448, 0}, - {"cls", 0x94c8, 0}, - {"sev", 0x9438, 0}, - {"clv", 0x94b8, 0}, - {"set", 0x9468, 0}, - {"clt", 0x94e8, 0}, - {"seh", 0x9458, 0}, - {"clh", 0x94d8, 0}, - {"sleep", 0x9588, 0}, - {"wdr", 0x95a8, 0}, - {"ijmp", 0x9409, DF_TINY1X}, - {"eijmp", 0x9419, DF_NO_EIJMP}, - {"icall", 0x9509, DF_TINY1X}, - {"eicall",0x9519, DF_NO_EICALL}, - {"ret", 0x9508, 0}, - {"reti", 0x9518, 0}, - {"spm", 0x95e8, DF_NO_SPM}, - {"espm", 0x95f8, DF_NO_ESPM}, - {"break", 0x9598, DF_NO_BREAK}, - {"lpm", 0x95c8, DF_NO_LPM}, - {"elpm", 0x95d8, DF_NO_ELPM}, - {"bset", 0x9408, 0}, - {"bclr", 0x9488, 0}, - {"ser", 0xef0f, 0}, - {"com", 0x9400, 0}, - {"neg", 0x9401, 0}, - {"inc", 0x9403, 0}, - {"dec", 0x940a, 0}, - {"lsr", 0x9406, 0}, - {"ror", 0x9407, 0}, - {"asr", 0x9405, 0}, - {"swap", 0x9402, 0}, - {"push", 0x920f, DF_TINY1X}, - {"pop", 0x900f, DF_TINY1X}, - {"tst", 0x2000, 0}, - {"clr", 0x2400, 0}, - {"lsl", 0x0c00, 0}, - {"rol", 0x1c00, 0}, - {"breq", 0xf001, 0}, - {"brne", 0xf401, 0}, - {"brcs", 0xf000, 0}, - {"brcc", 0xf400, 0}, - {"brsh", 0xf400, 0}, - {"brlo", 0xf000, 0}, - {"brmi", 0xf002, 0}, - {"brpl", 0xf402, 0}, - {"brge", 0xf404, 0}, - {"brlt", 0xf004, 0}, - {"brhs", 0xf005, 0}, - {"brhc", 0xf405, 0}, - {"brts", 0xf006, 0}, - {"brtc", 0xf406, 0}, - {"brvs", 0xf003, 0}, - {"brvc", 0xf403, 0}, - {"brie", 0xf007, 0}, - {"brid", 0xf407, 0}, - {"rjmp", 0xc000, 0}, - {"rcall", 0xd000, 0}, - {"jmp", 0x940c, DF_NO_JMP}, - {"call", 0x940e, DF_NO_JMP}, - {"brbs", 0xf000, 0}, - {"brbc", 0xf400, 0}, - {"add", 0x0c00, 0}, - {"adc", 0x1c00, 0}, - {"sub", 0x1800, 0}, - {"sbc", 0x0800, 0}, - {"and", 0x2000, 0}, - {"or", 0x2800, 0}, - {"eor", 0x2400, 0}, - {"cp", 0x1400, 0}, - {"cpc", 0x0400, 0}, - {"cpse", 0x1000, 0}, - {"mov", 0x2c00, 0}, - {"mul", 0x9c00, DF_NO_MUL}, - {"movw", 0x0100, DF_NO_MOVW}, - {"muls", 0x0200, DF_NO_MUL}, - {"mulsu", 0x0300, DF_NO_MUL}, - {"fmul", 0x0308, DF_NO_MUL}, - {"fmuls", 0x0380, DF_NO_MUL}, - {"fmulsu",0x0388, DF_NO_MUL}, - {"adiw", 0x9600, DF_TINY1X}, - {"sbiw", 0x9700, DF_TINY1X}, - {"subi", 0x5000, 0}, - {"sbci", 0x4000, 0}, - {"andi", 0x7000, 0}, - {"ori", 0x6000, 0}, - {"sbr", 0x6000, 0}, - {"cpi", 0x3000, 0}, - {"ldi", 0xe000, 0}, - {"cbr", 0x7000, 0}, - {"sbrc", 0xfc00, 0}, - {"sbrs", 0xfe00, 0}, - {"bst", 0xfa00, 0}, - {"bld", 0xf800, 0}, - {"in", 0xb000, 0}, - {"out", 0xb800, 0}, - {"sbic", 0x9900, 0}, - {"sbis", 0x9b00, 0}, - {"sbi", 0x9a00, 0}, - {"cbi", 0x9800, 0}, - {"lds", 0x9000, DF_TINY1X}, - {"sts", 0x9200, DF_TINY1X}, - {"ld", 0, 0}, - {"st", 0, 0}, - {"ldd", 0, DF_TINY1X}, - {"std", 0, DF_TINY1X}, - {"count", 0, 0}, - {"lpm", 0x9004, DF_NO_LPM|DF_NO_LPM_X}, - {"lpm", 0x9005, DF_NO_LPM|DF_NO_LPM_X}, - {"elpm", 0x9006, DF_NO_ELPM|DF_NO_ELPM_X}, - {"elpm", 0x9007, DF_NO_ELPM|DF_NO_ELPM_X}, - {"ld", 0x900c, DF_NO_XREG}, - {"ld", 0x900d, DF_NO_XREG}, - {"ld", 0x900e, DF_NO_XREG}, - {"ld", 0x8008, DF_NO_YREG}, - {"ld", 0x9009, DF_NO_YREG}, - {"ld", 0x900a, DF_NO_YREG}, - {"ld", 0x8000, 0}, - {"ld", 0x9001, DF_TINY1X}, - {"ld", 0x9002, DF_TINY1X}, - {"st", 0x920c, DF_NO_XREG}, - {"st", 0x920d, DF_NO_XREG}, - {"st", 0x920e, DF_NO_XREG}, - {"st", 0x8208, DF_NO_YREG}, - {"st", 0x9209, DF_NO_YREG}, - {"st", 0x920a, DF_NO_YREG}, - {"st", 0x8200, 0}, - {"st", 0x9201, DF_TINY1X}, - {"st", 0x9202, DF_TINY1X}, - {"ldd", 0x8008, DF_TINY1X}, - {"ldd", 0x8000, DF_TINY1X}, - {"std", 0x8208, DF_TINY1X}, - {"std", 0x8200, DF_TINY1X}, - {"end", 0, 0} - }; - - -/* We try to parse the command name. Is it a assembler mnemonic or anything else ? - * If so, it may be a macro. -*/ - -int parse_mnemonic(struct prog_info *pi) -{ - int mnemonic; - int i; - int opcode = 0; - int opcode2 = 0; - int instruction_long = False; - char *operand1; - char *operand2; - struct macro *macro; - char temp[MAX_MNEMONIC_LEN + 1]; - - operand1 = get_next_token(pi->fi->scratch, TERM_SPACE); // we get the first word on line - mnemonic = get_mnemonic_type(my_strlwr(pi->fi->scratch)); - if(mnemonic == -1) { // if -1 this must be a macro name - macro = get_macro(pi, pi->fi->scratch); // and so, we try to get the corresponding macro struct. - if(macro) { - return(expand_macro(pi, macro, operand1)); // we expand the macro - } else { // if we cant find a name, this is a unknown word. - print_msg(pi, MSGTYPE_ERROR, "Unknown mnemonic/macro: %s", pi->fi->scratch); - return(True); - } - } - if(pi->pass == PASS_2) { - if(mnemonic <= MNEMONIC_BREAK) { - if(operand1) { - print_msg(pi, MSGTYPE_WARNING, "Garbage after instruction %s: %s", instruction_list[mnemonic].mnemonic, operand1); } - opcode = 0; // No operand - } else if(mnemonic <= MNEMONIC_ELPM) { - if(operand1) { - operand2 = get_next_token(operand1, TERM_COMMA); - if(!operand2) { - print_msg(pi, MSGTYPE_ERROR, "%s needs a second operand", instruction_list[mnemonic].mnemonic); - return(True); } - get_next_token(operand2, TERM_END); - i = get_register(pi, operand1); - opcode = i << 4; - i = get_indirect(pi, operand2); - if(i == 6) { // Means Z - if(mnemonic == MNEMONIC_LPM) - mnemonic = MNEMONIC_LPM_Z; - else if(mnemonic == MNEMONIC_ELPM) - mnemonic = MNEMONIC_ELPM_Z; - } else if(i == 7) { // Means Z+ - if(mnemonic == MNEMONIC_LPM) - mnemonic = MNEMONIC_LPM_ZP; - else if(mnemonic == MNEMONIC_ELPM) - mnemonic = MNEMONIC_ELPM_ZP; - } else { - print_msg(pi, MSGTYPE_ERROR, "Unsupported operand: %s", operand2); - return(True); - } - } else - opcode = 0; - } else { - if(!operand1) { - print_msg(pi, MSGTYPE_ERROR, "%s needs an operand", instruction_list[mnemonic].mnemonic); - return(True); - } - operand2 = get_next_token(operand1, TERM_COMMA); - if(mnemonic >= MNEMONIC_BRBS) { - if(!operand2) { - print_msg(pi, MSGTYPE_ERROR, "%s needs a second operand", instruction_list[mnemonic].mnemonic); - return(True); - } - get_next_token(operand2, TERM_END); - } - if(mnemonic <= MNEMONIC_BCLR) { - if(!get_bitnum(pi, operand1, &i)) - return(False); - opcode = i << 4; - } else if(mnemonic <= MNEMONIC_ROL) { - i = get_register(pi, operand1); - if((mnemonic == MNEMONIC_SER) && (i < 16)) { - print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); - i &= 0x0f; - } - opcode = i << 4; - if(mnemonic >= MNEMONIC_TST) - opcode |= ((i & 0x10) << 5) | (i & 0x0f); - } else if(mnemonic <= MNEMONIC_RCALL) { - if(!get_expr(pi, operand1, &i)) - return(False); - i -= pi->cseg_addr + 1; - if(mnemonic <= MNEMONIC_BRID) { - if((i < -64) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "Branch out of range (-64 <= k <= 63)"); - opcode = (i & 0x7f) << 3; - } else { - if(((i < -2048) || (i > 2047)) && (pi->device->flash_size != 4096)) - print_msg(pi, MSGTYPE_ERROR, "Relative address out of range (-2048 <= k <= 2047)"); - opcode = i & 0x0fff; - } - } else if(mnemonic <= MNEMONIC_CALL) { - if(!get_expr(pi, operand1, &i)) - return(False); - if((i < 0) || (i > 4194303)) - print_msg(pi, MSGTYPE_ERROR, "Address out of range (0 <= k <= 4194303)"); - opcode = ((i & 0x3e0000) >> 13) | ((i & 0x010000) >> 16); - opcode2 = i & 0xffff; - instruction_long = True; - } else if(mnemonic <= MNEMONIC_BRBC) { - if(!get_bitnum(pi, operand1, &i)) - return(False); - opcode = i; - if(!get_expr(pi, operand2, &i)) - return(False); - i -= pi->cseg_addr + 1; - if((i < -64) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "Branch out of range (-64 <= k <= 63)"); - opcode |= (i & 0x7f) << 3; - } else if(mnemonic <= MNEMONIC_MUL) { - i = get_register(pi, operand1); - opcode = i << 4; - i = get_register(pi, operand2); - opcode |= ((i & 0x10) << 5) | (i & 0x0f); - } else if(mnemonic <= MNEMONIC_MOVW) { - i = get_register(pi, operand1); - if((i % 2) == 1) - print_msg(pi, MSGTYPE_ERROR, "%s must use a even numbered register for Rd", instruction_list[mnemonic].mnemonic); - opcode = (i / 2) << 4; - i = get_register(pi, operand2); - if((i % 2) == 1) - print_msg(pi, MSGTYPE_ERROR, "%s must use a even numbered register for Rr", instruction_list[mnemonic].mnemonic); - opcode |= i / 2; - } else if(mnemonic <= MNEMONIC_MULS) { - i = get_register(pi, operand1); - if(i < 16) - print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); - opcode = (i & 0x0f) << 4; - i = get_register(pi, operand2); - if(i < 16) - print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); - opcode |= (i & 0x0f); - } else if(mnemonic <= MNEMONIC_FMULSU) { - i = get_register(pi, operand1); - if((i < 16) || (i >= 24)) - print_msg(pi, MSGTYPE_ERROR, "%s can only use registers (r16 - r23)", instruction_list[mnemonic].mnemonic); - opcode = (i & 0x07) << 4; - i = get_register(pi, operand2); - if((i < 16) || (i >= 24)) - print_msg(pi, MSGTYPE_ERROR, "%s can only use registers (r16 - r23)", instruction_list[mnemonic].mnemonic); - opcode |= (i & 0x07); - } else if(mnemonic <= MNEMONIC_SBIW) { - i = get_register(pi, operand1); - if(!((i == 24) || (i == 26) || (i == 28) || (i == 30))) - print_msg(pi, MSGTYPE_ERROR, "%s can only use registers R24, R26, R28 or R30", instruction_list[mnemonic].mnemonic); - opcode = ((i - 24) / 2) << 4; - if(!get_expr(pi, operand2, &i)) - return(False); - if((i < 0) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "Constant out of range (0 <= k <= 63)"); - opcode |= ((i & 0x30) << 2) | (i & 0x0f); - } else if(mnemonic <= MNEMONIC_CBR) { - i = get_register(pi, operand1); - if(i < 16) - print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); - opcode = (i & 0x0f) << 4; - if(!get_expr(pi, operand2, &i)) - return(False); - if((i < -128) || (i > 255)) - print_msg(pi, MSGTYPE_WARNING, "Constant out of range (-128 <= k <= 255). Will be masked"); - if(mnemonic == MNEMONIC_CBR) - i = ~i; - opcode |= ((i & 0xf0) << 4) | (i & 0x0f); - } else if(mnemonic <= MNEMONIC_BLD) { - i = get_register(pi, operand1); - opcode = i << 4; - if(!get_bitnum(pi, operand2, &i)) - return(False); - opcode |= i; - } else if(mnemonic == MNEMONIC_IN) { - i = get_register(pi, operand1); - opcode = i << 4; - if(!get_expr(pi, operand2, &i)) - return(False); - if((i < 0) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 63)"); - opcode |= ((i & 0x30) << 5) | (i & 0x0f); - } else if(mnemonic == MNEMONIC_OUT) { - if(!get_expr(pi, operand1, &i)) - return(False); - if((i < 0) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 63)"); - opcode = ((i & 0x30) << 5) | (i & 0x0f); - i = get_register(pi, operand2); - opcode |= i << 4; - } else if(mnemonic <= MNEMONIC_CBI) { - if(!get_expr(pi, operand1, &i)) - return(False); - if((i < 0) || (i > 31)) - print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 31)"); - opcode = i << 3; - if(!get_bitnum(pi, operand2, &i)) - return(False); - opcode |= i; - } else if(mnemonic == MNEMONIC_LDS) { - i = get_register(pi, operand1); - opcode = i << 4; - if(!get_expr(pi, operand2, &i)) - return(False); - if((i < 0) || (i > 65535)) - print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); - opcode2 = i; - instruction_long = True; - } else if(mnemonic == MNEMONIC_STS) { - if(!get_expr(pi, operand1, &i)) - return(False); - if((i < 0) || (i > 65535)) - print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); - opcode2 = i; - i = get_register(pi, operand2); - opcode = i << 4; - instruction_long = True; - } else if(mnemonic == MNEMONIC_LD) { - i = get_register(pi, operand1); - opcode = i << 4; - mnemonic = MNEMONIC_LD_X + get_indirect(pi, operand2); - } else if(mnemonic == MNEMONIC_ST) { - mnemonic = MNEMONIC_ST_X + get_indirect(pi, operand1); - i = get_register(pi, operand2); - opcode = i << 4; - } else if(mnemonic == MNEMONIC_LDD) { - i = get_register(pi, operand1); - opcode = i << 4; - if(tolower(operand2[0]) == 'z') - mnemonic = MNEMONIC_LDD_Z; - else if(tolower(operand2[0]) == 'y') - mnemonic = MNEMONIC_LDD_Y; - else - print_msg(pi, MSGTYPE_ERROR, "Garbage in second operand (%s)", operand2); - i = 1; - while((operand2[i] != '\0') && (operand2[i] != '+')) i++; - if(operand2[i] == '\0') { - print_msg(pi, MSGTYPE_ERROR, "Garbage in second operand (%s)", operand2); - return(False); - } - if(!get_expr(pi, &operand2[i + 1], &i)) - return(False); - if((i < 0) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "Displacement out of range (0 <= q <= 63)"); - opcode |= ((i & 0x20) << 8) | ((i & 0x18) << 7) | (i & 0x07); - } else if(mnemonic == MNEMONIC_STD) { - if(tolower(operand1[0]) == 'z') - mnemonic = MNEMONIC_STD_Z; - else if(tolower(operand1[0]) == 'y') - mnemonic = MNEMONIC_STD_Y; - else - print_msg(pi, MSGTYPE_ERROR, "Garbage in first operand (%s)", operand1); - i = 1; - while((operand1[i] != '\0') && (operand1[i] != '+')) i++; - if(operand1[i] == '\0') { - print_msg(pi, MSGTYPE_ERROR, "Garbage in first operand (%s)", operand1); - return(False); - } - if(!get_expr(pi, &operand1[i + 1], &i)) - return(False); - if((i < 0) || (i > 63)) - print_msg(pi, MSGTYPE_ERROR, "Displacement out of range (0 <= q <= 63)"); - opcode = ((i & 0x20) << 8) | ((i & 0x18) << 7) | (i & 0x07); - i = get_register(pi, operand2); - opcode |= i << 4; - } else - print_msg(pi, MSGTYPE_ERROR, "Shit! Missing opcode check [%d]...", mnemonic); - } - if (pi->device->flag & instruction_list[mnemonic].flag) { - strncpy(temp, instruction_list[mnemonic].mnemonic, MAX_MNEMONIC_LEN); - print_msg(pi, MSGTYPE_ERROR, "%s instruction is not supported on %s", - my_strupr(temp), pi->device->name); - } - opcode |= instruction_list[mnemonic].opcode; - if(pi->list_on && pi->list_line) { - if(instruction_long) - fprintf(pi->list_file, "C:%06x %04x %04x %s\n", pi->cseg_addr, opcode, opcode2, pi->list_line); - else - fprintf(pi->list_file, "C:%06x %04x %s\n", pi->cseg_addr, opcode, pi->list_line); - pi->list_line = NULL; - } - if(pi->hfi) { - write_prog_word(pi, pi->cseg_addr, opcode); - if(instruction_long) - write_prog_word(pi, pi->cseg_addr + 1, opcode2); - } - if(instruction_long) - pi->cseg_addr += 2; - else - pi->cseg_addr++; - } else { // Pass 1 - if((mnemonic == MNEMONIC_JMP) || (mnemonic == MNEMONIC_CALL) - || (mnemonic == MNEMONIC_LDS) || (mnemonic == MNEMONIC_STS)) { - pi->cseg_addr += 2; - pi->cseg_count += 2; - } else { - pi->cseg_addr++; - pi->cseg_count++; - } - } - return(True); -} - - -int get_mnemonic_type(char *mnemonic) -{ - int i; - - for(i = 0; i < MNEMONIC_COUNT; i++) { - if(!strcmp(mnemonic, instruction_list[i].mnemonic)) { - return(i); - } - } - return(-1); -} - - -int get_register(struct prog_info *pi, char *data) -{ - char *second_reg; - int reg = 0; - struct def *def; - - // Check for any occurence of r1:r0 pairs, and if so skip to second register - second_reg = strchr(data, ':'); - if(second_reg != NULL) - data = second_reg + 1; - - for(def = pi->first_def; def; def = def->next) - if(!nocase_strcmp(def->name, data)) - { - reg = def->reg; - return(reg); - } - if((tolower(data[0]) == 'r') && isdigit(data[1])) { - reg = atoi(&data[1]); - if(reg > 31) - print_msg(pi, MSGTYPE_ERROR, "R%d is not a valid register", reg); - } - else - print_msg(pi, MSGTYPE_ERROR, "No register associated with %s", data); - return(reg); -} - - -int get_bitnum(struct prog_info *pi, char *data, int *ret) -{ - if(!get_expr(pi, data, ret)) - return(False); - if((*ret < 0) || (*ret > 7)) { - print_msg(pi, MSGTYPE_ERROR, "Operand out of range (0 <= s <= 7)"); - return(False); - } - return(True); -} - - -int get_indirect(struct prog_info *pi, char *operand) -{ - int i = 1; - - switch(tolower(operand[0])) { - case '-': - while(IS_HOR_SPACE(operand[i])) i++; - if(operand[i + 1] != '\0') - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - switch(tolower(operand[i])) { - case 'x': - if (pi->device->flag & DF_NO_XREG) - print_msg(pi, MSGTYPE_ERROR, "X register is not supported on %s", pi->device->name); - return(2); - case 'y': - if (pi->device->flag & DF_NO_YREG) - print_msg(pi, MSGTYPE_ERROR, "Y register is not supported on %s", pi->device->name); - return(5); - case 'z': - return(8); - default: - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - return(0); - } - case 'x': - if (pi->device->flag & DF_NO_XREG) - print_msg(pi, MSGTYPE_ERROR, "X register is not supported on %s", pi->device->name); - while(IS_HOR_SPACE(operand[i])) i++; - if(operand[i] == '+') { - if(operand[i + 1] != '\0') - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - return(1); - } - else if(operand[i] == '\0') - return(0); - else - print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); - return(0); - case 'y': - if (pi->device->flag & DF_NO_YREG) - print_msg(pi, MSGTYPE_ERROR, "Y register is not supported on %s", pi->device->name); - while(IS_HOR_SPACE(operand[i])) i++; - if(operand[i] == '+') { - if(operand[i + 1] != '\0') - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - return(4); - } - else if(operand[i] == '\0') - return(3); - else - print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); - return(0); - case 'z': - while(IS_HOR_SPACE(operand[i])) i++; - if(operand[i] == '+') { - if(operand[i + 1] != '\0') - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - return(7); - } - else if(operand[i] == '\0') - return(6); - else - print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); - return(0); - default: - print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); - } - return(0); -} - -/* Return 1 if instruction name is supported by the current device, - 0 if unsupported, -1 if it is invalid */ -int is_supported(struct prog_info *pi, char *name) { - char temp[MAX_MNEMONIC_LEN+1]; - int mnemonic; - - strncpy(temp,name,MAX_MNEMONIC_LEN); - mnemonic = get_mnemonic_type(my_strlwr(temp)); - if (mnemonic == -1) return -1; - if (pi->device->flag & instruction_list[mnemonic].flag) return 0; - return 1; -} - -int count_supported_instructions(int flags) -{ - int i = 0, count = 0; - while(i < MNEMONIC_END) { - if((i < MNEMONIC_LD) || (i > MNEMONIC_COUNT)) - if(!(flags & instruction_list[i].flag)) - count++; - i++; - } - return(count); -} - -/* end of mnemonic.c */ - +/*********************************************************************** + * + * AVRA - Assembler for the Atmel AVR microcontroller series + * + * Copyright (C) 1998-2020 The AVRA Authors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * + * Authors of AVRA can be reached at: + * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com + * www: https://github.com/Ro5bert/avra + */ + +#include +#include +#include +#include + +#include "misc.h" +#include "avra.h" +#include "device.h" + +#define MAX_MNEMONIC_LEN 8 /* Maximum mnemonic length */ + +enum { + MNEMONIC_NOP = 0, /* 0000 0000 0000 0000 */ + MNEMONIC_SEC, /* 1001 0100 0000 1000 */ + MNEMONIC_CLC, /* 1001 0100 1000 1000 */ + MNEMONIC_SEN, /* 1001 0100 0010 1000 */ + MNEMONIC_CLN, /* 1001 0100 1010 1000 */ + MNEMONIC_SEZ, /* 1001 0100 0001 1000 */ + MNEMONIC_CLZ, /* 1001 0100 1001 1000 */ + MNEMONIC_SEI, /* 1001 0100 0111 1000 */ + MNEMONIC_CLI, /* 1001 0100 1111 1000 */ + MNEMONIC_SES, /* 1001 0100 0100 1000 */ + MNEMONIC_CLS, /* 1001 0100 1100 1000 */ + MNEMONIC_SEV, /* 1001 0100 0011 1000 */ + MNEMONIC_CLV, /* 1001 0100 1011 1000 */ + MNEMONIC_SET, /* 1001 0100 0110 1000 */ + MNEMONIC_CLT, /* 1001 0100 1110 1000 */ + MNEMONIC_SEH, /* 1001 0100 0101 1000 */ + MNEMONIC_CLH, /* 1001 0100 1101 1000 */ + MNEMONIC_SLEEP, /* 1001 0101 1000 1000 */ + MNEMONIC_WDR, /* 1001 0101 1010 1000 */ + MNEMONIC_IJMP, /* 1001 0100 0000 1001 */ + MNEMONIC_EIJMP, /* 1001 0100 0001 1001 */ + MNEMONIC_ICALL, /* 1001 0101 0000 1001 */ + MNEMONIC_EICALL, /* 1001 0101 0001 1001 */ + MNEMONIC_RET, /* 1001 0101 0000 1000 */ + MNEMONIC_RETI, /* 1001 0101 0001 1000 */ + MNEMONIC_SPM, /* 1001 0101 1110 1000 */ + MNEMONIC_ESPM, /* 1001 0101 1111 1000 */ + MNEMONIC_BREAK, /* 1001 0101 1001 1000 */ + MNEMONIC_LPM, /* 1001 0101 1100 1000 */ + MNEMONIC_ELPM, /* 1001 0101 1101 1000 */ + MNEMONIC_BSET, /* s 1001 0100 0sss 1000 */ + MNEMONIC_BCLR, /* s 1001 0100 1sss 1000 */ + MNEMONIC_SER, /* Rd 1110 1111 dddd 1111 */ + MNEMONIC_COM, /* Rd 1001 010d dddd 0000 */ + MNEMONIC_NEG, /* Rd 1001 010d dddd 0001 */ + MNEMONIC_INC, /* Rd 1001 010d dddd 0011 */ + MNEMONIC_DEC, /* Rd 1001 010d dddd 1010 */ + MNEMONIC_LSR, /* Rd 1001 010d dddd 0110 */ + MNEMONIC_ROR, /* Rd 1001 010d dddd 0111 */ + MNEMONIC_ASR, /* Rd 1001 010d dddd 0101 */ + MNEMONIC_SWAP, /* Rd 1001 010d dddd 0010 */ + MNEMONIC_PUSH, /* Rr 1001 001r rrrr 1111 */ + MNEMONIC_POP, /* Rd 1001 000d dddd 1111 */ + MNEMONIC_TST, /* Rd 0010 00dd dddd dddd */ + MNEMONIC_CLR, /* Rd 0010 01dd dddd dddd */ + MNEMONIC_LSL, /* Rd 0000 11dd dddd dddd */ + MNEMONIC_ROL, /* Rd 0001 11dd dddd dddd */ + MNEMONIC_BREQ, /* k 1111 00kk kkkk k001 */ + MNEMONIC_BRNE, /* k 1111 01kk kkkk k001 */ + MNEMONIC_BRCS, /* k 1111 00kk kkkk k000 */ + MNEMONIC_BRCC, /* k 1111 01kk kkkk k000 */ + MNEMONIC_BRSH, /* k 1111 01kk kkkk k000 */ + MNEMONIC_BRLO, /* k 1111 00kk kkkk k000 */ + MNEMONIC_BRMI, /* k 1111 00kk kkkk k010 */ + MNEMONIC_BRPL, /* k 1111 01kk kkkk k010 */ + MNEMONIC_BRGE, /* k 1111 01kk kkkk k100 */ + MNEMONIC_BRLT, /* k 1111 00kk kkkk k100 */ + MNEMONIC_BRHS, /* k 1111 00kk kkkk k101 */ + MNEMONIC_BRHC, /* k 1111 01kk kkkk k101 */ + MNEMONIC_BRTS, /* k 1111 00kk kkkk k110 */ + MNEMONIC_BRTC, /* k 1111 01kk kkkk k110 */ + MNEMONIC_BRVS, /* k 1111 00kk kkkk k011 */ + MNEMONIC_BRVC, /* k 1111 01kk kkkk k011 */ + MNEMONIC_BRIE, /* k 1111 00kk kkkk k111 */ + MNEMONIC_BRID, /* k 1111 01kk kkkk k111 */ + MNEMONIC_RJMP, /* k 1100 kkkk kkkk kkkk */ + MNEMONIC_RCALL, /* k 1101 kkkk kkkk kkkk */ + MNEMONIC_JMP, /* k 1001 010k kkkk 110k + 16k */ + MNEMONIC_CALL, /* k 1001 010k kkkk 111k + 16k */ + MNEMONIC_BRBS, /* s, k 1111 00kk kkkk ksss */ + MNEMONIC_BRBC, /* s, k 1111 01kk kkkk ksss */ + MNEMONIC_ADD, /* Rd, Rr 0000 11rd dddd rrrr */ + MNEMONIC_ADC, /* Rd, Rr 0001 11rd dddd rrrr */ + MNEMONIC_SUB, /* Rd, Rr 0001 10rd dddd rrrr */ + MNEMONIC_SBC, /* Rd, Rr 0000 10rd dddd rrrr */ + MNEMONIC_AND, /* Rd, Rr 0010 00rd dddd rrrr */ + MNEMONIC_OR, /* Rd, Rr 0010 10rd dddd rrrr */ + MNEMONIC_EOR, /* Rd, Rr 0010 01rd dddd rrrr */ + MNEMONIC_CP, /* Rd, Rr 0001 01rd dddd rrrr */ + MNEMONIC_CPC, /* Rd, Rr 0000 01rd dddd rrrr */ + MNEMONIC_CPSE, /* Rd, Rr 0001 00rd dddd rrrr */ + MNEMONIC_MOV, /* Rd, Rr 0010 11rd dddd rrrr */ + MNEMONIC_MUL, /* Rd, Rr 1001 11rd dddd rrrr */ + MNEMONIC_MOVW, /* Rd, Rr 0000 0001 dddd rrrr */ + MNEMONIC_MULS, /* Rd, Rr 0000 0010 dddd rrrr */ + MNEMONIC_MULSU, /* Rd, Rr 0000 0011 0ddd 0rrr */ + MNEMONIC_FMUL, /* Rd, Rr 0000 0011 0ddd 1rrr */ + MNEMONIC_FMULS, /* Rd, Rr 0000 0011 1ddd 0rrr */ + MNEMONIC_FMULSU, /* Rd, Rr 0000 0011 1ddd 1rrr */ + MNEMONIC_ADIW, /* Rd, K 1001 0110 KKdd KKKK */ + MNEMONIC_SBIW, /* Rd, K 1001 0111 KKdd KKKK */ + MNEMONIC_SUBI, /* Rd, K 0101 KKKK dddd KKKK */ + MNEMONIC_SBCI, /* Rd, K 0100 KKKK dddd KKKK */ + MNEMONIC_ANDI, /* Rd, K 0111 KKKK dddd KKKK */ + MNEMONIC_ORI, /* Rd, K 0110 KKKK dddd KKKK */ + MNEMONIC_SBR, /* Rd, K 0110 KKKK dddd KKKK */ + MNEMONIC_CPI, /* Rd, K 0011 KKKK dddd KKKK */ + MNEMONIC_LDI, /* Rd, K 1110 KKKK dddd KKKK */ + MNEMONIC_CBR, /* Rd, K 0111 KKKK dddd KKKK ~K */ + MNEMONIC_SBRC, /* Rr, b 1111 110r rrrr 0bbb */ + MNEMONIC_SBRS, /* Rr, b 1111 111r rrrr 0bbb */ + MNEMONIC_BST, /* Rr, b 1111 101d dddd 0bbb */ + MNEMONIC_BLD, /* Rd, b 1111 100d dddd 0bbb */ + MNEMONIC_IN, /* Rd, P 1011 0PPd dddd PPPP */ + MNEMONIC_OUT, /* P, Rr 1011 1PPr rrrr PPPP */ + MNEMONIC_SBIC, /* P, b 1001 1001 PPPP Pbbb */ + MNEMONIC_SBIS, /* P, b 1001 1011 PPPP Pbbb */ + MNEMONIC_SBI, /* P, b 1001 1010 PPPP Pbbb */ + MNEMONIC_CBI, /* P, b 1001 1000 PPPP Pbbb */ + MNEMONIC_LDS, /* Rd, k 1001 000d dddd 0000 + 16k */ + MNEMONIC_STS, /* k, Rr 1001 001d dddd 0000 + 16k */ + MNEMONIC_LD, /* Rd, __ dummy */ + MNEMONIC_ST, /* __, Rr dummy */ + MNEMONIC_LDD, /* Rd, _+q dummy */ + MNEMONIC_STD, /* _+q, Rr dummy */ + MNEMONIC_COUNT, + MNEMONIC_LPM_Z, /* Rd, Z 1001 000d dddd 0100 */ + MNEMONIC_LPM_ZP, /* Rd, Z+ 1001 000d dddd 0101 */ + MNEMONIC_ELPM_Z, /* Rd, Z 1001 000d dddd 0110 */ + MNEMONIC_ELPM_ZP, /* Rd, Z+ 1001 000d dddd 0111 */ + MNEMONIC_LD_X, /* Rd, X 1001 000d dddd 1100 */ + MNEMONIC_LD_XP, /* Rd, X+ 1001 000d dddd 1101 */ + MNEMONIC_LD_MX, /* Rd, -X 1001 000d dddd 1110 */ + MNEMONIC_LD_Y, /* Rd, Y 1000 000d dddd 1000 */ + MNEMONIC_LD_YP, /* Rd, Y+ 1001 000d dddd 1001 */ + MNEMONIC_LD_MY, /* Rd, -Y 1001 000d dddd 1010 */ + MNEMONIC_LD_Z, /* Rd, Z 1000 000d dddd 0000 */ + MNEMONIC_LD_ZP, /* Rd, Z+ 1001 000d dddd 0001 */ + MNEMONIC_LD_MZ, /* Rd, -Z 1001 000d dddd 0010 */ + MNEMONIC_ST_X, /* X, Rr 1001 001d dddd 1100 */ + MNEMONIC_ST_XP, /* X+, Rr 1001 001d dddd 1101 */ + MNEMONIC_ST_MX, /* -X, Rr 1001 001d dddd 1110 */ + MNEMONIC_ST_Y, /* Y, Rr 1000 001d dddd 1000 */ + MNEMONIC_ST_YP, /* Y+, Rr 1001 001d dddd 1001 */ + MNEMONIC_ST_MY, /* -Y, Rr 1001 001d dddd 1010 */ + MNEMONIC_ST_Z, /* Z, Rr 1000 001d dddd 0000 */ + MNEMONIC_ST_ZP, /* Z+, Rr 1001 001d dddd 0001 */ + MNEMONIC_ST_MZ, /* -Z, Rr 1001 001d dddd 0010 */ + MNEMONIC_LDD_Y, /* Rd, Y+q 10q0 qq0d dddd 1qqq */ + MNEMONIC_LDD_Z, /* Rd, Z+q 10q0 qq0d dddd 0qqq */ + MNEMONIC_STD_Y, /* Y+q, Rr 10q0 qq1r rrrr 1qqq */ + MNEMONIC_STD_Z, /* Z+q, Rr 10q0 qq1r rrrr 0qqq */ + MNEMONIC_LDS_AVR8L,/* Rd, k 1010 0kkk dddd kkkk */ + MNEMONIC_STS_AVR8L,/* Rd, k 1010 1kkk dddd kkkk */ + MNEMONIC_END +}; + +struct instruction { + char *mnemonic; + int opcode; + int flag; /* Device flags meaning the instruction is not supported */ +}; + +struct instruction instruction_list[] = { + {"nop", 0x0000, 0}, + {"sec", 0x9408, 0}, + {"clc", 0x9488, 0}, + {"sen", 0x9428, 0}, + {"cln", 0x94a8, 0}, + {"sez", 0x9418, 0}, + {"clz", 0x9498, 0}, + {"sei", 0x9478, 0}, + {"cli", 0x94f8, 0}, + {"ses", 0x9448, 0}, + {"cls", 0x94c8, 0}, + {"sev", 0x9438, 0}, + {"clv", 0x94b8, 0}, + {"set", 0x9468, 0}, + {"clt", 0x94e8, 0}, + {"seh", 0x9458, 0}, + {"clh", 0x94d8, 0}, + {"sleep", 0x9588, 0}, + {"wdr", 0x95a8, 0}, + {"ijmp", 0x9409, DF_TINY1X}, + {"eijmp", 0x9419, DF_NO_EIJMP}, + {"icall", 0x9509, DF_TINY1X}, + {"eicall",0x9519, DF_NO_EICALL}, + {"ret", 0x9508, 0}, + {"reti", 0x9518, 0}, + {"spm", 0x95e8, DF_NO_SPM}, + {"espm", 0x95f8, DF_NO_ESPM}, + {"break", 0x9598, DF_NO_BREAK}, + {"lpm", 0x95c8, DF_NO_LPM}, + {"elpm", 0x95d8, DF_NO_ELPM}, + {"bset", 0x9408, 0}, + {"bclr", 0x9488, 0}, + {"ser", 0xef0f, 0}, + {"com", 0x9400, 0}, + {"neg", 0x9401, 0}, + {"inc", 0x9403, 0}, + {"dec", 0x940a, 0}, + {"lsr", 0x9406, 0}, + {"ror", 0x9407, 0}, + {"asr", 0x9405, 0}, + {"swap", 0x9402, 0}, + {"push", 0x920f, DF_TINY1X}, + {"pop", 0x900f, DF_TINY1X}, + {"tst", 0x2000, 0}, + {"clr", 0x2400, 0}, + {"lsl", 0x0c00, 0}, + {"rol", 0x1c00, 0}, + {"breq", 0xf001, 0}, + {"brne", 0xf401, 0}, + {"brcs", 0xf000, 0}, + {"brcc", 0xf400, 0}, + {"brsh", 0xf400, 0}, + {"brlo", 0xf000, 0}, + {"brmi", 0xf002, 0}, + {"brpl", 0xf402, 0}, + {"brge", 0xf404, 0}, + {"brlt", 0xf004, 0}, + {"brhs", 0xf005, 0}, + {"brhc", 0xf405, 0}, + {"brts", 0xf006, 0}, + {"brtc", 0xf406, 0}, + {"brvs", 0xf003, 0}, + {"brvc", 0xf403, 0}, + {"brie", 0xf007, 0}, + {"brid", 0xf407, 0}, + {"rjmp", 0xc000, 0}, + {"rcall", 0xd000, 0}, + {"jmp", 0x940c, DF_NO_JMP}, + {"call", 0x940e, DF_NO_JMP}, + {"brbs", 0xf000, 0}, + {"brbc", 0xf400, 0}, + {"add", 0x0c00, 0}, + {"adc", 0x1c00, 0}, + {"sub", 0x1800, 0}, + {"sbc", 0x0800, 0}, + {"and", 0x2000, 0}, + {"or", 0x2800, 0}, + {"eor", 0x2400, 0}, + {"cp", 0x1400, 0}, + {"cpc", 0x0400, 0}, + {"cpse", 0x1000, 0}, + {"mov", 0x2c00, 0}, + {"mul", 0x9c00, DF_NO_MUL}, + {"movw", 0x0100, DF_NO_MOVW}, + {"muls", 0x0200, DF_NO_MUL}, + {"mulsu", 0x0300, DF_NO_MUL}, + {"fmul", 0x0308, DF_NO_MUL}, + {"fmuls", 0x0380, DF_NO_MUL}, + {"fmulsu",0x0388, DF_NO_MUL}, + {"adiw", 0x9600, DF_TINY1X | DF_AVR8L}, + {"sbiw", 0x9700, DF_TINY1X | DF_AVR8L}, + {"subi", 0x5000, 0}, + {"sbci", 0x4000, 0}, + {"andi", 0x7000, 0}, + {"ori", 0x6000, 0}, + {"sbr", 0x6000, 0}, + {"cpi", 0x3000, 0}, + {"ldi", 0xe000, 0}, + {"cbr", 0x7000, 0}, + {"sbrc", 0xfc00, 0}, + {"sbrs", 0xfe00, 0}, + {"bst", 0xfa00, 0}, + {"bld", 0xf800, 0}, + {"in", 0xb000, 0}, + {"out", 0xb800, 0}, + {"sbic", 0x9900, 0}, + {"sbis", 0x9b00, 0}, + {"sbi", 0x9a00, 0}, + {"cbi", 0x9800, 0}, + {"lds", 0x9000, DF_TINY1X | DF_AVR8L}, + {"sts", 0x9200, DF_TINY1X | DF_AVR8L}, + {"ld", 0, 0}, + {"st", 0, 0}, + {"ldd", 0, DF_TINY1X}, + {"std", 0, DF_TINY1X}, + {"count", 0, 0}, + {"lpm", 0x9004, DF_NO_LPM|DF_NO_LPM_X}, + {"lpm", 0x9005, DF_NO_LPM|DF_NO_LPM_X}, + {"elpm", 0x9006, DF_NO_ELPM|DF_NO_ELPM_X}, + {"elpm", 0x9007, DF_NO_ELPM|DF_NO_ELPM_X}, + {"ld", 0x900c, DF_NO_XREG}, + {"ld", 0x900d, DF_NO_XREG}, + {"ld", 0x900e, DF_NO_XREG}, + {"ld", 0x8008, DF_NO_YREG}, + {"ld", 0x9009, DF_NO_YREG}, + {"ld", 0x900a, DF_NO_YREG}, + {"ld", 0x8000, 0}, + {"ld", 0x9001, DF_TINY1X}, + {"ld", 0x9002, DF_TINY1X}, + {"st", 0x920c, DF_NO_XREG}, + {"st", 0x920d, DF_NO_XREG}, + {"st", 0x920e, DF_NO_XREG}, + {"st", 0x8208, DF_NO_YREG}, + {"st", 0x9209, DF_NO_YREG}, + {"st", 0x920a, DF_NO_YREG}, + {"st", 0x8200, 0}, + {"st", 0x9201, DF_TINY1X}, + {"st", 0x9202, DF_TINY1X}, + {"ldd", 0x8008, DF_TINY1X}, + {"ldd", 0x8000, DF_TINY1X}, + {"std", 0x8208, DF_TINY1X}, + {"std", 0x8200, DF_TINY1X}, + {"lds", 0xa000, DF_TINY1X}, + {"sts", 0xa800, DF_TINY1X}, + {"end", 0, 0} +}; + + +/* We try to parse the command name. Is it a assembler mnemonic or anything else ? + * If so, it may be a macro. */ + +int +parse_mnemonic(struct prog_info *pi) +{ + int mnemonic; + int i; + int opcode = 0; + int opcode2 = 0; + int instruction_long = False; + char *operand1; + char *operand2; + struct macro *macro; + char temp[MAX_MNEMONIC_LEN + 1]; + + operand1 = get_next_token(pi->fi->scratch, TERM_SPACE); /* we get the first word on line */ + mnemonic = get_mnemonic_type(pi); + if (mnemonic == -1) { /* if -1 this must be a macro name */ + macro = get_macro(pi, pi->fi->scratch); /* and so, we try to get the corresponding macro struct. */ + if (macro) { + return (expand_macro(pi, macro, operand1)); /* we expand the macro */ + } else { /* if we cant find a name, this is a unknown word. */ + print_msg(pi, MSGTYPE_ERROR, "Unknown mnemonic/macro: %s", pi->fi->scratch); + return (True); + } + } + if (pi->pass == PASS_2) { + if (mnemonic <= MNEMONIC_BREAK) { + if (operand1) { + print_msg(pi, MSGTYPE_WARNING, "Garbage after instruction %s: %s", instruction_list[mnemonic].mnemonic, operand1); + } + opcode = 0; /* No operand */ + } else if (mnemonic <= MNEMONIC_ELPM) { + if (operand1) { + operand2 = get_next_token(operand1, TERM_COMMA); + if (!operand2) { + print_msg(pi, MSGTYPE_ERROR, "%s needs a second operand", instruction_list[mnemonic].mnemonic); + return (True); + } + get_next_token(operand2, TERM_END); + i = get_register(pi, operand1); + opcode = i << 4; + i = get_indirect(pi, operand2); + if (i == 6) { /* Means Z */ + if (mnemonic == MNEMONIC_LPM) + mnemonic = MNEMONIC_LPM_Z; + else if (mnemonic == MNEMONIC_ELPM) + mnemonic = MNEMONIC_ELPM_Z; + } else if (i == 7) { /* Means Z+ */ + if (mnemonic == MNEMONIC_LPM) + mnemonic = MNEMONIC_LPM_ZP; + else if (mnemonic == MNEMONIC_ELPM) + mnemonic = MNEMONIC_ELPM_ZP; + } else { + print_msg(pi, MSGTYPE_ERROR, "Unsupported operand: %s", operand2); + return (True); + } + } else + opcode = 0; + } else { + if (!operand1) { + print_msg(pi, MSGTYPE_ERROR, "%s needs an operand", instruction_list[mnemonic].mnemonic); + return (True); + } + operand2 = get_next_token(operand1, TERM_COMMA); + if (mnemonic >= MNEMONIC_BRBS) { + if (!operand2) { + print_msg(pi, MSGTYPE_ERROR, "%s needs a second operand", instruction_list[mnemonic].mnemonic); + return (True); + } + get_next_token(operand2, TERM_END); + } + if (mnemonic <= MNEMONIC_BCLR) { + if (!get_bitnum(pi, operand1, &i)) + return (False); + opcode = i << 4; + } else if (mnemonic <= MNEMONIC_ROL) { + i = get_register(pi, operand1); + if ((mnemonic == MNEMONIC_SER) && (i < 16)) { + print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); + i &= 0x0f; + } + opcode = i << 4; + if (mnemonic >= MNEMONIC_TST) + opcode |= ((i & 0x10) << 5) | (i & 0x0f); + } else if (mnemonic <= MNEMONIC_RCALL) { + if (!get_expr(pi, operand1, &i)) + return (False); + i -= pi->cseg->addr + 1; + if (mnemonic <= MNEMONIC_BRID) { + if ((i < -64) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "Branch out of range (-64 <= k <= 63)"); + opcode = (i & 0x7f) << 3; + } else { + if (((i < -2048) || (i > 2047)) && (pi->device->flash_size != 4096)) + print_msg(pi, MSGTYPE_ERROR, "Relative address out of range (-2048 <= k <= 2047)"); + opcode = i & 0x0fff; + } + } else if (mnemonic <= MNEMONIC_CALL) { + if (!get_expr(pi, operand1, &i)) + return (False); + if ((i < 0) || (i > 4194303)) + print_msg(pi, MSGTYPE_ERROR, "Address out of range (0 <= k <= 4194303)"); + opcode = ((i & 0x3e0000) >> 13) | ((i & 0x010000) >> 16); + opcode2 = i & 0xffff; + instruction_long = True; + } else if (mnemonic <= MNEMONIC_BRBC) { + if (!get_bitnum(pi, operand1, &i)) + return (False); + opcode = i; + if (!get_expr(pi, operand2, &i)) + return (False); + i -= pi->cseg->addr + 1; + if ((i < -64) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "Branch out of range (-64 <= k <= 63)"); + opcode |= (i & 0x7f) << 3; + } else if (mnemonic <= MNEMONIC_MUL) { + i = get_register(pi, operand1); + opcode = i << 4; + i = get_register(pi, operand2); + opcode |= ((i & 0x10) << 5) | (i & 0x0f); + } else if (mnemonic <= MNEMONIC_MOVW) { + i = get_register(pi, operand1); + if ((i % 2) == 1) + print_msg(pi, MSGTYPE_ERROR, "%s must use a even numbered register for Rd", instruction_list[mnemonic].mnemonic); + opcode = (i / 2) << 4; + i = get_register(pi, operand2); + if ((i % 2) == 1) + print_msg(pi, MSGTYPE_ERROR, "%s must use a even numbered register for Rr", instruction_list[mnemonic].mnemonic); + opcode |= i / 2; + } else if (mnemonic <= MNEMONIC_MULS) { + i = get_register(pi, operand1); + if (i < 16) + print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); + opcode = (i & 0x0f) << 4; + i = get_register(pi, operand2); + if (i < 16) + print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); + opcode |= (i & 0x0f); + } else if (mnemonic <= MNEMONIC_FMULSU) { + i = get_register(pi, operand1); + if ((i < 16) || (i >= 24)) + print_msg(pi, MSGTYPE_ERROR, "%s can only use registers (r16 - r23)", instruction_list[mnemonic].mnemonic); + opcode = (i & 0x07) << 4; + i = get_register(pi, operand2); + if ((i < 16) || (i >= 24)) + print_msg(pi, MSGTYPE_ERROR, "%s can only use registers (r16 - r23)", instruction_list[mnemonic].mnemonic); + opcode |= (i & 0x07); + } else if (mnemonic <= MNEMONIC_SBIW) { + i = get_register(pi, operand1); + if (!((i == 24) || (i == 26) || (i == 28) || (i == 30))) + print_msg(pi, MSGTYPE_ERROR, "%s can only use registers R24, R26, R28 or R30", instruction_list[mnemonic].mnemonic); + opcode = ((i - 24) / 2) << 4; + if (!get_expr(pi, operand2, &i)) + return (False); + if ((i < 0) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "Constant out of range (0 <= k <= 63)"); + opcode |= ((i & 0x30) << 2) | (i & 0x0f); + } else if (mnemonic <= MNEMONIC_CBR) { + i = get_register(pi, operand1); + if (i < 16) + print_msg(pi, MSGTYPE_ERROR, "%s can only use a high register (r16 - r31)", instruction_list[mnemonic].mnemonic); + opcode = (i & 0x0f) << 4; + if (!get_expr(pi, operand2, &i)) + return (False); + if ((i < -128) || (i > 255)) + print_msg(pi, MSGTYPE_WARNING, "Constant out of range (-128 <= k <= 255). Will be masked"); + if (mnemonic == MNEMONIC_CBR) + i = ~i; + opcode |= ((i & 0xf0) << 4) | (i & 0x0f); + } else if (mnemonic <= MNEMONIC_BLD) { + i = get_register(pi, operand1); + opcode = i << 4; + if (!get_bitnum(pi, operand2, &i)) + return (False); + opcode |= i; + } else if (mnemonic == MNEMONIC_IN) { + i = get_register(pi, operand1); + opcode = i << 4; + if (!get_expr(pi, operand2, &i)) + return (False); + if ((i < 0) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 63)"); + opcode |= ((i & 0x30) << 5) | (i & 0x0f); + } else if (mnemonic == MNEMONIC_OUT) { + if (!get_expr(pi, operand1, &i)) + return (False); + if ((i < 0) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 63)"); + opcode = ((i & 0x30) << 5) | (i & 0x0f); + i = get_register(pi, operand2); + opcode |= i << 4; + } else if (mnemonic <= MNEMONIC_CBI) { + if (!get_expr(pi, operand1, &i)) + return (False); + if ((i < 0) || (i > 31)) + print_msg(pi, MSGTYPE_ERROR, "I/O out of range (0 <= P <= 31)"); + opcode = i << 3; + if (!get_bitnum(pi, operand2, &i)) + return (False); + opcode |= i; + } else if (mnemonic == MNEMONIC_LDS) { + i = get_register(pi, operand1); + opcode = i << 4; + /* AVR8L has one word LDS. High nibble of k in funny order */ + if (pi->device->flag & DF_AVR8L) { + mnemonic = MNEMONIC_LDS_AVR8L; + opcode &= 0x00f0; + } + if (!get_expr(pi, operand2, &i)) + return (False); + if (pi->device->flag & DF_AVR8L) { + if ((i < 0x40) || (i > 0xbf)) + print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0x40 <= k <= 0xbf)"); + opcode |= ((i & 0x40) << 2) | ((i & 0x30) << 5) | (i & 0x0f); + } else { + if ((i < 0) || (i > 65535)) + print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); + opcode2 = i; + instruction_long = True; + } + } else if (mnemonic == MNEMONIC_STS) { + if (!get_expr(pi, operand1, &i)) + return (False); + /* AVR8L has one word STS. High nibble of k in funny order */ + if (pi->device->flag & DF_AVR8L) { + mnemonic = MNEMONIC_STS_AVR8L; + if ((i < 0x40) || (i > 0xbf)) + print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0x40 <= k <= 0xbf)"); + opcode |= ((i & 0x40) << 2) | ((i & 0x30) << 5) | (i & 0x0f); + } else { + if ((i < 0) || (i > 65535)) + print_msg(pi, MSGTYPE_ERROR, "SRAM out of range (0 <= k <= 65535)"); + opcode2 = i; + instruction_long = True; + } + i = get_register(pi, operand2); + if (pi->device->flag & DF_AVR8L) + opcode |= ((i << 4) & 0x00f0); + else + opcode = i << 4; + } else if (mnemonic == MNEMONIC_LD) { + i = get_register(pi, operand1); + opcode = i << 4; + mnemonic = MNEMONIC_LD_X + get_indirect(pi, operand2); + } else if (mnemonic == MNEMONIC_ST) { + mnemonic = MNEMONIC_ST_X + get_indirect(pi, operand1); + i = get_register(pi, operand2); + opcode = i << 4; + } else if (mnemonic == MNEMONIC_LDD) { + i = get_register(pi, operand1); + opcode = i << 4; + if (tolower(operand2[0]) == 'z') + mnemonic = MNEMONIC_LDD_Z; + else if (tolower(operand2[0]) == 'y') + mnemonic = MNEMONIC_LDD_Y; + else + print_msg(pi, MSGTYPE_ERROR, "Garbage in second operand (%s)", operand2); + i = 1; + while ((operand2[i] != '\0') && (operand2[i] != '+')) i++; + if (operand2[i] == '\0') { + print_msg(pi, MSGTYPE_ERROR, "Garbage in second operand (%s)", operand2); + return (False); + } + if (!get_expr(pi, &operand2[i + 1], &i)) + return (False); + if ((i < 0) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "Displacement out of range (0 <= q <= 63)"); + opcode |= ((i & 0x20) << 8) | ((i & 0x18) << 7) | (i & 0x07); + } else if (mnemonic == MNEMONIC_STD) { + if (tolower(operand1[0]) == 'z') + mnemonic = MNEMONIC_STD_Z; + else if (tolower(operand1[0]) == 'y') + mnemonic = MNEMONIC_STD_Y; + else + print_msg(pi, MSGTYPE_ERROR, "Garbage in first operand (%s)", operand1); + i = 1; + while ((operand1[i] != '\0') && (operand1[i] != '+')) i++; + if (operand1[i] == '\0') { + print_msg(pi, MSGTYPE_ERROR, "Garbage in first operand (%s)", operand1); + return (False); + } + if (!get_expr(pi, &operand1[i + 1], &i)) + return (False); + if ((i < 0) || (i > 63)) + print_msg(pi, MSGTYPE_ERROR, "Displacement out of range (0 <= q <= 63)"); + opcode = ((i & 0x20) << 8) | ((i & 0x18) << 7) | (i & 0x07); + i = get_register(pi, operand2); + opcode |= i << 4; + } else + print_msg(pi, MSGTYPE_ERROR, "Shit! Missing opcode check [%d]...", mnemonic); + } + if (pi->device->flag & instruction_list[mnemonic].flag) { + strncpy(temp, instruction_list[mnemonic].mnemonic, MAX_MNEMONIC_LEN); + print_msg(pi, MSGTYPE_ERROR, "%s instruction is not supported on %s", + my_strupr(temp), pi->device->name); + } + opcode |= instruction_list[mnemonic].opcode; + if (pi->list_on && pi->list_line) { + if (instruction_long) + fprintf(pi->list_file, "%c:%06lx %04x %04x %s\n", + pi->cseg->ident, pi->cseg->addr, opcode, opcode2, pi->list_line); + else + fprintf(pi->list_file, "%c:%06lx %04x %s\n", + pi->cseg->ident, pi->cseg->addr, opcode, pi->list_line); + pi->list_line = NULL; + } + if (pi->cseg->hfi) { + write_prog_word(pi, pi->cseg->addr, opcode); + if (instruction_long) + write_prog_word(pi, pi->cseg->addr + 1, opcode2); + } + if (instruction_long) + pi->cseg->addr += 2; /* XXX advance */ + else + pi->cseg->addr ++; + } else { /* Pass 1 */ + if (pi->device->flag & DF_AVR8L) + mnemonic = MNEMONIC_LDS_AVR8L; + if ((mnemonic == MNEMONIC_JMP) || (mnemonic == MNEMONIC_CALL) + || (mnemonic == MNEMONIC_LDS) || (mnemonic == MNEMONIC_STS)) { + pi->cseg->addr += 2; + pi->cseg->count += 2; + } else { + pi->cseg->addr++; + pi->cseg->count++; + } + } + return (True); +} + +int +get_mnemonic_type(struct prog_info *pi) +{ + int i; + char *mnemonic; + + mnemonic = my_strlwr(pi->fi->scratch); + + for (i = 0; i < MNEMONIC_COUNT; i++) { + if (!strcmp(mnemonic, instruction_list[i].mnemonic)) { + return (i); + } + } + return (-1); +} + + +int +get_register(struct prog_info *pi, char *data) +{ + char *second_reg; + int reg = 0; + struct def *def; + + /* Check for any occurence of r1:r0 pairs, and if so skip to second register */ + second_reg = strchr(data, ':'); + if (second_reg != NULL) + data = second_reg + 1; + + for (def = pi->first_def; def; def = def->next) + if (!nocase_strcmp(def->name, data)) { + reg = def->reg; + return (reg); + } + if ((tolower(data[0]) == 'r') && isdigit(data[1])) { + reg = atoi(&data[1]); + if (reg > 31) + print_msg(pi, MSGTYPE_ERROR, "R%d is not a valid register", reg); + return (reg); + } + if (data[1] != '\0') { + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", data); + } + switch (data[0]) { + case 'x': + reg = 26; + break; + case 'y': + reg = 28; + break; + case 'z': + reg = 30; + break; + default: + print_msg(pi, MSGTYPE_ERROR, "No register associated with %s", data); + } + if ((reg < 16) && (pi->device->flag & DF_AVR8L)) + print_msg(pi, MSGTYPE_ERROR, "%s can only use a high registers (r16 - r31)", pi->device->name); + + return (reg); +} + +int +get_bitnum(struct prog_info *pi, char *data, int *ret) +{ + if (!get_expr(pi, data, ret)) + return (False); + if ((*ret < 0) || (*ret > 7)) { + print_msg(pi, MSGTYPE_ERROR, "Operand out of range (0 <= s <= 7)"); + return (False); + } + return (True); +} + + +int +get_indirect(struct prog_info *pi, char *operand) +{ + int i = 1; + + switch (tolower(operand[0])) { + case '-': + while (IS_HOR_SPACE(operand[i])) i++; + if (operand[i + 1] != '\0') + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + switch (tolower(operand[i])) { + case 'x': + if (pi->device->flag & DF_NO_XREG) + print_msg(pi, MSGTYPE_ERROR, "X register is not supported on %s", pi->device->name); + return (2); + case 'y': + if (pi->device->flag & DF_NO_YREG) + print_msg(pi, MSGTYPE_ERROR, "Y register is not supported on %s", pi->device->name); + return (5); + case 'z': + return (8); + default: + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + return (0); + } + case 'x': + if (pi->device->flag & DF_NO_XREG) + print_msg(pi, MSGTYPE_ERROR, "X register is not supported on %s", pi->device->name); + while (IS_HOR_SPACE(operand[i])) i++; + if (operand[i] == '+') { + if (operand[i + 1] != '\0') + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + return (1); + } else if (operand[i] == '\0') + return (0); + else + print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); + return (0); + case 'y': + if (pi->device->flag & DF_NO_YREG) + print_msg(pi, MSGTYPE_ERROR, "Y register is not supported on %s", pi->device->name); + while (IS_HOR_SPACE(operand[i])) i++; + if (operand[i] == '+') { + if (operand[i + 1] != '\0') + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + return (4); + } else if (operand[i] == '\0') + return (3); + else + print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); + return (0); + case 'z': + while (IS_HOR_SPACE(operand[i])) i++; + if (operand[i] == '+') { + if (operand[i + 1] != '\0') + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + return (7); + } else if (operand[i] == '\0') + return (6); + else + print_msg(pi, MSGTYPE_ERROR, "Garbage after operand (%s)", operand); + return (0); + default: + print_msg(pi, MSGTYPE_ERROR, "Garbage in operand (%s)", operand); + } + return (0); +} + +/* Return 1 if instruction name is supported by the current device, + * 0 if unsupported, -1 if it is invalid */ +int +is_supported(struct prog_info *pi, char *name) +{ + int mnemonic; + + strncpy(pi->fi->scratch,name,MAX_MNEMONIC_LEN); + mnemonic = get_mnemonic_type(pi); + if (mnemonic == -1) return -1; + if (pi->device->flag & instruction_list[mnemonic].flag) return 0; + return 1; +} + +int +count_supported_instructions(int flags) +{ + int i = 0, count = 0; + while (i < MNEMONIC_END) { + if ((i < MNEMONIC_LD) || (i > MNEMONIC_COUNT)) + if (!(flags & instruction_list[i].flag)) + count++; + i++; + } + return (count); +} + +/* end of mnemonic.c */ + diff -Nru avra-1.3.0/src/parser.c avra-1.4.2+dfsg/src/parser.c --- avra-1.3.0/src/parser.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/parser.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,15 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra - * - * - * SourceForge.net: Detail:713798 Strings are not always correctly handled - * Change made by JEG 5-01-03 - * - * global keyword is now .global to match common sytnax. TW 10-11-05 + * www: https://github.com/Ro5bert/avra */ #include @@ -44,64 +38,56 @@ /* Special fgets. Like fgets, but with better check for CR, LF and FF and without the ending \n char */ /* size must be >=2. No checks for s=NULL, size<2 or stream=NULL. B.A. */ -char *fgets_new(struct prog_info *pi, char *s, int size, FILE *stream) +char * +fgets_new(struct prog_info *pi, char *s, int size, FILE *stream) { int c; char *ptr=s; do { - if((c=fgetc(stream))==EOF || IS_ENDLINE(c)) // Terminate at chr$ 10,12,13,0 and EOF + if ((c=fgetc(stream))==EOF || IS_ENDLINE(c)) /* Terminate at chr$ 10,12,13,0 and EOF */ break; - /* - ** concatenate lines terminated with \ only... - */ - if (c == '\\') - { - /* only newline and cr may follow... */ - if((c=fgetc(stream))==EOF) - break; - - if(!IS_ENDLINE(c)) // Terminate at chr$ 10,12,13,0 and EOF - { - *ptr++ = '\\'; // no concatenation, insert it - } - else - { - // mit be additional LF (DOS) - c=fgetc(stream); - if (IS_ENDLINE(c)) - c=fgetc(stream); - - if (c == EOF) - break; - } - } + /* concatenate lines terminated with \ only... */ + if (c == '\\') { + /* only newline and cr may follow... */ + if ((c=fgetc(stream))==EOF) + break; + + if (!IS_ENDLINE(c)) { /* Terminate at chr$ 10,12,13,0 and EOF */ + *ptr++ = '\\'; /* no concatenation, insert it */ + } else { + /* mit be additional LF (DOS) */ + c=fgetc(stream); + if (IS_ENDLINE(c)) + c=fgetc(stream); + + if (c == EOF) + break; + } + } *ptr++=c; - } while(--size); - if((c==EOF) && (ptr==s)) // EOF and no chars read -> that's all folks + } while (--size); + if ((c==EOF) && (ptr==s)) /* EOF and no chars read -> that's all folks */ return NULL; - if(!size) { - print_msg(pi, MSGTYPE_ERROR, "Line to long"); + if (!size) { + print_msg(pi, MSGTYPE_ERROR, "Line too long"); return NULL; } *ptr=0; - if(c==12) // Check for Formfeed (Bug [1462886]) + if (c==12) /* Check for Formfeed */ print_msg(pi, MSGTYPE_WARNING, "Found Formfeed char. Please remove it."); - if(c==13) { // Check for CR LF sequence (DOS/ Windows line termination) - if((c=fgetc(stream)) != 10) { + if (c==13) { /* Check for CR LF sequence (DOS/ Windows line termination) */ + if ((c=fgetc(stream)) != 10) { ungetc(c,stream); - print_msg(pi, MSGTYPE_WARNING, "Found CR (0x0d) without LF (0x0a). Please add a LF."); - } + } } return s; } -/* - * Parses given assembler file - */ - -int parse_file(struct prog_info *pi, char *filename) +/* Parse given assembler file. */ +int +parse_file(struct prog_info *pi, const char *filename) { #if debug == 1 printf("parse_file\n"); @@ -111,19 +97,19 @@ struct file_info *fi; struct include_file *include_file; ok = True; - if((fi=malloc(sizeof(struct file_info)))==NULL) { + if ((fi=malloc(sizeof(struct file_info)))==NULL) { print_msg(pi, MSGTYPE_OUT_OF_MEM,NULL); - return(False); + return (False); } pi->fi = fi; - if(pi->pass == PASS_1) { - if((include_file = malloc(sizeof(struct include_file)))==NULL) { + if (pi->pass == PASS_1) { + if ((include_file = malloc(sizeof(struct include_file)))==NULL) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); free(fi); - return(False); + return (False); } include_file->next = NULL; - if(pi->last_include_file) { + if (pi->last_include_file) { pi->last_include_file->next = include_file; include_file->num = pi->last_include_file->num + 1; } else { @@ -131,22 +117,22 @@ include_file->num = 0; } pi->last_include_file = include_file; - if((include_file->name = malloc(strlen(filename) + 1))==NULL) { + if ((include_file->name = malloc(strlen(filename) + 1))==NULL) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); free(fi); - return(False); + return (False); } strcpy(include_file->name, filename); - } else { // PASS 2 - for(include_file = pi->first_include_file; include_file; include_file = include_file->next) { - if(!strcmp(include_file->name, filename)) + } else { /* PASS 2 */ + for (include_file = pi->first_include_file; include_file; include_file = include_file->next) { + if (!strcmp(include_file->name, filename)) break; } } - if(!include_file) { + if (!include_file) { print_msg(pi, MSGTYPE_ERROR, "Internal assembler error"); free(fi); - return(False); + return (False); } fi->include_file = include_file; fi->line_number = 0; @@ -154,24 +140,24 @@ #if debug == 1 printf("Opening %s\n",filename); #endif - if((fi->fp = fopen(filename, "r"))==NULL) { + if ((fi->fp = fopen(filename, "r"))==NULL) { perror(filename); free(fi); - return(False); + return (False); } loopok = True; - while(loopok && !fi->exit_file) { - if(fgets_new(pi,fi->buff, LINEBUFFER_LENGTH, fi->fp)) { + while (loopok && !fi->exit_file) { + if (fgets_new(pi,fi->buff, LINEBUFFER_LENGTH, fi->fp)) { fi->line_number++; pi->list_line = fi->buff; ok = parse_line(pi, fi->buff); #if debug == 1 - printf("parse_line was %i\n", ok); + printf("parse_line was %i\n", ok); #endif - if(ok) { - if((pi->pass == PASS_2) && pi->list_line && pi->list_on) + if (ok) { + if ((pi->pass == PASS_2) && pi->list_line && pi->list_on) fprintf(pi->list_file, " %s\n", pi->list_line); - if(pi->error_count >= pi->max_errors) { + if (pi->error_count >= pi->max_errors) { print_msg(pi, MSGTYPE_MESSAGE, "Maximum error count reached. Exiting..."); loopok = False; } @@ -180,7 +166,7 @@ } } else { loopok = False; - if(!feof(fi->fp)) { + if (!feof(fi->fp)) { ok = False; perror(filename); } @@ -188,20 +174,12 @@ } fclose(fi->fp); free(fi); - return(ok); + return (ok); } - -/**************************************************************************** - * - * function parse_line - * - * Parses one line - * - ****************************************************************************/ - - -int parse_line(struct prog_info *pi, char *line) +/* Parse one line. */ +int +parse_line(struct prog_info *pi, char *line) { char *ptr=NULL; int k; @@ -210,202 +188,202 @@ char temp[LINEBUFFER_LENGTH]; struct label *label = NULL; struct macro_call *macro_call; + int len; - while(IS_HOR_SPACE(*line)) line++; /* At first remove leading spaces / tabs */ - if(IS_END_OR_COMMENT(*line)) /* Skip comment line or empty line */ - return(True); - /* Filter out .stab debugging information */ - /* .stabs sometimes contains colon : symbol - might be interpreted as label */ - if(*line == '.') { /* minimal slowdown of existing code */ - if(strncmp(temp,".stabs ",7) == 0 ) { /* compiler output is always lower case */ + while (IS_HOR_SPACE(*line)) line++; /* At first remove leading spaces / tabs */ + if (IS_END_OR_COMMENT(*line)) /* Skip comment line or empty line */ + return (True); + /* Filter out .stab debugging information */ + /* .stabs sometimes contains colon : symbol - might be interpreted as label */ + if (*line == '.') { /* minimal slowdown of existing code */ + if (strncmp(temp,".stabs ",7) == 0) { /* compiler output is always lower case */ strcpy(temp,line); /* TODO : Do we need this temp variable ? Please check */ - return parse_stabs( pi, temp ); + return parse_stabs(pi, temp); } - if(strncmp(temp,".stabn ",7) == 0 ) { + if (strncmp(temp,".stabn ",7) == 0) { strcpy(temp,line); - return parse_stabn( pi, temp ); + return parse_stabn(pi, temp); } } - /* Meta information translation */ + /* Meta information translation */ ptr=line; k=0; - while((ptr=strchr(ptr, '%')) != NULL) { - if(!strncmp(ptr, "%MINUTE%", 8) ) { /* Replacement always shorter than tag -> no length check */ - k=strftime(ptr,3,"%M", localtime(&pi->time)); - strcpy(ptr+k,ptr+8); - ptr+=k; - continue; - } - if(!strncmp(ptr, "%HOUR%", 6) ) { - k=strftime(ptr,3,"%H", localtime(&pi->time)); - strcpy(ptr+k,ptr+6); - ptr+=k; - continue; - } - if(!strncmp(ptr, "%DAY%", 5) ) { - k=strftime(ptr,3,"%d", localtime(&pi->time)); - strcpy(ptr+k,ptr+5); - ptr+=k; - continue; - } - if(!strncmp(ptr, "%MONTH%", 7) ) { - k=strftime(ptr,3,"%m", localtime(&pi->time)); - strcpy(ptr+k,ptr+7); - ptr+=k; - continue; - } - if(!strncmp(ptr, "%YEAR%", 6) ) { - k=strftime(ptr,5,"%Y", localtime(&pi->time)); - strcpy(ptr+k,ptr+6); - ptr+=k; - continue; + len = strlen(ptr); + while ((ptr=strchr(ptr, '%')) != NULL) { + if (!strncmp(ptr, "%MINUTE%", 8)) { /* Replacement always shorter than tag -> no length check */ + k=strftime(ptr, 3, "%M", localtime(&pi->time)); + memmove(ptr+k, ptr+8, len - (ptr+8 - line) + 1); + ptr += k; + len -= 8-k; + } else if (!strncmp(ptr, "%HOUR%", 6)) { + k=strftime(ptr, 3, "%H", localtime(&pi->time)); + memmove(ptr+k, ptr+6, len - (ptr+6 - line) + 1); + ptr += k; + len -= 6-k; + } else if (!strncmp(ptr, "%DAY%", 5)) { + k=strftime(ptr, 3, "%d", localtime(&pi->time)); + memmove(ptr+k, ptr+5, len - (ptr+5 - line) + 1); + ptr += k; + len -= 5-k; + } else if (!strncmp(ptr, "%MONTH%", 7)) { + k=strftime(ptr, 3, "%m", localtime(&pi->time)); + memmove(ptr+k, ptr+7, len - (ptr+7 - line) + 1); + ptr += k; + len -= 7-k; + } else if (!strncmp(ptr, "%YEAR%", 6)) { + k=strftime(ptr, 5, "%Y", localtime(&pi->time)); + memmove(ptr+k, ptr+6, len - (ptr+6 - line) + 1); + ptr += k; + len -= 6-k; + } else { + ptr++; } - ptr++; } -// if(pi->pass == PASS_2) // TODO : Test -// strcpy(pi->list_line, line); - strcpy(pi->fi->scratch,line); - for(i = 0; IS_LABEL(pi->fi->scratch[i]) || (pi->fi->scratch[i] == ':'); i++) - if(pi->fi->scratch[i] == ':') { /* it is a label */ + for (i = 0; IS_LABEL(pi->fi->scratch[i]) || (pi->fi->scratch[i] == ':'); i++) + if (pi->fi->scratch[i] == ':') { /* it is a label */ pi->fi->scratch[i] = '\0'; - if(pi->pass == PASS_1) { - for(macro_call = pi->macro_call; macro_call; macro_call = macro_call->prev_on_stack) { - for(label = pi->macro_call->first_label; label; label = label->next) { - if(!nocase_strcmp(label->name, &pi->fi->scratch[0])) { + if (pi->pass == PASS_1) { + for (macro_call = pi->macro_call; macro_call; macro_call = macro_call->prev_on_stack) { + for (label = pi->macro_call->first_label; label; label = label->next) { + if (!nocase_strcmp(label->name, &pi->fi->scratch[0])) { print_msg(pi, MSGTYPE_ERROR, "Can't redefine local label %s", &pi->fi->scratch[0]); break; } } } - if(test_label(pi,&pi->fi->scratch[0],"Can't redefine label %s")!=NULL) + if (test_label(pi,&pi->fi->scratch[0],"Can't redefine label %s")!=NULL) break; - if(test_variable(pi,&pi->fi->scratch[0],"%s have already been defined as a .SET variable")!=NULL) + if (test_variable(pi,&pi->fi->scratch[0],"%s have already been defined as a .SET variable")!=NULL) break; - if(test_constant(pi,&pi->fi->scratch[0],"%s has already been defined as a .EQU constant")!=NULL) + if (test_constant(pi,&pi->fi->scratch[0],"%s has already been defined as a .EQU constant")!=NULL) break; label = malloc(sizeof(struct label)); - if(!label) { + if (!label) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } label->next = NULL; label->name = malloc(strlen(&pi->fi->scratch[0]) + 1); - if(!label->name) { + if (!label->name) { print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL); - return(False); + return (False); } strcpy(label->name, &pi->fi->scratch[0]); - switch(pi->segment) { - case SEGMENT_CODE: - label->value = pi->cseg_addr; - break; - case SEGMENT_DATA: - label->value = pi->dseg_addr; - break; - case SEGMENT_EEPROM: - label->value = pi->eseg_addr; - break; - } - if(pi->macro_call && !global_label) { - if(pi->macro_call->last_label) + label->value = pi->segment->addr; + + if (pi->macro_call && !global_label) { + if (pi->macro_call->last_label) pi->macro_call->last_label->next = label; - else + else pi->macro_call->first_label = label; - pi->macro_call->last_label = label; + pi->macro_call->last_label = label; } else { - if(pi->last_label) - pi->last_label->next = label; + if (pi->last_label) + pi->last_label->next = label; else pi->first_label = label; pi->last_label = label; } - } + } i++; - while(IS_HOR_SPACE(pi->fi->scratch[i]) && !IS_END_OR_COMMENT(pi->fi->scratch[i])) i++; - if(IS_END_OR_COMMENT(pi->fi->scratch[i])) { - if((pi->pass == PASS_2) && pi->list_on) { // Diff tilpassing + while (IS_HOR_SPACE(pi->fi->scratch[i]) && !IS_END_OR_COMMENT(pi->fi->scratch[i])) i++; + if (IS_END_OR_COMMENT(pi->fi->scratch[i])) { + if ((pi->pass == PASS_2) && pi->list_on) { /* Diff tilpassing */ fprintf(pi->list_file, " %s\n", pi->list_line); pi->list_line = NULL; } - return(True); + return (True); } - strcpy(pi->fi->scratch, &pi->fi->scratch[i]); + memmove(pi->fi->scratch, &pi->fi->scratch[i], strlen(&pi->fi->scratch[i])+1); break; } -#if 0 - if(pi->fi->scratch[0] == '.') { -#else - if((pi->fi->scratch[0] == '.') || (pi->fi->scratch[0] == '#')) { -#endif + if ((pi->fi->scratch[0] == '.') || (pi->fi->scratch[0] == '#')) { pi->fi->label = label; flag = parse_directive(pi); - if((pi->pass == PASS_2) && pi->list_on && pi->list_line) { // Diff tilpassing - fprintf(pi->list_file, " %s\n", pi->list_line); + if ((pi->pass == PASS_2) && pi->list_on && pi->list_line) { /* Diff tilpassing */ + fprintf(pi->list_file, " %s\n", pi->list_line); pi->list_line = NULL; } - return(flag); + return (flag); } else { return parse_mnemonic(pi); } } -/* - * Get the next token, and terminate the last one. - * Termination identifier is specified. - */ - -char *get_next_token(char *data, int term) +/* Get the next token, and terminate the last one. + * Termination identifier is specified. */ +char * +get_next_token(char *data, int term) { int i = 0, j, anti_comma = False; - switch(term) { - case TERM_END: -// while(!IS_END_OR_COMMENT(data[i])) i++; Problems with 2. operand == ';' - while( ((data[i] != ',') || anti_comma) && !(((data[i] == ';') && !anti_comma) || IS_ENDLINE(data[i])) ) { - if((data[i] == '\'') || (data[i] == '"')) - anti_comma = anti_comma ? False : True; - i++; - } - break; - case TERM_SPACE: - while(!IS_HOR_SPACE(data[i]) && !IS_END_OR_COMMENT(data[i])) i++; - break; - case TERM_DASH: - while((data[i] != '-') && !IS_END_OR_COMMENT(data[i])) i++; - break; - case TERM_COLON: - while((data[i] != ':') && !IS_ENDLINE(data[i])) i++; - break; - case TERM_DOUBLEQUOTE: - while((data[i] != '"') && !IS_ENDLINE(data[i])) i++; - break; - case TERM_COMMA: - while(((data[i] != ',') || anti_comma) && !(((data[i] == ';') && !anti_comma) || IS_ENDLINE(data[i])) ) { - if((data[i] == '\'') || (data[i] == '"')) - anti_comma = anti_comma ? False : True; - i++; - } - break; - case TERM_EQUAL: - while((data[i] != '=') && !IS_END_OR_COMMENT(data[i])) i++; - break; - } - if(IS_END_OR_COMMENT(data[i])) { + /* XXX: this does the same thing for TERM_END and TERM_COMMA? */ + switch (term) { + case TERM_END: + /* Skip to next comma or EOL or start of comment, taking into account + * the possibility for ',' or ';' to be inside quotes. */ + while (((data[i] != ',') || anti_comma) && ((data[i] != ';') || anti_comma) && !IS_ENDLINE(data[i])) { + if ((data[i] == '\'') || (data[i] == '"')) + anti_comma = anti_comma ? False : True; + i++; + } + break; + case TERM_SPACE: + /* Skip to next horizontal space or EOL or start of comment. */ + while (!IS_HOR_SPACE(data[i]) && !IS_END_OR_COMMENT(data[i])) i++; + break; + case TERM_DASH: + /* Skip to next dash or EOL or start of comment. */ + while ((data[i] != '-') && !IS_END_OR_COMMENT(data[i])) i++; + break; + case TERM_COLON: + /* Skip to next colon or EOL. */ + while ((data[i] != ':') && !IS_ENDLINE(data[i])) i++; + break; + case TERM_DOUBLEQUOTE: + /* Skip to next double quote or EOL. */ + while ((data[i] != '"') && !IS_ENDLINE(data[i])) i++; + break; + case TERM_COMMA: + /* Skip to next comma or EOL or start of comment, taking into account + * the possibility for ',' or ';' to be inside quotes. */ + while (((data[i] != ',') || anti_comma) && ((data[i] != ';') || anti_comma) && !IS_ENDLINE(data[i])) { + if ((data[i] == '\'') || (data[i] == '"')) + anti_comma = anti_comma ? False : True; + i++; + } + break; + case TERM_EQUAL: + /* Skip to next equals or EOL or start of comment. */ + while ((data[i] != '=') && !IS_END_OR_COMMENT(data[i])) i++; + break; + } + /* If we hit EOL or a comment, return null. */ + if (IS_END_OR_COMMENT(data[i])) { + /* Null-out the EOL/start of comment. */ data[i--] = '\0'; - while(IS_HOR_SPACE(data[i])) data[i--] = '\0'; - return(0); + /* Null-out everything until the first non-horizontal whitespace + * character. */ + while (IS_HOR_SPACE(data[i])) data[i--] = '\0'; + return (0); } j = i - 1; - while(IS_HOR_SPACE(data[j])) data[j--] = '\0'; + /* Null-out all horizontal whitespace before the terminator. */ + while (IS_HOR_SPACE(data[j])) data[j--] = '\0'; + /* Null-out the terminator itself. */ data[i++] = '\0'; - while(IS_HOR_SPACE(data[i]) && !IS_END_OR_COMMENT(data[i])) i++; - if(IS_END_OR_COMMENT(data[i])) - return(0); - return(&data[i]); + /* Skip over all horizontal whitespace after the terminator. */ + while (IS_HOR_SPACE(data[i]) && !IS_END_OR_COMMENT(data[i])) i++; + /* If we hit EOL or a comment, return null. */ + if (IS_END_OR_COMMENT(data[i])) + return (0); + /* i should now be the index of the first non-whitespace character after + * the terminator. */ + return (&data[i]); } /* end of parser.c */ diff -Nru avra-1.3.0/src/stab.h avra-1.4.2+dfsg/src/stab.h --- avra-1.3.0/src/stab.h 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/stab.h 2020-07-18 23:19:00.000000000 +0000 @@ -1,114 +1,99 @@ -/* @(#)stab.h 1.11 92/05/11 SMI */ -/* $Id: stab.h,v 1.2 2005/10/11 08:44:56 tobias-weber Exp $ */ -/* - * Copyright (c) 1990 by Sun Microsystems, Inc. - */ - -/* - * This file gives definitions supplementing - * for permanent symbol table entries. - * These must have one of the N_STAB bits on, - * and are subject to relocation according to the masks in . - */ - -#ifndef _STAB_H -#define _STAB_H - - -#if !defined(_a_out_h) && !defined(_A_OUT_H) -/* this file contains fragments of a.out.h and stab.h relevant to - * support of stabX processing within ELF files - see the - * Format of a symbol table entry - */ -struct nlist { - union { - char *n_name; /* for use when in-core */ - long n_strx; /* index into file string table */ - } n_un; - unsigned char n_type; /* type flag (N_TEXT,..) */ - char n_other; /* unused */ - short n_desc; /* see */ - unsigned long n_value; /* value of symbol (or sdb offset) */ -}; - -/* - * Simple values for n_type. - */ -#define N_UNDF 0x0 /* undefined */ -#define N_ABS 0x2 /* absolute */ -#define N_TEXT 0x4 /* text */ -#define N_DATA 0x6 /* data */ -#define N_BSS 0x8 /* bss */ -#define N_COMM 0x12 /* common (internal to ld) */ -#define N_FN 0x1f /* file name symbol */ - -#define N_EXT 01 /* external bit, or'ed in */ -#define N_TYPE 0x1e /* mask for all the type bits */ - -#endif - -/* - * for symbolic debugger, sdb(1): - */ -#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ -#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ -#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ -#define N_STSYM 0x26 /* static symbol: name,,0,type,address */ -#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ -#define N_MAIN 0x2a /* name of main routine : name,,0,0,0 */ -#define N_ROSYM 0x2c /* ro_data objects */ -#define N_OBJ 0x38 /* object file path or name */ -#define N_OPT 0x3c /* compiler options */ -#define N_RSYM 0x40 /* register sym: name,,0,type,register */ -#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ -#define N_FLINE 0x4c /* function start.end */ -#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ -#define N_ENDM 0x62 /* last stab emitted for module */ -#define N_SO 0x64 /* source file name: name,,0,0,address */ -#define N_LSYM 0x80 /* local sym: name,,0,type,offset */ -#define N_BINCL 0x82 /* header file: name,,0,0,0 */ -#define N_SOL 0x84 /* #included file name: name,,0,0,address */ -#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ -#define N_EINCL 0xa2 /* end of include file */ -#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ -#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ -#define N_EXCL 0xc2 /* excluded include file */ -#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ -#define N_BCOMM 0xe2 /* begin common: name,, */ -#define N_ECOMM 0xe4 /* end common: name,, */ -#define N_ECOML 0xe8 /* end common (local name): ,,address */ -#define N_LENG 0xfe /* second stab entry with length information */ - -/* - * for the berkeley pascal compiler, pc(1): - */ -#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ -#define N_WITH 0xea /* pascal with statement: type,,0,0,offset */ - -/* - * for code browser only - */ -#define N_BROWS 0x48 /* path to associated .cb file */ - -/* - * Optional langauge designations for N_SO - */ -#define N_SO_AS 1 /* Assembler */ -#define N_SO_C 2 /* C */ -#define N_SO_ANSI_C 3 /* ANSI C */ -#define N_SO_CC 4 /* C++ */ -#define N_SO_FORTRAN 5 /* Fortran 77 */ -#define N_SO_PASCAL 6 /* Pascal */ - -/* - * Floating point type values - */ -#define NF_NONE 0 /* Undefined type */ -#define NF_SINGLE 1 /* IEEE 32 bit float */ -#define NF_DOUBLE 2 /* IEEE 64 bit float */ -#define NF_COMPLEX 3 /* Fortran complex */ -#define NF_COMPLEX16 4 /* Fortran double complex */ -#define NF_COMPLEX32 5 /* Fortran complex*16 */ -#define NF_LDOUBLE 6 /* Long double */ - -#endif +/* @(#)stab.h 1.11 92/05/11 SMI */ +/* $Id: stab.h,v 1.2 2005/10/11 08:44:56 tobias-weber Exp $ */ +/* + * Copyright (c) 1990 by Sun Microsystems, Inc. + */ + +/* This file gives definitions supplementing + * for permanent symbol table entries. + * These must have one of the N_STAB bits on, + * and are subject to relocation according to the masks in . */ + +#ifndef _STAB_H +#define _STAB_H + + +#if !defined(_a_out_h) && !defined(_A_OUT_H) +/* this file contains fragments of a.out.h and stab.h relevant to + * support of stabX processing within ELF files - see the + * Format of a symbol table entry */ +struct nlist { + union { + char *n_name; /* for use when in-core */ + long n_strx; /* index into file string table */ + } n_un; + unsigned char n_type; /* type flag (N_TEXT,..) */ + char n_other; /* unused */ + short n_desc; /* see */ + unsigned long n_value; /* value of symbol (or sdb offset) */ +}; + +/* Simple values for n_type. */ +#define N_UNDF 0x0 /* undefined */ +#define N_ABS 0x2 /* absolute */ +#define N_TEXT 0x4 /* text */ +#define N_DATA 0x6 /* data */ +#define N_BSS 0x8 /* bss */ +#define N_COMM 0x12 /* common (internal to ld) */ +#define N_FN 0x1f /* file name symbol */ + +#define N_EXT 01 /* external bit, or'ed in */ +#define N_TYPE 0x1e /* mask for all the type bits */ + +#endif + +/* for symbolic debugger, sdb(1): */ +#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ +#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ +#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ +#define N_STSYM 0x26 /* static symbol: name,,0,type,address */ +#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ +#define N_MAIN 0x2a /* name of main routine : name,,0,0,0 */ +#define N_ROSYM 0x2c /* ro_data objects */ +#define N_OBJ 0x38 /* object file path or name */ +#define N_OPT 0x3c /* compiler options */ +#define N_RSYM 0x40 /* register sym: name,,0,type,register */ +#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ +#define N_FLINE 0x4c /* function start.end */ +#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ +#define N_ENDM 0x62 /* last stab emitted for module */ +#define N_SO 0x64 /* source file name: name,,0,0,address */ +#define N_LSYM 0x80 /* local sym: name,,0,type,offset */ +#define N_BINCL 0x82 /* header file: name,,0,0,0 */ +#define N_SOL 0x84 /* #included file name: name,,0,0,address */ +#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ +#define N_EINCL 0xa2 /* end of include file */ +#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ +#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ +#define N_EXCL 0xc2 /* excluded include file */ +#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ +#define N_BCOMM 0xe2 /* begin common: name,, */ +#define N_ECOMM 0xe4 /* end common: name,, */ +#define N_ECOML 0xe8 /* end common (local name): ,,address */ +#define N_LENG 0xfe /* second stab entry with length information */ + +/* for the berkeley pascal compiler, pc(1): */ +#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ +#define N_WITH 0xea /* pascal with statement: type,,0,0,offset */ + +/* for code browser only */ +#define N_BROWS 0x48 /* path to associated .cb file */ + +/* Optional langauge designations for N_SO */ +#define N_SO_AS 1 /* Assembler */ +#define N_SO_C 2 /* C */ +#define N_SO_ANSI_C 3 /* ANSI C */ +#define N_SO_CC 4 /* C++ */ +#define N_SO_FORTRAN 5 /* Fortran 77 */ +#define N_SO_PASCAL 6 /* Pascal */ + +/* Floating point type values */ +#define NF_NONE 0 /* Undefined type */ +#define NF_SINGLE 1 /* IEEE 32 bit float */ +#define NF_DOUBLE 2 /* IEEE 64 bit float */ +#define NF_COMPLEX 3 /* Fortran complex */ +#define NF_COMPLEX16 4 /* Fortran double complex */ +#define NF_COMPLEX32 5 /* Fortran complex*16 */ +#define NF_LDOUBLE 6 /* Long double */ + +#endif diff -Nru avra-1.3.0/src/stdextra.c avra-1.4.2+dfsg/src/stdextra.c --- avra-1.3.0/src/stdextra.c 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/src/stdextra.c 2020-07-18 23:19:00.000000000 +0000 @@ -1,8 +1,8 @@ /*********************************************************************** * - * avra - Assembler for the Atmel AVR microcontroller series + * AVRA - Assembler for the Atmel AVR microcontroller series * - * Copyright (C) 1998-2003 Jon Anders Haugum, Tobias Weber + * Copyright (C) 1998-2020 The AVRA Authors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,13 +20,9 @@ * Boston, MA 02111-1307, USA. * * - * Authors of avra can be reached at: + * Authors of AVRA can be reached at: * email: jonah@omegav.ntnu.no, tobiw@suprafluid.com - * www: http://sourceforge.net/projects/avra - */ - -/******************************************************************** - * Extra standard functions + * www: https://github.com/Ro5bert/avra */ #include @@ -34,158 +30,186 @@ #include "misc.h" - -/******************************************************************** - * Case insensetive strcmp() - */ - -int nocase_strcmp(char *s, char *t) +/* Case insensetive strcmp() */ +int +nocase_strcmp(const char *s, const char *t) { int i; - for(i = 0; tolower(s[i]) == tolower(t[i]); i++) - if(s[i] == '\0') - return(0); - return(tolower(s[i]) - tolower(t[i])); + for (i = 0; tolower(s[i]) == tolower(t[i]); i++) + if (s[i] == '\0') + return (0); + return (tolower(s[i]) - tolower(t[i])); } - -/******************************************************************** - * Case insensetive strncmp() - */ - -int nocase_strncmp(char *s, char *t, int n) +/* Case insensetive strncmp() */ +int +nocase_strncmp(char *s, char *t, int n) { int i; - for(i = 0; (tolower(s[i]) == tolower(t[i])); i++, n--) - if((s[i] == '\0') || (n == 1)) - return(0); - return(tolower(s[i]) - tolower(t[i])); + for (i = 0; (tolower(s[i]) == tolower(t[i])); i++, n--) + if ((s[i] == '\0') || (n == 1)) + return (0); + return (tolower(s[i]) - tolower(t[i])); } - -/******************************************************************** - * Case insensetive strstr() - */ - -char *nocase_strstr(char *s, char *t) +/* Case insensetive strstr() */ +char * +nocase_strstr(char *s, char *t) { int i = 0, j, found = False; - while((s[i] != '\0') && !found) { + while ((s[i] != '\0') && !found) { j = 0; - while(tolower(t[j]) == tolower(s[i + j])) { + while (tolower(t[j]) == tolower(s[i + j])) { j++; - if(t[j] == '\0') { + if (t[j] == '\0') { found = True; break; - } - else if(s[i + j] == '\0') + } else if (s[i + j] == '\0') break; - } - i++; } + i++; + } i--; - if(found) - return(&s[i]); - return(NULL); + if (found) + return (&s[i]); + return (NULL); } - -/******************************************************************** - * ascii to hex - * ignores "0x" - */ - -int atox(char *s) +/* Convert ascii to hex. Ignores "0x". */ +int +atox(char *s) { int i = 0, ret = 0; - while(s[i] != '\0') { + while (s[i] != '\0') { ret <<= 4; - if((s[i] <= 'F') && (s[i] >= 'A')) + if ((s[i] <= 'F') && (s[i] >= 'A')) ret |= s[i] - 'A' + 10; - else if((s[i] <= 'f') && (s[i] >= 'a')) + else if ((s[i] <= 'f') && (s[i] >= 'a')) ret |= s[i] - 'a' + 10; - else if((s[i] <= '9') && (s[i] >= '0')) + else if ((s[i] <= '9') && (s[i] >= '0')) ret |= s[i] - '0'; i++; } - return(ret); + return (ret); } - -/******************************************************************** - * n ascii chars to int - */ - -int atoi_n(char *s, int n) +/* n ascii chars to int. */ +int +atoi_n(char *s, int n) { int i = 0, ret = 0; - while((s[i] != '\0') && n) { + while ((s[i] != '\0') && n) { ret = 10 * ret + (s[i] - '0'); i++; n--; } - return(ret); + return (ret); } - -/******************************************************************** - * n ascii chars to hex - * 0 < n <= 8 - * ignores "0x" - */ - -int atox_n(char *s, int n) +/* n ascii chars to hex, where 0 < n <= 8. Ignores "0x". */ +int +atox_n(char *s, int n) { int i = 0, ret = 0; - while((s[i] != '\0') && n) { + while ((s[i] != '\0') && n) { ret <<= 4; - if((s[i] <= 'F') && (s[i] >= 'A')) + if ((s[i] <= 'F') && (s[i] >= 'A')) ret |= s[i] - 'A' + 10; - else if((s[i] <= 'f') && (s[i] >= 'a')) + else if ((s[i] <= 'f') && (s[i] >= 'a')) ret |= s[i] - 'a' + 10; - else if((s[i] <= '9') && (s[i] >= '0')) + else if ((s[i] <= '9') && (s[i] >= '0')) ret |= s[i] - '0'; i++; n--; } - return(ret); + return (ret); } -/* - * My own strlwr function since this one only exists in win - */ - -char *my_strlwr(char *in) +/* My own strlwr function since this one only exists in win. */ +char * +my_strlwr(char *in) { - int i; + int i; - for(i = 0; in[i] != '\0'; i++) - in[i] = tolower(in[i]); + for (i = 0; in[i] != '\0'; i++) + in[i] = tolower(in[i]); - return(in); + return (in); } -/* - * My own strupr function since this one only exists in win - */ - -char *my_strupr(char *in) +/* My own strupr function since this one only exists in win. */ +char * +my_strupr(char *in) { - int i; + int i; - for(i = 0; in[i] != '\0'; i++) - in[i] = toupper(in[i]); + for (i = 0; in[i] != '\0'; i++) + in[i] = toupper(in[i]); - return(in); + return (in); } +static int +snprint(char **buf, size_t *limit, const char *const str) +{ + int rc; + rc = snprintf(*buf, *limit, "%s", str); + if (rc <= (int)*limit) + *buf += rc, *limit -= rc; + else + *limit = 0; + return rc; +} + +char * +snprint_list(char *buf, size_t limit, const char *const str_list[]) +{ + int i, rc; + char *ptr = buf; + if (str_list[0] != NULL) + if (str_list[1] != NULL) + snprint(&ptr, &limit, "either "); + for (i = 0; str_list[i] != NULL; i++) { + if (i > 0) { + if (str_list[i+1] == NULL) + snprint(&ptr, &limit, " or "); + else + snprint(&ptr, &limit, ", "); + } + rc = snprintf(ptr, limit, "\"%s\"", str_list[i]); + if (rc <= (int)limit) + ptr += rc, limit -= rc; + else + limit = 0; + } + return buf; +} + +void +test_print_list(void) +{ + static const char *const test_value[] = { + "DEFAULT", + "IGNORE", + "ERROR", + "ABCD", + "123", + "QQ", + "Z", + NULL + }; + char buf[73] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; + int i; + for (i = 0; i < sizeof(buf); i++) + fprintf(stderr, "(%s)\n", snprint_list(buf, i, test_value)); +} /* stdextra.c */ diff -Nru avra-1.3.0/tests/overlap/BSDmakefile avra-1.4.2+dfsg/tests/overlap/BSDmakefile --- avra-1.3.0/tests/overlap/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,6 @@ +SUBDIR= overlap01 overlap02 overlap03 overlap04 overlap05 \ + overlap06 overlap07 overlap08 overlap09 overlap10 \ + overlap11 overlap12 overlap13 overlap14 overlap15 \ + overlap16 overlap17 overlap18 overlap19 overlap20 \ + overlap21 +.include diff -Nru avra-1.3.0/tests/overlap/Makefile.common avra-1.4.2+dfsg/tests/overlap/Makefile.common --- avra-1.3.0/tests/overlap/Makefile.common 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/Makefile.common 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,9 @@ +TESTNAME= test +all: $(TESTNAME).hex + +$(TESTNAME).hex: $(TESTNAME).asm + @echo ==== $(NAME) ==== + $(SHOULDFAIL)/usr/obj/usr/home/saper/hggit/avra/src/avra $(AFLAGS) $(TESTNAME).asm + +clean: + rm -f $(TESTNAME).cof $(TESTNAME).eep.hex $(TESTNAME).hex $(TESTNAME).obj $(TESTNAME).lst diff -Nru avra-1.3.0/tests/overlap/overlap01/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap01/BSDmakefile --- avra-1.3.0/tests/overlap/overlap01/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap01/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA OVERLAP ERROR is accepted +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap01/test.asm avra-1.4.2+dfsg/tests/overlap/overlap01/test.asm --- avra-1.3.0/tests/overlap/overlap01/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap01/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap error diff -Nru avra-1.3.0/tests/overlap/overlap02/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap02/BSDmakefile --- avra-1.3.0/tests/overlap/overlap02/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap02/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA NONEXISTENT gets ignored +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap02/test.asm avra-1.4.2+dfsg/tests/overlap/overlap02/test.asm --- avra-1.3.0/tests/overlap/overlap02/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap02/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma nonexistent 1 diff -Nru avra-1.3.0/tests/overlap/overlap03/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap03/BSDmakefile --- avra-1.3.0/tests/overlap/overlap03/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap03/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if empty PRAGMA fails +SHOULDFAIL= - +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap03/test.asm avra-1.4.2+dfsg/tests/overlap/overlap03/test.asm --- avra-1.3.0/tests/overlap/overlap03/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap03/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma diff -Nru avra-1.3.0/tests/overlap/overlap04/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap04/BSDmakefile --- avra-1.3.0/tests/overlap/overlap04/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap04/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA OVERLAP IGNORE is accepted +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap04/test.asm avra-1.4.2+dfsg/tests/overlap/overlap04/test.asm --- avra-1.3.0/tests/overlap/overlap04/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap04/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap ignore diff -Nru avra-1.3.0/tests/overlap/overlap05/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap05/BSDmakefile --- avra-1.3.0/tests/overlap/overlap05/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap05/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA OVERLAP WARNING is accepted +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap05/test.asm avra-1.4.2+dfsg/tests/overlap/overlap05/test.asm --- avra-1.3.0/tests/overlap/overlap05/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap05/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap warning diff -Nru avra-1.3.0/tests/overlap/overlap06/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap06/BSDmakefile --- avra-1.3.0/tests/overlap/overlap06/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap06/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA OVERLAP DEFAULT is accepted +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap06/test.asm avra-1.4.2+dfsg/tests/overlap/overlap06/test.asm --- avra-1.3.0/tests/overlap/overlap06/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap06/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap default diff -Nru avra-1.3.0/tests/overlap/overlap07/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap07/BSDmakefile --- avra-1.3.0/tests/overlap/overlap07/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap07/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if misspelt PRAGMA OVERLAP parameter fails +SHOULDFAIL= - +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap07/test.asm avra-1.4.2+dfsg/tests/overlap/overlap07/test.asm --- avra-1.3.0/tests/overlap/overlap07/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap07/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap somesing diff -Nru avra-1.3.0/tests/overlap/overlap08/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap08/BSDmakefile --- avra-1.3.0/tests/overlap/overlap08/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap08/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if -O e works +AFLAGS+= -O e +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap08/test.asm avra-1.4.2+dfsg/tests/overlap/overlap08/test.asm --- avra-1.3.0/tests/overlap/overlap08/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap08/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap default diff -Nru avra-1.3.0/tests/overlap/overlap09/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap09/BSDmakefile --- avra-1.3.0/tests/overlap/overlap09/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap09/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if -O w works +AFLAGS+= -O w +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap09/test.asm avra-1.4.2+dfsg/tests/overlap/overlap09/test.asm --- avra-1.3.0/tests/overlap/overlap09/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap09/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap default diff -Nru avra-1.3.0/tests/overlap/overlap10/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap10/BSDmakefile --- avra-1.3.0/tests/overlap/overlap10/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap10/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if -O i works +AFLAGS+= -O i +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap10/test.asm avra-1.4.2+dfsg/tests/overlap/overlap10/test.asm --- avra-1.3.0/tests/overlap/overlap10/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap10/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap default diff -Nru avra-1.3.0/tests/overlap/overlap11/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap11/BSDmakefile --- avra-1.3.0/tests/overlap/overlap11/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap11/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,4 @@ +NAME= Checking if -O x fails +SHOULDFAIL= - +AFLAGS+= -O x +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap11/test.asm avra-1.4.2+dfsg/tests/overlap/overlap11/test.asm --- avra-1.3.0/tests/overlap/overlap11/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap11/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlap default diff -Nru avra-1.3.0/tests/overlap/overlap12/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap12/BSDmakefile --- avra-1.3.0/tests/overlap/overlap12/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap12/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if PRAGMA OVERLAPPING gets accepted +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap12/test.asm avra-1.4.2+dfsg/tests/overlap/overlap12/test.asm --- avra-1.3.0/tests/overlap/overlap12/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap12/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +.device ATmega328P +#pragma overlappingmode default diff -Nru avra-1.3.0/tests/overlap/overlap13/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap13/BSDmakefile --- avra-1.3.0/tests/overlap/overlap13/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap13/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,4 @@ +NAME= Checking if simple overlap in code gets detected with -O e +SHOULDFAIL= - +AFLAGS+= -O e +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap13/test.asm avra-1.4.2+dfsg/tests/overlap/overlap13/test.asm --- avra-1.3.0/tests/overlap/overlap13/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap13/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,5 @@ +.device ATmega328P + .org $100 + ret + .org $100 + ret diff -Nru avra-1.3.0/tests/overlap/overlap14/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap14/BSDmakefile --- avra-1.3.0/tests/overlap/overlap14/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap14/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if simple overlap causes warning with -O w +AFLAGS+= -O w +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap14/test.asm avra-1.4.2+dfsg/tests/overlap/overlap14/test.asm --- avra-1.3.0/tests/overlap/overlap14/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap14/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,5 @@ +.device ATmega328P + .org $100 + ret + .org $100 + ret diff -Nru avra-1.3.0/tests/overlap/overlap15/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap15/BSDmakefile --- avra-1.3.0/tests/overlap/overlap15/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap15/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if simple overlap gets ignored with -O i +AFLAGS+= -O i +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap15/test.asm avra-1.4.2+dfsg/tests/overlap/overlap15/test.asm --- avra-1.3.0/tests/overlap/overlap15/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap15/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,5 @@ +.device ATmega328P + .org $100 + ret + .org $100 + ret diff -Nru avra-1.3.0/tests/overlap/overlap16/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap16/BSDmakefile --- avra-1.3.0/tests/overlap/overlap16/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap16/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if code and data segments can overlap +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap16/test.asm avra-1.4.2+dfsg/tests/overlap/overlap16/test.asm --- avra-1.3.0/tests/overlap/overlap16/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap16/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,8 @@ +.device ATmega328P +#pragma overlap error + .cseg + .org $100 + ret + .dseg + .org $100 + .byte 1 diff -Nru avra-1.3.0/tests/overlap/overlap17/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap17/BSDmakefile --- avra-1.3.0/tests/overlap/overlap17/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap17/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if data segment can overlap +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap17/test.asm avra-1.4.2+dfsg/tests/overlap/overlap17/test.asm --- avra-1.3.0/tests/overlap/overlap17/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap17/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,11 @@ +.device ATmega328P +#pragma overlap warning + .dseg + .org $100 + .byte 1 + .cseg + .org $100 + ret + .dseg + .org $100 + .byte 1 diff -Nru avra-1.3.0/tests/overlap/overlap18/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap18/BSDmakefile --- avra-1.3.0/tests/overlap/overlap18/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap18/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Checking if 1 word overlap gets detected +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap18/test.asm avra-1.4.2+dfsg/tests/overlap/overlap18/test.asm --- avra-1.3.0/tests/overlap/overlap18/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap18/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,6 @@ +.device ATmega328P +#pragma overlap warning + .org $101 + ret + .org $100 + jmp $102 diff -Nru avra-1.3.0/tests/overlap/overlap19/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap19/BSDmakefile --- avra-1.3.0/tests/overlap/overlap19/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap19/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Check if .OVERLAP works +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap19/test.asm avra-1.4.2+dfsg/tests/overlap/overlap19/test.asm --- avra-1.3.0/tests/overlap/overlap19/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap19/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,16 @@ +.device ATmega328P +#pragma overlap error + .overlap + .org $024 + rcall isr + .org $026 + rcall isr + .nooverlap + +isr: + reti +usart_rx_isr: + reti + + .org $024 + jmp usart_rx_isr diff -Nru avra-1.3.0/tests/overlap/overlap20/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap20/BSDmakefile --- avra-1.3.0/tests/overlap/overlap20/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap20/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +NAME= Checking if overlap19 without .NOOVERLAP fails +SHOULDFAIL= - +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap20/test.asm avra-1.4.2+dfsg/tests/overlap/overlap20/test.asm --- avra-1.3.0/tests/overlap/overlap20/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap20/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,14 @@ +.device ATmega328P +#pragma overlap error + .org $024 + rcall isr + .org $026 + rcall isr + +isr: + reti +usart_rx_isr: + reti + + .org $024 + jmp usart_rx_isr diff -Nru avra-1.3.0/tests/overlap/overlap21/BSDmakefile avra-1.4.2+dfsg/tests/overlap/overlap21/BSDmakefile --- avra-1.3.0/tests/overlap/overlap21/BSDmakefile 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap21/BSDmakefile 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +NAME= Check if .NOOVERLAP works +.include "../Makefile.common" diff -Nru avra-1.3.0/tests/overlap/overlap21/test.asm avra-1.4.2+dfsg/tests/overlap/overlap21/test.asm --- avra-1.3.0/tests/overlap/overlap21/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/overlap/overlap21/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,15 @@ +.device ATmega328P +#pragma overlap warning + .overlap + .org $024 + rcall isr + .org $026 + rcall isr + +isr: + reti +usart_rx_isr: + reti + + .org $024 + jmp usart_rx_isr diff -Nru avra-1.3.0/tests/regression/pr16/test avra-1.4.2+dfsg/tests/regression/pr16/test --- avra-1.3.0/tests/regression/pr16/test 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/pr16/test 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,26 @@ +#!/bin/sh + +try() { + if ! ${AVRA} test.asm > /dev/null; then + echo "AVRA had non-zero exit status" + exit 1 + fi + # This is a bit of a hack. Basically, this gets the date in the same format + # as in the test.asm file, converts it to ASCII values, concatenates all + # the ASCII values, and then searches for that string of ASCII values in + # the output hex file. + if grep "$(date +%Y%m%d%H%M | od -A n -t x1 | awk '{printf $1$2$3$4$5$6$7$8$9$10$11$12}')" test.hex > /dev/null; then + rm test.hex test.eep.hex test.obj + exit 0 + fi +} + +# Try twice, because it's possible that the minute changes in between +# compilation and testing the output. (If the first one succeeds, the second +# one won't run.) + +try +try + +exit 1 + diff -Nru avra-1.3.0/tests/regression/pr16/test.asm avra-1.4.2+dfsg/tests/regression/pr16/test.asm --- avra-1.3.0/tests/regression/pr16/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/pr16/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,5 @@ + +.device atmega2560 + +.db "%YEAR%%MONTH%%DAY%%HOUR%%MINUTE%" + diff -Nru avra-1.3.0/tests/regression/README.md avra-1.4.2+dfsg/tests/regression/README.md --- avra-1.3.0/tests/regression/README.md 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/README.md 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,24 @@ +# Regression tests + +Regression testing is done via the `runtests.sh` script, which has a zero exit +status if and only if all tests passed. +Each test gets it own folder (which should have a descriptive name). +Each test folder must contain either an executable called `test` or a source +file called `test.asm`. + +* If the `test` executable exists, then it is executed inside the test + directory and its return status indicates the result of the test (zero means + success; non-zero means failure). + The `test` executable can use the `AVRA` environment variable to determine + the location of the AVRA executable. + +* Otherwise, the `test.asm` source file is assembled. + If assembly fails, then the test fails. + Additionally, if `test.hex.expected` and `test.eep.hex.expected` exist in the + test folder, then they are compared to the two output files from the + assembler (`test.hex` and `test.eep.hex`, respectively); + if the actual and expected outputs are not identical, then the test fails. + +Of course, it's possible that output changes are normal, due to a new feature +or a bug fix. In these cases, expected hex files should be updated. + diff -Nru avra-1.3.0/tests/regression/runtests.sh avra-1.4.2+dfsg/tests/regression/runtests.sh --- avra-1.3.0/tests/regression/runtests.sh 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/runtests.sh 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,69 @@ +#!/bin/sh + +AVRA="../../src/avra" +tstcnt=0 +failcnt=0 +failed=0 + +fail() { + echo "$1" + failed=1 +} + +for dir in */; do + base="$(basename "${dir}")" + tstfile="${base}/test" + srcfile="${base}/test.asm" + hexfile="${base}/test.hex" + eepfile="${base}/test.eep.hex" + + failed=0 + tstcnt=$((tstcnt+1)) + printf "\nTesting %s\n" "${base}" + + # First look for test executable. + if [ -f "${tstfile}" ]; then + if [ ! -x "${tstfile}" ]; then + fail "${tstfile} is not executable" + elif ! (cd "${base}" && AVRA="../${AVRA}" ./test); then + fail "${tstfile} had non-zero exit status" + fi + # No test executable. Make sure test.asm exists. + elif [ ! -f "${srcfile}" ]; then + fail "Neither ${tstfile} nor ${srcfile} found" + # test.asm exists; compile it. + elif ! ${AVRA} "${srcfile}" > /dev/null; then + fail "AVRA had non-zero exit status" + # test.asm compiled successfully; check expected output. + else + # Check expected hex. + if [ ! -f "${hexfile}.expected" ]; then + echo "No expected HEX file found" + elif cmp "${hexfile}" "${hexfile}.expected"; then + echo "HEX file ok" + else + fail "Different HEX file" + fi + + # Check expected eeprom hex. + if [ ! -f "${eepfile}.expected" ]; then + echo "No expected EEPROM file found" + elif cmp "${eepfile}" "${eepfile}.expected"; then + echo "EEPROM file ok" + else + fail "Different EEPROM file" + fi + + rm "${hexfile}" "${eepfile}" "${base}"/*.obj + fi + + if [ $failed -eq 1 ]; then + echo "FAILED" + failcnt=$((failcnt+1)) + else + echo "PASSED" + fi +done + +printf "\n%d tests, %d failed\n\n" "$tstcnt" "$failcnt" +exit $((!!failcnt)) diff -Nru avra-1.3.0/tests/regression/test1/test.asm avra-1.4.2+dfsg/tests/regression/test1/test.asm --- avra-1.3.0/tests/regression/test1/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test1/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,27 @@ +; Test new device +.device ATmega328P + +; Test number sign labels +#define TEST +.define DOTTEST + + +; Test whitespace between function name and value +ldi r16, high(0) +ldi r17, high (0) + +;--- +; Test data segment start with a number sign instead of a dot +;--- +#DSEG +Buffer: .BYTE 8 ; Reserve 64 bits + +;--- +; EEPROM segment +;--- +.ESEG + +; Test line continuation +AVERAGE: .db 0xF0, 0xFF, \ + 0x55, 0xFF, \ + 0x55, 0x0F diff -Nru avra-1.3.0/tests/regression/test1/test.eep.hex.expected avra-1.4.2+dfsg/tests/regression/test1/test.eep.hex.expected --- avra-1.3.0/tests/regression/test1/test.eep.hex.expected 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test1/test.eep.hex.expected 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +:06000000F0FF55FF550F53 +:00000001FF diff -Nru avra-1.3.0/tests/regression/test1/test.hex.expected avra-1.4.2+dfsg/tests/regression/test1/test.hex.expected --- avra-1.3.0/tests/regression/test1/test.hex.expected 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test1/test.hex.expected 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,3 @@ +:020000020000FC +:0400000000E010E02C +:00000001FF diff -Nru avra-1.3.0/tests/regression/test2/test.asm avra-1.4.2+dfsg/tests/regression/test2/test.asm --- avra-1.3.0/tests/regression/test2/test.asm 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test2/test.asm 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,44 @@ +.device ATmega328P + +; REGISTER USAGE +; +; R1: overflow counter. pin status tied to 7th bit +; R16: tmp stuff + + RJMP MAIN + +MAIN: + LDI R16, 0xff ; low RAMEND + OUT 0x3d, R16 ; SPL + LDI R16, 0x08 ; high RAMEND + OUT 0x3e, R16 ; SPH + + SBI 0x04, 5 ; DDRB5, output + CBI 0x05, 5 ; PORTB5, off + + ; To have a blinking delay that's visible, we have to prescale a lot. + ; The maximum prescaler is 1024, which makes our TCNT0 increase + ; 15625 times per second, which means that it overflows 61 times per + ; second. That's manageable. If we keep a count of overflows in a + ; register and tie our LED to its highest bit, we get a 4 seconds span + ; for that counter. Good enough. + IN R16, 0x25 ; TCCR0B + ORI R16, 0x05 ; CS00 + CS02 = 1024 prescaler + OUT 0x25, R16 + + CLR R1 ; initialize overflow counter + +LOOP: + IN R16, 0x15 ; TIFR0 + SBRC R16, 0 ; is TOV flag clear? + RCALL TOGGLE + RJMP LOOP + +TOGGLE: + LDI R16, 0x01 + OUT 0x15, R16 + INC R1 + CBI 0x05, 5 ; PORTB5, off + SBRS R1, 7 ; if LED is on + SBI 0x05, 5 ; PORTB5, on + RET diff -Nru avra-1.3.0/tests/regression/test2/test.eep.hex.expected avra-1.4.2+dfsg/tests/regression/test2/test.eep.hex.expected --- avra-1.3.0/tests/regression/test2/test.eep.hex.expected 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test2/test.eep.hex.expected 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1 @@ +:00000001FF diff -Nru avra-1.3.0/tests/regression/test2/test.hex.expected avra-1.4.2+dfsg/tests/regression/test2/test.hex.expected --- avra-1.3.0/tests/regression/test2/test.hex.expected 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/tests/regression/test2/test.hex.expected 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,5 @@ +:020000020000FC +:1000000000C00FEF0DBF08E00EBF259A2D9805B573 +:10001000056005BD112405B300FD01D0FCCF01E052 +:0C00200005BB13942D9817FE2D9A08952F +:00000001FF diff -Nru avra-1.3.0/TODO avra-1.4.2+dfsg/TODO --- avra-1.3.0/TODO 2010-08-01 20:47:38.000000000 +0000 +++ avra-1.4.2+dfsg/TODO 2020-07-18 23:19:00.000000000 +0000 @@ -1,10 +1,10 @@ TODO ==== - - .elif does not work within macros - LDS and STS instructions don't address I/O - ATmega8 CALL instruction is bogus - recursion - sigsegv - - .DSEG starts assembly at wrong address for ATmega48/88/168 - Conditional assembly with forward referenced label on .DW directive generates incorrect code - AVRA complains about "((str_start_%)<<1)" beeing invalid - if last line in include is a remark line, it is written twice in the listing + - Printing of diagnostic messages with hexademical numbers is inconsistent + (some are %x; others %X) diff -Nru avra-1.3.0/.travis.yml avra-1.4.2+dfsg/.travis.yml --- avra-1.3.0/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/.travis.yml 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,2 @@ +language: c +script: make check diff -Nru avra-1.3.0/USAGE.md avra-1.4.2+dfsg/USAGE.md --- avra-1.3.0/USAGE.md 1970-01-01 00:00:00.000000000 +0000 +++ avra-1.4.2+dfsg/USAGE.md 2020-07-18 23:19:00.000000000 +0000 @@ -0,0 +1,383 @@ +# AVRA Usage + +To compile a source file, run `avra mysource.S`. You will end up with a +compiled version of the file in Intel HEX format at `mysource.S.hex`. You can +control the output filename with `-o`. See `--help` for more options (not all +options work). + +## Warning Supression + +There is a possibility to supress certain warnings. +Currently only register reassignment warnings can be supressed: + + avra -W NoRegDef + +## Using Directives + +AVRA offers a number of directives that are not part of Atmel's assembler. +These directives should help you in creating versatile and more modular code. + +### Directive `.define` + +To define a constant, use `.define`. This does the same thing as `.equ`; +it is just a little more C style. Keep in mind that AVRA is not case +sensitive. The `.define` directive is not to be confused with `.def`, which is +used to assign registers only. This is due to backward compatibility with +Atmel's AVRASM32. Here is an example on how `.define` can be used: + + .define network 1 + +Now `network` is set to the value 1. You can also define names without values: + + .define network + +Both versions are equivalent, as AVRA will implicitly define `network` to be 1 +in the second case. (Although, if you really want `network` to be 1, you +should use the first version.) You may want to assemble a specific part of your +code depeding on a define or switch setting. You can test your defined word on +existence (`.ifdef` and `.ifndef`) as well as on the value it represents. The +following code shows a way to prevent error messages due to testing undefined +constants: + + .ifndef network + .define network 0 + .endif + +### Directives `.if` and `.else` + +The three lines in the last example set the default value of `network`. +Now we could use the `.if` and `.else` directives test whether, e.g., network +support is to be included into the assembly process: + + .if network = 1 + .include "include\tcpip.asm" + .else + .include "include\dummynet.asm" + .endif + +There is also an `.elif` ("else if") directive, which does what you think. + +### Directive `.error` + +The `.error` directive can be used to throw an error during the assembly +process. The following example shows how we can stop the assembler if a +particular value has not been previously set: + + .ifndef network + .error "network is not configured!" ; the assembler stops here + .endif + +### Directives `.nolist` and `.list` + +The ouput to the list file can be paused and resumed by the `.nolist` and +`.list` directives. After AVRA discovers a `.nolist` while assembling, it +stops output to the list file. After a `.list` directive is detected, AVRA +continues the normal list file output. + +### Directive `.includepath` + +By default, any file that is included from within the source file must +either be a single filename or an absolute path. With the directive +`.includepath` you can set an additional include path. Furthermore, you can +set as many include paths as you want. To avoid ambiguity, be sure not to use +the same filename in separate included directories. + +## Using Include Files + +To avoid multiple inclusion of include files, you can use some directives, as +shown in the following example: + + .ifndef _MYFILE_ASM_ ; Avoid multiple inclusion of myfile.asm + .define _MYFILE_ASM_ + + ; Anything here will only be included once. + + .endif + +## Using Build Date Meta Tags + +You can use some special tags that AVRA supports to implement compiler build +time and date into your program: + + %MINUTE% is replaced by the current minute (00-59) + %HOUR% is replaced by the current hour (00-23) + %DAY% is replaced by the current day of month (01-31) + %MONTH% is replaced by the current month (01-12) + %YEAR% is replaced by the current year (2004-9999) + +For example, these tags can be used as follows: + + buildtime: .db "Release date %DAY%.%MONTH%.%YEAR% %HOUR%:%MINUTE%" + +This line will then be assembled by AVRA into: + + buildtime: .db "Release date 10.05.2004 19:54" + +As another example, you can create an automatically-updating serial number with +meta tags: + + .define serialnumber %DAY% + %MONTH%*31 + (%YEAR% - 2000) *31*12 + +The `%TAG%` is translated before any other parsing happens. The real output can +be found in the list file. + +## Macro Features + +Sometimes you have to work with 16 bit or greater variables stored +in 8 bit registers. AVRA provides enhanced macro support that allows you to +write short and flexible macros that simplify access to big variables. The +enhanced macro features are active when you use square brackets [ ] to wrap +macro parameters. See the following examples. + +### Automatic Type Conversion For Macros + +Values representing more than 8 bits are usualy kept in a set of byte wide +registers. To simplify 16 bit operations, words can be written as `r16:r17`. In +this example, `r16` contains the most significant byte and register `r17` +contains the least significant byte. In the same way, a 24 bit value stored +across 3 registers can be written as `r16:r17:r18`, for example (in this case, +`r16` is the most significant and `r18` is the least significant). In fact, up +to 8 registers can be used with this syntax. + +### Macro Data Types + +There are 3 data types that can be used in macro definitions. The data types +are specified by appending one of the following codes that start with an +underscore to the end of a macro name: + + immediate values _i + registers _8,_16,_24,_32,_40,_48,_56,_64 + void parameter _v + +See the following section for examples on how these types work. + +Within square brackets, the two words `src` and `dst` are interpreted as +`YH:YL` and `ZH:ZL`, respectively. Normal code outside of the macro parameter +square brackets can still make use of the special key words `src` and `dst` +without any side effects. + +### Examples For Automatic Type Conversion and Macro Overloading + +To simplify the examples below, we redefine some registers: + + .def a = r16 ; general purpose registers + .def b = r17 + .def c = r18 + .def d = r19 + + .def w = r20 ; working registers + .def v = r21 + +If we substract the 16 bit value `c:d` from `a:b`, we usually have to use the +following command sequence: + + sub b,d + sbc a,c + +Now we can use macros to simplify subtraction with 16 bit values: + + .macro subs + .message "no parameters specified" + .endm + + .macro subs_16_16 + sub @1,@3 + sbc @0,@2 + .endm + + .macro subs_16_8 + sub @1,@2 + sbci @0,0 + .endm + + ; Now we can write a 16 bit minus 16 bit subtraction as: + + subs [a:b,c:d] + + ; Or, for a 16 bit minus 8 bit subtraction: + + subs [a:b,c] + +Note that we have essentially overloaded the `subs` macro to accept arguments +of different types, just like you could do in C, for example. +Another example of macro overloading follows. + + .macro load + ; This message is shown if you use the macro within your code + ; specifying no parameters. If your macro allows the case where + ; no parameters are given, exchange .message with your code. + .message "no parameters specified" + .endm + + ; Here we define the macro "load" for the case it is being used + ; with two registers as first parameter and an immediate (constant) + ; value as second parameter: + + .macro load_16_i + ldi @0,high(@2) + ldi @1,low(@2) + .endm + + ; The same case, but now with a 32 bit register value as first + ; parameter: + + .macro load_32_i + ldi @0,BYTE4(@4) + ldi @1,BYTE3(@4) + ldi @2,high(@4) + ldi @3,low(@4) + .endm + + ; Now these macros can be invoked as follows: + + load [a:b,15] ; Uses macro load_16_i to load immediate. + + load [a:b:c:d,15] ; Uses macro load_32_i to load immediate. + + +### More Examples + + .dseg + counter: .byte 2 + + .cseg + + .macro poke + .message "no parameters" + .endm + + .macro poke_i_16_i + ldi @1,high(@3) + sts @0+0,@1 + ldi @2,low(@3) + sts @0+1,@2 + .endm + + .macro poke_i_i + ldi w,@1 + sts @0+0,w + .endm + + .macro poke_i_v_i + ldi w,high(@3) + sts @0+0,w + ldi w,low(@3) + sts @0+1,w + .endm + + .macro poke_i_v_v_v_i + ldi w,high(@3) + sts @0+0,w + ldi w,low(@3) + sts @0+1,w + ldi w,BYTE3(@3) + sts @0+2,w + ldi w,BYTE4(@3) + sts @0+3,w + .endm + + + ; This writes 9999 into the memory at 'counter' using only the working + ; register for transfering the values. + + poke [counter,w:w,9999] + + ; This works the same as above, but the transferred value 9999 is also + ; kept in the pair of registers a:b. + + poke [counter,a:b,9999] + + ; In this design 'w' is always a working register, which implies that + ; it cannot be used for normal variables. The following example + ; uses poke_i_i because the parameter contains two immediate values. + + poke [counter,9999] ;uses poke_i_i + + ; To be able to choose between a 8, 16, or 32 bit operation, you just + ; add a void parameter. + + poke [counter,,9999] ;uses poke_i_v_i + + ; And the same for 32 bit pokes: + + poke [counter,,,,9999] ;uses poke_i_v_v_v_i + +### Loops Within Macros + +One problem you may have experienced is that labels defined within macros +are defined twice, for example, if you call the macro two times. You can use +labels for macro loops by appending "_%" to the label. The "%" symbol is +replaced by a running number. + +#### Loop Example + + ; Definition of the macro + + .macro write_8_8 + write_%: + st Z+,@0 + dec @1 + brne write_% + .endm + + ; Use in user code + + write [a,b] + write [c,d] + + ; After assembling this code, the result looks like this: + + write_1: + st Z+,a + dec b + brne write_1 + write_2: + st Z+,c + dec d + brne write_2 + +## Warnings and Errors + +Here are some frequently asked questions about common errors. + +### Constant Out of Range + +This warning occurs if a value exceeds the byte or word value of a assignment. +Read the comment posted by Jim Galbraith: + +The expression (~0x80) is a Bitwise Not operation. This operator returns the +input expression with all its bits inverted. If 0x80 represents -128, then +0x7f, or +127 should be ok. If this is considered as a 32-bit expression (AVRA +internal representation), then it appears to be more like oxffffffff-0x80 or +0xffffffff^0x80. The result would then be 0xffffff7f. The assembler would +then have to be told or it would have to decide, based on context, how much +significance to assign to the higher bits. I have also encountered such +conditions with various assemblers, including AVRA. To make sure the assembler +does what I really want, I use a construct like 0xff-0x80 or 0xff^0x80. This +way the bit significance cannot extend beyond bit-7 and there cannot be any +misunderstanding. + +### Can't Use `.DB` Directive in Data Segment + +The `.DB` and `.DW` directives are only used to assign constant data in the +eeprom or code space. Using these directives within the data segment is +forbidden because you cannot set ram content at assembly time. You can only +allocate memory for your variables using labels and the `.byte` directive: + + .dseg + my_string: .byte 15 + +### The `.byte` Directive + +The `.byte` directive can only be used in data segment (`.dseg`). + +This directive cannot be used in the code or eeprom regions because this only +allocates memory without assigning specific values to it. Instead, use `.db` +or `.dw` for data in the code or eeprom segments. + +### Internal Assembler Error + +If you get an "internal assembler error" please contact the project maintainer +via the [GitHub issue tracker](https://github.com/Ro5bert/avra/issues). Be sure +to include a code example and a description of your working enviroment. +